From: David Laight <[email protected]>

-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 <[email protected]>
---
 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


Reply via email to