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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C4AE6C6FA82 for ; Fri, 23 Sep 2022 10:35:55 +0000 (UTC) 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=Pce2vA9J1t8MH/A1Y5l/A6STgT/3GuTiKgUSFarlzbA=; b=TjU3Dnwf0XguFM pg3myYTMrsxS28ajh21Idt3FBXDYKRny0QfJFFzU+otbe/vIP0FBIDquuRwx3fkMurDHnoLiGL9UI kE9jvPMX8EB5tj6boehvRUPN+TO9tXHic3LoGHfMBAHy3oEOIg/SedhKbqqCgyrGIcFptSwvGNK4i 0pU383VFISC8QpRxFRf98TWqfBOQ1t2w5Idd8qCOajQeQehug8cGTEo93Rmi5XGshkvr1oCw74TZi TcVDwFaq5y/SCuNSHdZC6Db5thRoEVOhI/bIJZZLW1g9oLNZ6+ARPFAnNkD2vwwAFqSW1crKqGZrR 0Y3aucxIY/04zVo7nfhg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1obg1I-003fx8-M6; Fri, 23 Sep 2022 10:34:56 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1obg1E-003fuC-Rv for linux-arm-kernel@lists.infradead.org; Fri, 23 Sep 2022 10:34:55 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 19B7B61AA2; Fri, 23 Sep 2022 10:34:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 718D9C433D7; Fri, 23 Sep 2022 10:34:50 +0000 (UTC) Date: Fri, 23 Sep 2022 11:34:46 +0100 From: Catalin Marinas To: Will Deacon Cc: Mark Rutland , linux-arm-kernel@lists.infradead.org, james.morse@arm.com, robin.murphy@arm.com Subject: Re: [PATCH] arm64: uaccess: simplify uaccess_mask_ptr() Message-ID: References: <20220922151053.3520750-1-mark.rutland@arm.com> <20220922205545.GA12945@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220922205545.GA12945@willie-the-truck> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220923_033452_973517_5E9D734F X-CRM114-Status: GOOD ( 19.27 ) 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 Thu, Sep 22, 2022 at 09:55:46PM +0100, Will Deacon wrote: > On Thu, Sep 22, 2022 at 04:10:53PM +0100, Mark Rutland wrote: > > diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h > > index 2fc9f0861769a..e69559826cb8c 100644 > > --- a/arch/arm64/include/asm/uaccess.h > > +++ b/arch/arm64/include/asm/uaccess.h > > @@ -203,9 +203,11 @@ static inline void uaccess_enable_privileged(void) > > } > > > > /* > > - * Sanitise a uaccess pointer such that it becomes NULL if above the maximum > > - * user address. In case the pointer is tagged (has the top byte set), untag > > - * the pointer before checking. > > + * Sanitize a uaccess pointer such that it cannot reach any kernel address. > > + * > > + * Clearing bit 55 ensures the pointer cannot address any portion of the TTBR1 > > + * address range (i.e. any kernel address), and either the pointer falls within > > + * the TTBR0 address range or must cause a fault. > > */ > > #define uaccess_mask_ptr(ptr) (__typeof__(ptr))__uaccess_mask_ptr(ptr) > > static inline void __user *__uaccess_mask_ptr(const void __user *ptr) > > @@ -213,12 +215,11 @@ static inline void __user *__uaccess_mask_ptr(const void __user *ptr) > > void __user *safe_ptr; > > > > asm volatile( > > - " bics xzr, %3, %2\n" > > - " csel %0, %1, xzr, eq\n" > > - : "=&r" (safe_ptr) > > - : "r" (ptr), "r" (TASK_SIZE_MAX - 1), > > - "r" (untagged_addr(ptr)) > > - : "cc"); > > + " bic %0, %1, %2\n" > > + : "=r" (safe_ptr) > > + : "r" (ptr), > > + "i" (BIT(55)) > > + ); > > > > csdb(); > > Why do we still need the CSDB after your change? Good point, we no longer do a check against TASK_SIZE so no need for flags prediction (IIRC that was the reason for CSDB). -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel