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=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham 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 01071C83004 for ; Wed, 29 Apr 2020 15:24:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B96AD208FE for ; Wed, 29 Apr 2020 15:24:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B96AD208FE 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 3DBFC8E0006; Wed, 29 Apr 2020 11:24:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 366628E0001; Wed, 29 Apr 2020 11:24:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 22DC48E0006; Wed, 29 Apr 2020 11:24:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0252.hostedemail.com [216.40.44.252]) by kanga.kvack.org (Postfix) with ESMTP id 065528E0001 for ; Wed, 29 Apr 2020 11:24:50 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id ABE6E3ABE for ; Wed, 29 Apr 2020 15:24:49 +0000 (UTC) X-FDA: 76761265098.20.bikes41_8169d6fc4970f X-HE-Tag: bikes41_8169d6fc4970f X-Filterd-Recvd-Size: 3468 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Wed, 29 Apr 2020 15:24:49 +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 64F0A1045; Wed, 29 Apr 2020 08:24:48 -0700 (PDT) Received: from gaia (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8FD523F68F; Wed, 29 Apr 2020 08:24:46 -0700 (PDT) Date: Wed, 29 Apr 2020 16:24:44 +0100 From: Catalin Marinas To: Kevin Brodsky Cc: linux-arm-kernel@lists.infradead.org, Will Deacon , Vincenzo Frascino , Szabolcs Nagy , Richard Earnshaw , Andrey Konovalov , Peter Collingbourne , linux-mm@kvack.org, linux-arch@vger.kernel.org, Alan Hayward , Luis Machado , Omair Javaid Subject: Re: [PATCH v3 19/23] arm64: mte: Add PTRACE_{PEEK,POKE}MTETAGS support Message-ID: <20200429152443.GD10651@gaia> References: <20200421142603.3894-1-catalin.marinas@arm.com> <20200421142603.3894-20-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) 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 Wed, Apr 29, 2020 at 11:27:10AM +0100, Kevin Brodsky wrote: > On 21/04/2020 15:25, Catalin Marinas wrote: > > diff --git a/arch/arm64/lib/mte.S b/arch/arm64/lib/mte.S > > index bd51ea7e2fcb..45be04a8c73c 100644 > > --- a/arch/arm64/lib/mte.S > > +++ b/arch/arm64/lib/mte.S > > @@ -5,6 +5,7 @@ > > #include > > #include > > +#include > > /* > > * Compare tags of two pages > > @@ -44,3 +45,52 @@ SYM_FUNC_START(mte_memcmp_pages) > > ret > > SYM_FUNC_END(mte_memcmp_pages) > > + > > +/* > > + * Read tags from a user buffer (one tag per byte) and set the corresponding > > + * tags at the given kernel address. Used by PTRACE_POKEMTETAGS. > > + * x0 - kernel address (to) > > + * x1 - user buffer (from) > > + * x2 - number of tags/bytes (n) > > + * Returns: > > + * x0 - number of tags read/set > > + */ > > +SYM_FUNC_START(mte_copy_tags_from_user) > > + mov x3, x1 > > +1: > > +USER(2f, ldtrb w4, [x1]) > > Here we are making either of the following assumptions: > 1. The __user pointer (here `from`) actually points to user memory, not > kernel memory (and we have set_fs(USER_DS) in place). > 2. CONFIG_ARM64_UAO is enabled and the hardware implements UAO. > > 1. is currently true because these functions are only used for the new > ptrace requests, which indeed pass pointers to user memory. However, future > users of these functions may not know about this requirement. > 2. is not necessarily true because ARM64_MTE does not depend on ARM64_UAO. > > It is unlikely that future users of these functions actually need to pass > __user pointers to kernel memory, so adding a comment spelling out the first > assumption is probably fine. I found it easier to add uao_user_alternative rather than writing a comment ;). Thanks. -- Catalin