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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 D4EE2EA4E07 for ; Mon, 2 Mar 2026 14:07:13 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4fPgjX3CrNz2xc8; Tue, 03 Mar 2026 01:07:12 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip="2a0c:5a00:149::25" ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1772460432; cv=none; b=mr5RgCANwuayVUIPru1EeMXsO/bBAO8uoFuIW0gquVCrjK23MAxqw/NGt+ffRGEXZLq9Tk8I8rTyRLQaotPWgnWeq2QbiLR1Cd0sNoGTFhrCnlEhkZN/+ubVWYD69VupNR4y8QyeWamam6AOwGjs9v0ab8ZEMrcQ25t9lSFHIGlI8waIJbNzoku2pLuLQVaoou1ggDw3JMeo8eyaudNnC73VHcO4zmt1mulAhEE8nsl3DtBXB4qdw5J1mVW7sMSMVZ2aJhUaIXoY3qW602VJFpnUCLKp2PzR2VmBm75m1A4bc9d2nRSrcWuDOHy1yHVS3gZrZRC8S3bR3yU653QLrA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1772460432; c=relaxed/relaxed; bh=o2ClYLRupqDrO68wbhPYoX/KO8vhOPlwFWoOd/NbY3w=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kkzEsVH0WWPEQZPVJBjFtJPaCXTCboepeFrskdfklBTjphWmBsJtDE9AG2q2Sr6fCiL/rphnnV0RMHZ/BM0SGkT0/AnNRUiLtvYfa0po6FjPkL6/9wzVVZ6B3W4YCF2AkuRrMxGc7IRxBL5971pqZQIJCr2xg7ZxNesVCeIxjCTvoSRpN8p1q7MgYDeCsFILM8HV8bVRGOYYa3JE2KyWUbwWfp+AlDjRhrrTLfximV/aXreBFiJ0wzgMtvz0xzlGa+iQxqaCje0Zk8aOuvOZzPTEF/QEEkfPNZZCfq8mlCPDGapHVmPnTupNHdB8ZrUH7bXOIaiW5dNgNb48ZKJ2lQ== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com; dkim=pass (2048-bit key; unprotected) header.d=runbox.com header.i=@runbox.com header.a=rsa-sha256 header.s=selector2 header.b=RaIJo34Y; dkim-atps=neutral; spf=pass (client-ip=2a0c:5a00:149::25; helo=mailtransmit04.runbox.com; envelope-from=david.laight.linux_spam@runbox.com; receiver=lists.ozlabs.org) smtp.mailfrom=runbox.com Authentication-Results: lists.ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=runbox.com header.i=@runbox.com header.a=rsa-sha256 header.s=selector2 header.b=RaIJo34Y; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=runbox.com (client-ip=2a0c:5a00:149::25; helo=mailtransmit04.runbox.com; envelope-from=david.laight.linux_spam@runbox.com; receiver=lists.ozlabs.org) Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [IPv6:2a0c:5a00:149::25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4fPgjW4wb4z2xGF for ; Tue, 03 Mar 2026 01:07:11 +1100 (AEDT) Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vx3Jx-003ZEJ-9O; Mon, 02 Mar 2026 14:28:25 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector2; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:To:From; bh=o2ClYLRupqDrO68wbhPYoX/KO8vhOPlwFWoOd/NbY3w=; b=RaIJo34Y0Q7j2egm9oaHOlOtOd qIf5fI6+l/d2wpNaqq8G9dXTQ9MMLD3B96RqcrmcIuZWAbHSJrVvAOsCyxNnHmB0ApiOwjvIA/WUq 2QHmlroveisu5RbpBCARdjIwFelcSMWSgnuhcGGnezIcVvrdSc/czwp60dIuZ0dJ0UBhYTt3Dir6A kPjMxT6Sx+w5jzEelLAoWpF5WZwr5068t7N9pLbu3BuEHsUXyhRpZNDULOe1NTcLEJsTarSsqPA3q jO3BiP4+6U4spuDiRYWorjNHk7ZXXdxC/8mJTlzMjB17nS6wB8o7mn+sdiXsOXXocQv+tO32ThUWi FRs2OCew==; Received: from [10.9.9.73] (helo=submission02.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vx3Jw-0001hU-9m; Mon, 02 Mar 2026 14:28:24 +0100 Received: by submission02.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vx3Jj-008UTR-SY; Mon, 02 Mar 2026 14:28:11 +0100 From: david.laight.linux@gmail.com To: Alexander Viro , Andre Almeida , Andrew Cooper , Christian Borntraeger , Christian Brauner , Christophe Leroy , "Christophe Leroy (CS GROUP)" , Darren Hart , David Laight , Davidlohr Bueso , Heiko Carstens , Jan Kara , Julia Lawall , Linus Torvalds , linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, LKML , Madhavan Srinivasan , Mathieu Desnoyers , Michael Ellerman , Nicholas Piggin , Nicolas Palix , Palmer Dabbelt , Paul Walmsley , Peter Zijlstra , Russell King , Sven Schnelle , Thomas Gleixner , x86@kernel.org, Kees Cook , akpm@linux-foundation.org Subject: [PATCH v2 4/5] uaccess: Disable -Wshadow in __scoped_user_access() Date: Mon, 2 Mar 2026 13:27:54 +0000 Message-Id: <20260302132755.1475451-5-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260302132755.1475451-1-david.laight.linux@gmail.com> References: <20260302132755.1475451-1-david.laight.linux@gmail.com> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: David Laight -Wshadow is enabled by W=2 builds and __scoped_user_access() quite deliberately creates a 'const' shadow of the 'user' address that references a 'guard page' when the application passes a kernel pointer. Signed-off-by: David Laight --- include/linux/uaccess.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h index 64bc2492eb99..445391ec5a6d 100644 --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h @@ -739,7 +739,9 @@ static __always_inline void __scoped_user_rw_access_end(const void *p) #define __scoped_user_access(mode, uptr, size, elbl) \ with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \ /* Force modified pointer usage within the scope */ \ - and_with (const auto uptr __cleanup(__scoped_user_##mode##_access_end) = _tmpptr) + __diag_push() __diag_ignore_all("-Wshadow", "uptr is readonly copy") \ + and_with (const auto uptr __cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \ + __diag_pop() /** * scoped_user_read_access_size - Start a scoped user read access with given size -- 2.39.5