From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe43.google.com (mail-vs1-xe43.google.com [IPv6:2607:f8b0:4864:20::e43]) by sourceware.org (Postfix) with ESMTPS id 4B15C394443C for ; Wed, 14 Oct 2020 23:43:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4B15C394443C Received: by mail-vs1-xe43.google.com with SMTP id v23so442030vsp.6 for ; Wed, 14 Oct 2020 16:43:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3w+czKVyohLMxBcXMIaP13GyxeCO5C8H4KHeiFeA5uE=; b=W8qetkTJKwsNGIkdJQf+FCL/PFCWW+jBO/yshf+W8U33+HZGq2s90WqpOnflrvmm56 6KsXOYDHPtK9gIC3A2bVt11KUWs/V2MFNv4Dc6lzxQ8dAcmGHQOH8kLKZYxZGKmze7MQ nRw5Uhg51aOamZUkixm2QAXBFBeoXQhmtmdtkwuYqFgmOvpmm8ZfKG9Eh1h0GqjKbO0I H5OnTeGtjYqN9dyRUblcu2Pdpfk8fddYgMt5/BawDlULyUBzKqXjmLp94CHGC73D+6Qp G+ZoMzPZPWgMae2dkAODEuqFJJLiCGPy8LQP/vo4rIcdnEz6PlTrdKhRiA7XrlGoxblh Ze0Q== X-Gm-Message-State: AOAM531sPmqYTMq/pPaPTCjwSqsn+ob7PLQqRXKvVsfqahOjgjRXsvTL ExO+Xr5mbDiFqmDD4Xxl9VFTsYg8dXZJJFtjTQWMo0ffs94= X-Google-Smtp-Source: ABdhPJy+uau90omOax4ZnuqjzDGaW3nLTRRyJ6xot3CSnMwXblec2A/H42qx53XH50y1gjhVCjq44S8JtpYTB76HiVE= X-Received: by 2002:a67:fb96:: with SMTP id n22mr1213426vsr.13.1602719015516; Wed, 14 Oct 2020 16:43:35 -0700 (PDT) MIME-Version: 1.0 References: <20200904103029.32083-1-catalin.marinas@arm.com> <20200904103029.32083-30-catalin.marinas@arm.com> <20200917081107.GA29031@willie-the-truck> <20200917090229.GA10662@gaia> <20200917161550.GA6642@arm.com> <20200918083046.GA30709@willie-the-truck> In-Reply-To: <20200918083046.GA30709@willie-the-truck> From: Peter Collingbourne Date: Wed, 14 Oct 2020 16:43:23 -0700 Message-ID: Subject: Re: [PATCH v9 29/29] arm64: mte: Add Memory Tagging Extension documentation To: Will Deacon Cc: Dave Martin , Catalin Marinas , linux-arch@vger.kernel.org, libc-alpha@sourceware.org, Szabolcs Nagy , Andrey Konovalov , Kevin Brodsky , linux-mm@kvack.org, Andrew Morton , Vincenzo Frascino , Linux ARM Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.2 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Oct 2020 23:43:37 -0000 On Fri, Sep 18, 2020 at 1:30 AM Will Deacon wrote: > > On Thu, Sep 17, 2020 at 05:15:53PM +0100, Dave Martin wrote: > > On Thu, Sep 17, 2020 at 10:02:30AM +0100, Catalin Marinas wrote: > > > On Thu, Sep 17, 2020 at 09:11:08AM +0100, Will Deacon wrote: > > > > On Fri, Sep 04, 2020 at 11:30:29AM +0100, Catalin Marinas wrote: > > > > > From: Vincenzo Frascino > > > > > > > > > > Memory Tagging Extension (part of the ARMv8.5 Extensions) provides > > > > > a mechanism to detect the sources of memory related errors which > > > > > may be vulnerable to exploitation, including bounds violations, > > > > > use-after-free, use-after-return, use-out-of-scope and use before > > > > > initialization errors. > > > > > > > > > > Add Memory Tagging Extension documentation for the arm64 linux > > > > > kernel support. > > > > > > > > > > Signed-off-by: Vincenzo Frascino > > > > > Co-developed-by: Catalin Marinas > > > > > Signed-off-by: Catalin Marinas > > > > > Acked-by: Szabolcs Nagy > > > > > > > > I'm taking this to mean that Szabolcs is happy with the proposed ABI -- > > > > please shout if that's not the case! > > > > > > I think Szabolcs is still on holiday. To summarise the past threads, > > > AFAICT he's happy with this per-thread control ABI but the discussion > > > went on whether to expand it in the future (with a new bit) to > > > synchronise the tag checking mode across all threads of a process. This > > > adds some complications for the kernel as it needs an IPI to the other > > > CPUs to set SCTLR_EL1 and it's also racy with multiple threads > > > requesting different modes. > > > > > > Now, in the glibc land, if the tag check mode is controlled via > > > environment variables, the dynamic loader can set this at process start > > > while still in single-threaded mode and not touch it at run-time. The > > > MTE checking can still be enabled at run-time, per mapped memory range > > > via the PROT_MTE flag. This approach doesn't require any additional > > > changes to the current patches. But it's for Szabolcs to confirm once > > > he's back. > > > > > > > Wasn't there a man page kicking around too? Would be good to see that > > > > go upstream (to the manpages project, of course). > > > > > > Dave started writing one for the tagged address ABI, not sure where that > > > is. For the MTE additions, we are waiting for the ABI to be upstreamed. > > > > The tagged address ABI control stuff is upstream in the man-pages-5.08 > > release. > > > > I don't think anyone drafted anything for MTE yet. Do we consider the > > MTE ABI to be sufficiently stable now for it to be worth starting > > drafting something? > > I think so, yes. I'm hoping to queue it for 5.10, once I have an Ack from > the Android tools side on the per-thread ABI. Our main requirement on the Android side is to provide an API for changing the tag checking mode in all threads in a process while multiple threads are running. I think we've been able to accomplish this [1] by using a libc private real-time signal which is sent to all threads. The implementation has been tested on FVP via the included unit tests. The code has also been tested on real hardware in a multi-threaded app process (of course we don't have MTE-enabled hardware, so the implementation was tested on hardware by hacking it to disable the tagged address ABI instead of changing the tag checking mode, and then verifying via ptrace(PTRACE_GETREGSET) that the tagged address ABI was disabled in all threads). That being said, as with any code at the nexus of concurrency and POSIX signals, the implementation is quite tricky so I would say it falls more into the category of "no obvious problems" than "obviously no problems". It also relies on changes to the implementations of pthread APIs so it wouldn't catch threads created directly via clone() rather than via pthread_create(). I think we would be able to ignore such threads on Android without causing compatibility issues because we can require the process to not create threads via clone() before calling the function. I imagine this may not necessarily work for other libcs like glibc, though, but as I understand it glibc has no plan to offer such an API. I feel confident enough in the kernel API though that I think that it's reasonable as a starting point at least, and that if a problem with the API is discovered I would expect it to be fixable by adding new APIs, so: Acked-by: Peter Collingbourne Peter [1] https://android-review.googlesource.com/c/platform/bionic/+/1427377