mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: david.laight.linux@gmail.com
To: Thomas Gleixner <tglx@linutronix.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Kees Cook <kees@kernel.org>,
	linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
	Al Viro <viro@zeniv.linux.org.uk>
Cc: David Laight <david.laight.linux@gmail.com>
Subject: [PATCH 4/5] uaccess: Disable -Wshadow in __scoped_user_access()
Date: Sat, 20 Dec 2025 21:56:07 +0000	[thread overview]
Message-ID: <20251220215608.434614-5-david.laight.linux@gmail.com> (raw)
In-Reply-To: <20251220215608.434614-1-david.laight.linux@gmail.com>

From: David Laight <david.laight.linux@gmail.com>

-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 <david.laight.linux@gmail.com>
---
 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 589cb2ef2e7b..e2ff4146c5d0 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -754,7 +754,9 @@ USER_ACCESS_GUARD(rw, void)
 	with (typeof(uptr) _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
 		and_with (CLASS(user_##mode##_access, scope)(_tmpptr))			\
 		/* Force modified pointer usage within the scope */			\
-		and_with (const typeof(uptr) uptr = _tmpptr)
+		__diag_push() __diag_ignore_all("-Wshadow", "uptr is readonly copy")	\
+		and_with (const typeof(uptr) uptr = _tmpptr)				\
+		__diag_pop()
 
 /**
  * scoped_user_read_access_size - Start a scoped user read access with given size
-- 
2.39.5


  parent reply	other threads:[~2025-12-20 21:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-20 21:56 [PATCH 0/5] uaccess: Updates to scoped_user_access() david.laight.linux
2025-12-20 21:56 ` [PATCH 1/5] uaccess: Fix scoped_user_read_access() for 'pointer to const' david.laight.linux
2025-12-20 21:56 ` [PATCH 2/5] compiler.h: Add generic support for 'autoterminating nested for() loops' david.laight.linux
2025-12-20 21:56 ` [PATCH 3/5] uaccess.h: Use with() and and_with() in __scoped_user_access() david.laight.linux
2025-12-20 21:56 ` david.laight.linux [this message]
2025-12-20 21:56 ` [PATCH 5/5] signal: Use scoped_user_access() instead of __put/get_user() david.laight.linux

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251220215608.434614-5-david.laight.linux@gmail.com \
    --to=david.laight.linux@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®