From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFDF6C433DF for ; Mon, 1 Jun 2020 16:33:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 75DD72073B for ; Mon, 1 Jun 2020 16:33:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 75DD72073B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E164580007; Mon, 1 Jun 2020 12:33:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DC7808E0006; Mon, 1 Jun 2020 12:33:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB5BF80007; Mon, 1 Jun 2020 12:33:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0154.hostedemail.com [216.40.44.154]) by kanga.kvack.org (Postfix) with ESMTP id B405B8E0006 for ; Mon, 1 Jun 2020 12:33:35 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 62135824805A for ; Mon, 1 Jun 2020 16:33:35 +0000 (UTC) X-FDA: 76881188790.14.day53_1f33882d62c15 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 00D121818A3CC for ; Mon, 1 Jun 2020 16:33:34 +0000 (UTC) X-HE-Tag: day53_1f33882d62c15 X-Filterd-Recvd-Size: 5690 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Mon, 1 Jun 2020 16:33:34 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D8365101E; Mon, 1 Jun 2020 09:33:27 -0700 (PDT) Received: from gaia (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EB7383F305; Mon, 1 Jun 2020 09:33:25 -0700 (PDT) Date: Mon, 1 Jun 2020 17:33:23 +0100 From: Catalin Marinas To: Luis Machado Cc: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, Will Deacon , Dave P Martin , Vincenzo Frascino , Szabolcs Nagy , Kevin Brodsky , Andrey Konovalov , Peter Collingbourne , Alan Hayward , Omair Javaid Subject: Re: [PATCH v4 18/26] arm64: mte: Add PTRACE_{PEEK,POKE}MTETAGS support Message-ID: <20200601163323.GD23419@gaia> References: <20200515171612.1020-1-catalin.marinas@arm.com> <20200515171612.1020-19-catalin.marinas@arm.com> <20200601120724.GB23419@gaia> <48197e4c-0b77-5e35-c735-922aede425c5@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <48197e4c-0b77-5e35-c735-922aede425c5@linaro.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Queue-Id: 00D121818A3CC X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Jun 01, 2020 at 12:17:27PM -0300, Luis Machado wrote: > On 6/1/20 9:07 AM, Catalin Marinas wrote: > > On Fri, May 29, 2020 at 06:25:14PM -0300, Luis Machado wrote: > > > I have a question about siginfo MTE information. I suppose SEGV_MTESERR will > > > be the most useful setting for debugging, right? Does si_addr contain the > > > tagged pointer with the logical tag, a zero-tagged memory address or a > > > tagged pointer with the allocation tag? > > > > The si_addr is zero-tagged currently. We were planning to expose the tag > > in FAR_EL1 as a separate siginfo field. See these discussions: > > > > https://lore.kernel.org/linux-arm-kernel/20200513180914.50892-1-pcc@google.com/ > > https://lore.kernel.org/linux-arm-kernel/20200521022943.195898-1-pcc@google.com/ > > > > In theory, we could add the tag to si_addr for SEGV_MTESERR, it > > shouldn't break the existing ABI (well, it depends on how you look at > > it). > > Having additional fields in siginfo that hold useful information is probably > best for debuggers. See my comment below about Intel MPX. > > > > From the debugger user's perspective, one would want to see both the logical > > > tag and the allocation tag. And it would be handy to have both available in > > > siginfo. Does that make sense? > > > > The debugger can access the allocation tag via PTRACE_PEEKMTETAGS. I > > don't think the kernel should provide this in siginfo. Also, the signal > > handler can do an LDG and read the allocation tag directly, no need for > > it to be in siginfo. > > While the debugger can request this information from the kernel, the > debugger has already received a SIGSEGV signal and will have to fetch > siginfo for si_code. Having to do another PTRACE_PEEKMTETAGS call just to > fetch the allocation tag doesn't sound great. Remember this can travel > through TCP to gdbserver so it can call ptrace from the remote's end. It > would be best to avoid the round trip. But given that this is supposed to be a rare event, does another round trip to read some memory matter much? > Also, there seems to be past precedent to include more information in > siginfo. For example, Intel MPX includes upper/lower bounds violation data > in there. There is a possible race here with getting the allocation tag. For example, another thread of the same process unmaps the memory and reading the tag from the user memory is no longer possible. If we are to add such information, we can't guarantee it's always possible (it may differ from the MPX case). In general, I don't like providing information that's already accessible by other means (unless there's a performance issue but I don't think that's the case here). > Regarding using LDG, are you suggesting force-running this particular > instruction in the traced process? If so, that isn't the way GDB (in > particular, not sure about LLDB) does things. No. What I meant is that if the signal handler itself needs the information, it can execute an LDG. For gdb, the equivalent currently is PTRACE_PEEKMTETAGS. > > > Also, when would we see SEGV_MTEAERR, for example? That would provide no > > > additional information about a particular memory address, which is not that > > > useful for the debugger. > > > > Yeah, we can't really do much here since the hardware doesn't provide us > > such information. The async mode is only useful as a general test to see > > if your program has MTE faults but for actual debugging you'd have to > > switch to synchronous. For glibc at least, I think the mode can be > > driven by an environment variable. > > I suspect SEGV_MTESERR would be a reasonable default then, for whoever is > responsible for setting the default settings. > > I'm assuming it is not the debugger, as it doesn't know how to toggle prctl > settings. The debugger could set the environment before starting the debugged process. But yes, that would be the C library. -- Catalin