[PATCH 4/5] uaccess: Disable -Wshadow in __scoped_user_access()

david.laight.linux@gmail.com posted 5 patches 1 month, 2 weeks ago
[PATCH 4/5] uaccess: Disable -Wshadow in __scoped_user_access()
Posted by david.laight.linux@gmail.com 1 month, 2 weeks ago
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