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=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable 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 E7111C07E96 for ; Thu, 8 Jul 2021 13:00:35 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AE96761456 for ; Thu, 8 Jul 2021 13:00:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE96761456 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eI93zoVNqp+IzqRfZovEzQiaJO26AV+2zeMkcb2el80=; b=mALGd94ATyi4OM DXr3p91MxCgC+ruGzAFhajQCbTkzfGgKQv0OkeTHltzdFnWj/Ajk3LFMHmWBdR3DygCLjOWioOZ9F HlH0M9L43kSd+b5ndwV+/n4pX9ff5XHYZOjtqR+eJjHoyqmOdccnc+pA8XDKctw32ZIF3pbl8/pjy zhCkXacMbP+HAeEelkWAdSKVUdGTCqXfLQzFTBHow/SGhdKsuq/rRnFa0FjrgxlMxqdyV9+URMBKS cE/WHdvbr6A+xt+CRZjn/fvMMyC0zt2tAMqg1Aiw6yd+EHchQIeQRSXVLClP0qQrVjqBhLzP/yWBI xD1UHCQUb3wAfoVPEjNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m1TcI-00GzYD-Ez; Thu, 08 Jul 2021 12:58:58 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m1Tc7-00GzUA-SN for linux-arm-kernel@lists.infradead.org; Thu, 08 Jul 2021 12:58:49 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id D433D61585; Thu, 8 Jul 2021 12:58:44 +0000 (UTC) Date: Thu, 8 Jul 2021 13:58:42 +0100 From: Catalin Marinas To: Peter Collingbourne Cc: Vincenzo Frascino , Dave Martin , Will Deacon , Andrew Morton , Andrea Arcangeli , Alistair Delva , Lokesh Gidra , William McVicker , Evgenii Stepanov , Mitch Phillips , Linux ARM , linux-mm@kvack.org, Andrey Konovalov , stable@vger.kernel.org Subject: Re: [PATCH v4 1/2] userfaultfd: do not untag user pointers Message-ID: <20210708125841.GA9966@arm.com> References: <20210707184313.3697385-1-pcc@google.com> <20210707184313.3697385-2-pcc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210707184313.3697385-2-pcc@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210708_055847_985596_2B03FE30 X-CRM114-Status: GOOD ( 23.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jul 07, 2021 at 11:43:12AM -0700, Peter Collingbourne wrote: > If a user program uses userfaultfd on ranges of heap memory, it may > end up passing a tagged pointer to the kernel in the range.start > field of the UFFDIO_REGISTER ioctl. This can happen when using an > MTE-capable allocator, or on Android if using the Tagged Pointers > feature for MTE readiness [1]. > > When a fault subsequently occurs, the tag is stripped from the fault > address returned to the application in the fault.address field > of struct uffd_msg. However, from the application's perspective, > the tagged address *is* the memory address, so if the application > is unaware of memory tags, it may get confused by receiving an > address that is, from its point of view, outside of the bounds of the > allocation. We observed this behavior in the kselftest for userfaultfd > [2] but other applications could have the same problem. > > Address this by not untagging pointers passed to the userfaultfd > ioctls. Instead, let the system call fail. This will provide an > early indication of problems with tag-unaware userspace code instead > of letting the code get confused later, and is consistent with how > we decided to handle brk/mmap/mremap in commit dcde237319e6 ("mm: > Avoid creating virtual address aliases in brk()/mmap()/mremap()"), > as well as being consistent with the existing tagged address ABI > documentation relating to how ioctl arguments are handled. > > The code change is a revert of commit 7d0325749a6c ("userfaultfd: > untag user pointers") plus some fixups to some additional calls to > validate_range that have appeared since then. > > [1] https://source.android.com/devices/tech/debug/tagged-pointers > [2] tools/testing/selftests/vm/userfaultfd.c > > Signed-off-by: Peter Collingbourne > Reviewed-by: Andrey Konovalov > Link: https://linux-review.googlesource.com/id/I761aa9f0344454c482b83fcfcce547db0a25501b > Fixes: 63f0c6037965 ("arm64: Introduce prctl() options to control the tagged user addresses ABI") > Cc: # 5.4 Reviewed-by: Catalin Marinas _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel