* [PATCH v2 4/5] uaccess: Disable -Wshadow in __scoped_user_access()
@ 2026-03-02 13:27 ` david.laight.linux
0 siblings, 0 replies; 28+ messages in thread
From: david.laight.linux @ 2026-03-02 13:27 UTC (permalink / raw)
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, linux-fsdevel, linuxppc-dev,
linux-riscv, linux-s390, LKML, Madhavan Srinivasan,
Mathieu Desnoyers, Michael Ellerman, Nicholas Piggin,
Nicolas Palix, Palmer Dabbelt, Paul Walmsley, Peter Zijlstra,
Russell King, Sven Schnelle, Thomas Gleixner, x86, Kees Cook,
akpm
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 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
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH v2 4/5] uaccess: Disable -Wshadow in __scoped_user_access()
2026-03-02 13:27 ` david.laight.linux
@ 2026-03-02 15:00 ` Christophe Leroy (CS GROUP)
-1 siblings, 0 replies; 28+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-03-02 15:00 UTC (permalink / raw)
To: david.laight.linux, Alexander Viro, Andre Almeida, Andrew Cooper,
Christian Borntraeger, Christian Brauner, Darren Hart,
Davidlohr Bueso, Heiko Carstens, Jan Kara, Julia Lawall,
Linus Torvalds, linux-arm-kernel, linux-fsdevel, linuxppc-dev,
linux-riscv, linux-s390, LKML, Madhavan Srinivasan,
Mathieu Desnoyers, Michael Ellerman, Nicholas Piggin,
Nicolas Palix, Palmer Dabbelt, Paul Walmsley, Peter Zijlstra,
Russell King, Sven Schnelle, Thomas Gleixner, x86, Kees Cook,
akpm
Le 02/03/2026 à 14:27, david.laight.linux@gmail.com a écrit :
> 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>
There is a problem with this patch:
DESCEND objtool
INSTALL libsubcmd_headers
CALL scripts/checksyscalls.sh
CC kernel/futex/core.o
In file included from ./include/asm-generic/div64.h:27,
from ./arch/powerpc/include/generated/asm/div64.h:1,
from ./include/linux/math.h:6,
from ./include/linux/math64.h:6,
from ./include/linux/time.h:6,
from ./include/linux/compat.h:10,
from kernel/futex/core.c:34:
kernel/futex/futex.h: In function 'futex_get_value_locked':
./include/linux/uaccess.h:740:20: warning: unused variable '_tmpptr'
[-Wunused-variable]
740 | with (auto _tmpptr = __scoped_user_access_begin(mode,
uptr, size, elbl)) \
| ^~~~~~~
./include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
./include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode,
uptr, size, elbl)) \
| ^~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
./include/linux/compiler.h:396:9: warning: this 'for' clause does not
guard... [-Wmisleading-indentation]
396 | for (declaration; !_with_done; _with_done = true)
| ^~~
./include/linux/compiler.h:394:17: note: in expansion of macro 'and_with'
394 | and_with (declaration)
| ^~~~~~~~
./include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode,
uptr, size, elbl)) \
| ^~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
In file included from ././include/linux/compiler_types.h:173,
from <command-line>:
./include/linux/compiler-gcc.h:118:33: note: ...this statement, but the
latter is misleadingly indented as if it were guarded by the 'for'
118 | #define __diag(s) _Pragma(__diag_str(GCC
diagnostic s))
| ^~~~~~~
./include/linux/compiler-gcc.h:129:9: note: in expansion of macro '__diag'
129 | __diag(__diag_GCC_ignore option)
| ^~~~~~
./include/linux/uaccess.h:742:31: note: in expansion of macro
'__diag_ignore_all'
742 | __diag_push() __diag_ignore_all("-Wshadow",
"uptr is readonly copy") \
| ^~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
In file included from ./include/asm-generic/div64.h:27,
from ./arch/powerpc/include/generated/asm/div64.h:1,
from ./include/linux/math.h:6,
from ./include/linux/math64.h:6,
from ./include/linux/time.h:6,
from ./include/linux/compat.h:10,
from kernel/futex/core.c:34:
./include/linux/uaccess.h:743:90: error: '_tmpptr' undeclared (first use
in this function)
743 | and_with (const auto uptr
__cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
|
^~~~~~~
./include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
./include/linux/uaccess.h:743:90: note: each undeclared identifier is
reported only once for each function it appears in
743 | and_with (const auto uptr
__cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
|
^~~~~~~
./include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
./include/linux/compiler.h:396:28: error: '_with_done' undeclared (first
use in this function)
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~
./include/linux/uaccess.h:743:17: note: in expansion of macro 'and_with'
743 | and_with (const auto uptr
__cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
| ^~~~~~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
kernel/futex/core.c: In function 'get_futex_key':
./include/linux/uaccess.h:740:20: warning: unused variable '_tmpptr'
[-Wunused-variable]
740 | with (auto _tmpptr = __scoped_user_access_begin(mode,
uptr, size, elbl)) \
| ^~~~~~~
./include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
./include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode,
uptr, size, elbl)) \
| ^~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
./include/linux/compiler.h:396:9: warning: this 'for' clause does not
guard... [-Wmisleading-indentation]
396 | for (declaration; !_with_done; _with_done = true)
| ^~~
./include/linux/compiler.h:394:17: note: in expansion of macro 'and_with'
394 | and_with (declaration)
| ^~~~~~~~
./include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode,
uptr, size, elbl)) \
| ^~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
In file included from ././include/linux/compiler_types.h:173,
from <command-line>:
./include/linux/compiler-gcc.h:118:33: note: ...this statement, but the
latter is misleadingly indented as if it were guarded by the 'for'
118 | #define __diag(s) _Pragma(__diag_str(GCC
diagnostic s))
| ^~~~~~~
./include/linux/compiler-gcc.h:129:9: note: in expansion of macro '__diag'
129 | __diag(__diag_GCC_ignore option)
| ^~~~~~
./include/linux/uaccess.h:742:31: note: in expansion of macro
'__diag_ignore_all'
742 | __diag_push() __diag_ignore_all("-Wshadow",
"uptr is readonly copy") \
| ^~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
In file included from ./include/asm-generic/div64.h:27,
from ./arch/powerpc/include/generated/asm/div64.h:1,
from ./include/linux/math.h:6,
from ./include/linux/math64.h:6,
from ./include/linux/time.h:6,
from ./include/linux/compat.h:10,
from kernel/futex/core.c:34:
./include/linux/uaccess.h:743:90: error: '_tmpptr' undeclared (first use
in this function)
743 | and_with (const auto uptr
__cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
|
^~~~~~~
./include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
./include/linux/compiler.h:396:28: error: '_with_done' undeclared (first
use in this function)
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~
./include/linux/uaccess.h:743:17: note: in expansion of macro 'and_with'
743 | and_with (const auto uptr
__cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
| ^~~~~~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
./include/linux/uaccess.h:740:20: warning: unused variable '_tmpptr'
[-Wunused-variable]
740 | with (auto _tmpptr = __scoped_user_access_begin(mode,
uptr, size, elbl)) \
| ^~~~~~~
./include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
./include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode,
uptr, size, elbl)) \
| ^~~~
./include/linux/uaccess.h:778:9: note: in expansion of macro
'__scoped_user_access'
778 | __scoped_user_access(write, udst, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:790:9: note: in expansion of macro
'scoped_user_write_access_size'
790 | scoped_user_write_access_size(udst, sizeof(*(udst)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:856:9: note: in expansion of macro
'scoped_user_write_access'
856 | scoped_user_write_access(_tmpdst, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:604:37: note: in expansion of macro 'put_user_inline'
604 | if (node_updated && put_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
./include/linux/compiler.h:396:9: warning: this 'for' clause does not
guard... [-Wmisleading-indentation]
396 | for (declaration; !_with_done; _with_done = true)
| ^~~
./include/linux/compiler.h:394:17: note: in expansion of macro 'and_with'
394 | and_with (declaration)
| ^~~~~~~~
./include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode,
uptr, size, elbl)) \
| ^~~~
./include/linux/uaccess.h:778:9: note: in expansion of macro
'__scoped_user_access'
778 | __scoped_user_access(write, udst, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:790:9: note: in expansion of macro
'scoped_user_write_access_size'
790 | scoped_user_write_access_size(udst, sizeof(*(udst)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:856:9: note: in expansion of macro
'scoped_user_write_access'
856 | scoped_user_write_access(_tmpdst, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:604:37: note: in expansion of macro 'put_user_inline'
604 | if (node_updated && put_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
In file included from ././include/linux/compiler_types.h:173,
from <command-line>:
./include/linux/compiler-gcc.h:118:33: note: ...this statement, but the
latter is misleadingly indented as if it were guarded by the 'for'
118 | #define __diag(s) _Pragma(__diag_str(GCC
diagnostic s))
| ^~~~~~~
./include/linux/compiler-gcc.h:129:9: note: in expansion of macro '__diag'
129 | __diag(__diag_GCC_ignore option)
| ^~~~~~
./include/linux/uaccess.h:742:31: note: in expansion of macro
'__diag_ignore_all'
742 | __diag_push() __diag_ignore_all("-Wshadow",
"uptr is readonly copy") \
| ^~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:778:9: note: in expansion of macro
'__scoped_user_access'
778 | __scoped_user_access(write, udst, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:790:9: note: in expansion of macro
'scoped_user_write_access_size'
790 | scoped_user_write_access_size(udst, sizeof(*(udst)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:856:9: note: in expansion of macro
'scoped_user_write_access'
856 | scoped_user_write_access(_tmpdst, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:604:37: note: in expansion of macro 'put_user_inline'
604 | if (node_updated && put_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
make[4]: *** [scripts/Makefile.build:289: kernel/futex/core.o] Error 1
make[3]: *** [scripts/Makefile.build:546: kernel/futex] Error 2
make[2]: *** [scripts/Makefile.build:546: kernel] Error 2
make[1]: *** [/home/chleroy/linux-powerpc/Makefile:2101: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2
> ---
> 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
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH v2 4/5] uaccess: Disable -Wshadow in __scoped_user_access()
@ 2026-03-02 15:00 ` Christophe Leroy (CS GROUP)
0 siblings, 0 replies; 28+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-03-02 15:00 UTC (permalink / raw)
To: david.laight.linux, Alexander Viro, Andre Almeida, Andrew Cooper,
Christian Borntraeger, Christian Brauner, Darren Hart,
Davidlohr Bueso, Heiko Carstens, Jan Kara, Julia Lawall,
Linus Torvalds, linux-arm-kernel, linux-fsdevel, linuxppc-dev,
linux-riscv, linux-s390, LKML, Madhavan Srinivasan,
Mathieu Desnoyers, Michael Ellerman, Nicholas Piggin,
Nicolas Palix, Palmer Dabbelt, Paul Walmsley, Peter Zijlstra,
Russell King, Sven Schnelle, Thomas Gleixner, x86, Kees Cook,
akpm
Le 02/03/2026 à 14:27, david.laight.linux@gmail.com a écrit :
> 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>
There is a problem with this patch:
DESCEND objtool
INSTALL libsubcmd_headers
CALL scripts/checksyscalls.sh
CC kernel/futex/core.o
In file included from ./include/asm-generic/div64.h:27,
from ./arch/powerpc/include/generated/asm/div64.h:1,
from ./include/linux/math.h:6,
from ./include/linux/math64.h:6,
from ./include/linux/time.h:6,
from ./include/linux/compat.h:10,
from kernel/futex/core.c:34:
kernel/futex/futex.h: In function 'futex_get_value_locked':
./include/linux/uaccess.h:740:20: warning: unused variable '_tmpptr'
[-Wunused-variable]
740 | with (auto _tmpptr = __scoped_user_access_begin(mode,
uptr, size, elbl)) \
| ^~~~~~~
./include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
./include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode,
uptr, size, elbl)) \
| ^~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
./include/linux/compiler.h:396:9: warning: this 'for' clause does not
guard... [-Wmisleading-indentation]
396 | for (declaration; !_with_done; _with_done = true)
| ^~~
./include/linux/compiler.h:394:17: note: in expansion of macro 'and_with'
394 | and_with (declaration)
| ^~~~~~~~
./include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode,
uptr, size, elbl)) \
| ^~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
In file included from ././include/linux/compiler_types.h:173,
from <command-line>:
./include/linux/compiler-gcc.h:118:33: note: ...this statement, but the
latter is misleadingly indented as if it were guarded by the 'for'
118 | #define __diag(s) _Pragma(__diag_str(GCC
diagnostic s))
| ^~~~~~~
./include/linux/compiler-gcc.h:129:9: note: in expansion of macro '__diag'
129 | __diag(__diag_GCC_ignore option)
| ^~~~~~
./include/linux/uaccess.h:742:31: note: in expansion of macro
'__diag_ignore_all'
742 | __diag_push() __diag_ignore_all("-Wshadow",
"uptr is readonly copy") \
| ^~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
In file included from ./include/asm-generic/div64.h:27,
from ./arch/powerpc/include/generated/asm/div64.h:1,
from ./include/linux/math.h:6,
from ./include/linux/math64.h:6,
from ./include/linux/time.h:6,
from ./include/linux/compat.h:10,
from kernel/futex/core.c:34:
./include/linux/uaccess.h:743:90: error: '_tmpptr' undeclared (first use
in this function)
743 | and_with (const auto uptr
__cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
|
^~~~~~~
./include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
./include/linux/uaccess.h:743:90: note: each undeclared identifier is
reported only once for each function it appears in
743 | and_with (const auto uptr
__cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
|
^~~~~~~
./include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
./include/linux/compiler.h:396:28: error: '_with_done' undeclared (first
use in this function)
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~
./include/linux/uaccess.h:743:17: note: in expansion of macro 'and_with'
743 | and_with (const auto uptr
__cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
| ^~~~~~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
kernel/futex/core.c: In function 'get_futex_key':
./include/linux/uaccess.h:740:20: warning: unused variable '_tmpptr'
[-Wunused-variable]
740 | with (auto _tmpptr = __scoped_user_access_begin(mode,
uptr, size, elbl)) \
| ^~~~~~~
./include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
./include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode,
uptr, size, elbl)) \
| ^~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
./include/linux/compiler.h:396:9: warning: this 'for' clause does not
guard... [-Wmisleading-indentation]
396 | for (declaration; !_with_done; _with_done = true)
| ^~~
./include/linux/compiler.h:394:17: note: in expansion of macro 'and_with'
394 | and_with (declaration)
| ^~~~~~~~
./include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode,
uptr, size, elbl)) \
| ^~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
In file included from ././include/linux/compiler_types.h:173,
from <command-line>:
./include/linux/compiler-gcc.h:118:33: note: ...this statement, but the
latter is misleadingly indented as if it were guarded by the 'for'
118 | #define __diag(s) _Pragma(__diag_str(GCC
diagnostic s))
| ^~~~~~~
./include/linux/compiler-gcc.h:129:9: note: in expansion of macro '__diag'
129 | __diag(__diag_GCC_ignore option)
| ^~~~~~
./include/linux/uaccess.h:742:31: note: in expansion of macro
'__diag_ignore_all'
742 | __diag_push() __diag_ignore_all("-Wshadow",
"uptr is readonly copy") \
| ^~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
In file included from ./include/asm-generic/div64.h:27,
from ./arch/powerpc/include/generated/asm/div64.h:1,
from ./include/linux/math.h:6,
from ./include/linux/math64.h:6,
from ./include/linux/time.h:6,
from ./include/linux/compat.h:10,
from kernel/futex/core.c:34:
./include/linux/uaccess.h:743:90: error: '_tmpptr' undeclared (first use
in this function)
743 | and_with (const auto uptr
__cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
|
^~~~~~~
./include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
./include/linux/compiler.h:396:28: error: '_with_done' undeclared (first
use in this function)
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~
./include/linux/uaccess.h:743:17: note: in expansion of macro 'and_with'
743 | and_with (const auto uptr
__cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
| ^~~~~~~~
./include/linux/uaccess.h:755:9: note: in expansion of macro
'__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:767:9: note: in expansion of macro
'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:831:9: note: in expansion of macro
'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
./include/linux/uaccess.h:740:20: warning: unused variable '_tmpptr'
[-Wunused-variable]
740 | with (auto _tmpptr = __scoped_user_access_begin(mode,
uptr, size, elbl)) \
| ^~~~~~~
./include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
./include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode,
uptr, size, elbl)) \
| ^~~~
./include/linux/uaccess.h:778:9: note: in expansion of macro
'__scoped_user_access'
778 | __scoped_user_access(write, udst, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:790:9: note: in expansion of macro
'scoped_user_write_access_size'
790 | scoped_user_write_access_size(udst, sizeof(*(udst)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:856:9: note: in expansion of macro
'scoped_user_write_access'
856 | scoped_user_write_access(_tmpdst, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:604:37: note: in expansion of macro 'put_user_inline'
604 | if (node_updated && put_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
./include/linux/compiler.h:396:9: warning: this 'for' clause does not
guard... [-Wmisleading-indentation]
396 | for (declaration; !_with_done; _with_done = true)
| ^~~
./include/linux/compiler.h:394:17: note: in expansion of macro 'and_with'
394 | and_with (declaration)
| ^~~~~~~~
./include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode,
uptr, size, elbl)) \
| ^~~~
./include/linux/uaccess.h:778:9: note: in expansion of macro
'__scoped_user_access'
778 | __scoped_user_access(write, udst, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:790:9: note: in expansion of macro
'scoped_user_write_access_size'
790 | scoped_user_write_access_size(udst, sizeof(*(udst)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:856:9: note: in expansion of macro
'scoped_user_write_access'
856 | scoped_user_write_access(_tmpdst, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:604:37: note: in expansion of macro 'put_user_inline'
604 | if (node_updated && put_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
In file included from ././include/linux/compiler_types.h:173,
from <command-line>:
./include/linux/compiler-gcc.h:118:33: note: ...this statement, but the
latter is misleadingly indented as if it were guarded by the 'for'
118 | #define __diag(s) _Pragma(__diag_str(GCC
diagnostic s))
| ^~~~~~~
./include/linux/compiler-gcc.h:129:9: note: in expansion of macro '__diag'
129 | __diag(__diag_GCC_ignore option)
| ^~~~~~
./include/linux/uaccess.h:742:31: note: in expansion of macro
'__diag_ignore_all'
742 | __diag_push() __diag_ignore_all("-Wshadow",
"uptr is readonly copy") \
| ^~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:778:9: note: in expansion of macro
'__scoped_user_access'
778 | __scoped_user_access(write, udst, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:790:9: note: in expansion of macro
'scoped_user_write_access_size'
790 | scoped_user_write_access_size(udst, sizeof(*(udst)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/uaccess.h:856:9: note: in expansion of macro
'scoped_user_write_access'
856 | scoped_user_write_access(_tmpdst, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:604:37: note: in expansion of macro 'put_user_inline'
604 | if (node_updated && put_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
make[4]: *** [scripts/Makefile.build:289: kernel/futex/core.o] Error 1
make[3]: *** [scripts/Makefile.build:546: kernel/futex] Error 2
make[2]: *** [scripts/Makefile.build:546: kernel] Error 2
make[1]: *** [/home/chleroy/linux-powerpc/Makefile:2101: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2
> ---
> 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
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH v2 4/5] uaccess: Disable -Wshadow in __scoped_user_access()
2026-03-02 15:00 ` Christophe Leroy (CS GROUP)
@ 2026-03-03 9:12 ` David Laight
-1 siblings, 0 replies; 28+ messages in thread
From: David Laight @ 2026-03-03 9:12 UTC (permalink / raw)
To: Christophe Leroy (CS GROUP)
Cc: Alexander Viro, Andre Almeida, Andrew Cooper,
Christian Borntraeger, Christian Brauner, Darren Hart,
Davidlohr Bueso, Heiko Carstens, Jan Kara, Julia Lawall,
Linus Torvalds, linux-arm-kernel, linux-fsdevel, linuxppc-dev,
linux-riscv, linux-s390, LKML, Madhavan Srinivasan,
Mathieu Desnoyers, Michael Ellerman, Nicholas Piggin,
Nicolas Palix, Palmer Dabbelt, Paul Walmsley, Peter Zijlstra,
Russell King, Sven Schnelle, Thomas Gleixner, x86, Kees Cook,
akpm
On Mon, 2 Mar 2026 16:00:26 +0100
"Christophe Leroy (CS GROUP)" <chleroy@kernel.org> wrote:
> Le 02/03/2026 à 14:27, david.laight.linux@gmail.com a écrit :
> > 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>
>
> There is a problem with this patch:
(badly line-wrapped errors deleted)
It seems to need gcc 12.
(So Linus is in luck.)
Prior to gcc 12 the #pragma generated by _Pragma() act as the
controlled statement of the for () loop.
Trying to put the _Pragma() inside the for statement doesn't work at all.
David
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v2 4/5] uaccess: Disable -Wshadow in __scoped_user_access()
@ 2026-03-03 9:12 ` David Laight
0 siblings, 0 replies; 28+ messages in thread
From: David Laight @ 2026-03-03 9:12 UTC (permalink / raw)
To: Christophe Leroy (CS GROUP)
Cc: Alexander Viro, Andre Almeida, Andrew Cooper,
Christian Borntraeger, Christian Brauner, Darren Hart,
Davidlohr Bueso, Heiko Carstens, Jan Kara, Julia Lawall,
Linus Torvalds, linux-arm-kernel, linux-fsdevel, linuxppc-dev,
linux-riscv, linux-s390, LKML, Madhavan Srinivasan,
Mathieu Desnoyers, Michael Ellerman, Nicholas Piggin,
Nicolas Palix, Palmer Dabbelt, Paul Walmsley, Peter Zijlstra,
Russell King, Sven Schnelle, Thomas Gleixner, x86, Kees Cook,
akpm
On Mon, 2 Mar 2026 16:00:26 +0100
"Christophe Leroy (CS GROUP)" <chleroy@kernel.org> wrote:
> Le 02/03/2026 à 14:27, david.laight.linux@gmail.com a écrit :
> > 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>
>
> There is a problem with this patch:
(badly line-wrapped errors deleted)
It seems to need gcc 12.
(So Linus is in luck.)
Prior to gcc 12 the #pragma generated by _Pragma() act as the
controlled statement of the for () loop.
Trying to put the _Pragma() inside the for statement doesn't work at all.
David
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v2 4/5] uaccess: Disable -Wshadow in __scoped_user_access()
2026-03-02 13:27 ` david.laight.linux
@ 2026-03-02 17:17 ` Linus Torvalds
-1 siblings, 0 replies; 28+ messages in thread
From: Linus Torvalds @ 2026-03-02 17:17 UTC (permalink / raw)
To: david.laight.linux
Cc: Alexander Viro, Andre Almeida, Andrew Cooper,
Christian Borntraeger, Christian Brauner, Christophe Leroy,
Christophe Leroy (CS GROUP), Darren Hart, Davidlohr Bueso,
Heiko Carstens, Jan Kara, Julia Lawall, linux-arm-kernel,
linux-fsdevel, linuxppc-dev, linux-riscv, linux-s390, LKML,
Madhavan Srinivasan, Mathieu Desnoyers, Michael Ellerman,
Nicholas Piggin, Nicolas Palix, Palmer Dabbelt, Paul Walmsley,
Peter Zijlstra, Russell King, Sven Schnelle, Thomas Gleixner, x86,
Kees Cook, akpm
On Mon, 2 Mar 2026 at 05:28, <david.laight.linux@gmail.com> wrote:
>
> 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.
This is too ugly to live.
There is no way that we should make an already unreadable macro even
worse just because somebody - incorrectly - thinks that W=2 matters.
No - what matters a whole lot more is keeping the kernel sources
readable (well, at least as readable as is possible).
Because W=2 is one of those "you get what you deserve" things.
Linus
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH v2 4/5] uaccess: Disable -Wshadow in __scoped_user_access()
@ 2026-03-02 17:17 ` Linus Torvalds
0 siblings, 0 replies; 28+ messages in thread
From: Linus Torvalds @ 2026-03-02 17:17 UTC (permalink / raw)
To: david.laight.linux
Cc: Alexander Viro, Andre Almeida, Andrew Cooper,
Christian Borntraeger, Christian Brauner, Christophe Leroy,
Christophe Leroy (CS GROUP), Darren Hart, Davidlohr Bueso,
Heiko Carstens, Jan Kara, Julia Lawall, linux-arm-kernel,
linux-fsdevel, linuxppc-dev, linux-riscv, linux-s390, LKML,
Madhavan Srinivasan, Mathieu Desnoyers, Michael Ellerman,
Nicholas Piggin, Nicolas Palix, Palmer Dabbelt, Paul Walmsley,
Peter Zijlstra, Russell King, Sven Schnelle, Thomas Gleixner, x86,
Kees Cook, akpm
On Mon, 2 Mar 2026 at 05:28, <david.laight.linux@gmail.com> wrote:
>
> 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.
This is too ugly to live.
There is no way that we should make an already unreadable macro even
worse just because somebody - incorrectly - thinks that W=2 matters.
No - what matters a whole lot more is keeping the kernel sources
readable (well, at least as readable as is possible).
Because W=2 is one of those "you get what you deserve" things.
Linus
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v2 4/5] uaccess: Disable -Wshadow in __scoped_user_access()
2026-03-02 13:27 ` david.laight.linux
@ 2026-03-05 8:10 ` kernel test robot
-1 siblings, 0 replies; 28+ messages in thread
From: kernel test robot @ 2026-03-05 8:10 UTC (permalink / raw)
To: david.laight.linux, Alexander Viro, Andre Almeida, Andrew Cooper,
Christian Borntraeger, Christian Brauner, Christophe Leroy,
Christophe Leroy (CS GROUP), Darren Hart, Davidlohr Bueso,
Heiko Carstens, Jan Kara, Julia Lawall, Linus Torvalds,
linux-arm-kernel, linux-fsdevel, linuxppc-dev, linux-riscv,
linux-s390, Madhavan Srinivasan, Mathieu Desnoyers,
Michael Ellerman, Nicholas Piggin, Nicolas Palix, Palmer Dabbelt,
Paul Walmsley, Peter Zijlstra, Russell King, Sven Schnelle
Cc: oe-kbuild-all, LKML
Hi,
kernel test robot noticed the following build errors:
[auto build test ERROR on brauner-vfs/vfs.all]
[also build test ERROR on v7.0-rc2]
[cannot apply to linus/master next-20260303]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/david-laight-linux-gmail-com/uaccess-Fix-scoped_user_read_access-for-pointer-to-const/20260302-213317
base: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.all
patch link: https://lore.kernel.org/r/20260302132755.1475451-5-david.laight.linux%40gmail.com
patch subject: [PATCH v2 4/5] uaccess: Disable -Wshadow in __scoped_user_access()
config: nios2-allnoconfig (https://download.01.org/0day-ci/archive/20260305/202603051642.i46zzlJ8-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 11.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260305/202603051642.i46zzlJ8-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603051642.i46zzlJ8-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
In file included from include/asm-generic/div64.h:27,
from ./arch/nios2/include/generated/asm/div64.h:1,
from include/linux/math.h:6,
from include/linux/math64.h:6,
from include/linux/time.h:6,
from include/linux/compat.h:10,
from kernel/futex/core.c:34:
kernel/futex/futex.h: In function 'futex_get_value_locked':
>> include/linux/uaccess.h:740:20: warning: unused variable '_tmpptr' [-Wunused-variable]
740 | with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
| ^~~~~~~
include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
| ^~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
>> include/linux/compiler.h:396:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
396 | for (declaration; !_with_done; _with_done = true)
| ^~~
include/linux/compiler.h:394:17: note: in expansion of macro 'and_with'
394 | and_with (declaration)
| ^~~~~~~~
include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
| ^~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
In file included from include/linux/compiler_types.h:173,
from <command-line>:
include/linux/compiler-gcc.h:118:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
118 | #define __diag(s) _Pragma(__diag_str(GCC diagnostic s))
| ^~~~~~~
include/linux/compiler-gcc.h:129:9: note: in expansion of macro '__diag'
129 | __diag(__diag_GCC_ignore option)
| ^~~~~~
include/linux/uaccess.h:742:31: note: in expansion of macro '__diag_ignore_all'
742 | __diag_push() __diag_ignore_all("-Wshadow", "uptr is readonly copy") \
| ^~~~~~~~~~~~~~~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
In file included from include/asm-generic/div64.h:27,
from ./arch/nios2/include/generated/asm/div64.h:1,
from include/linux/math.h:6,
from include/linux/math64.h:6,
from include/linux/time.h:6,
from include/linux/compat.h:10,
from kernel/futex/core.c:34:
>> include/linux/uaccess.h:743:90: error: '_tmpptr' undeclared (first use in this function)
743 | and_with (const auto uptr __cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
| ^~~~~~~
include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
include/linux/uaccess.h:743:90: note: each undeclared identifier is reported only once for each function it appears in
743 | and_with (const auto uptr __cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
| ^~~~~~~
include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
>> include/linux/compiler.h:396:28: error: '_with_done' undeclared (first use in this function)
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~
include/linux/uaccess.h:743:17: note: in expansion of macro 'and_with'
743 | and_with (const auto uptr __cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
| ^~~~~~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
kernel/futex/core.c: In function 'get_futex_key':
>> include/linux/uaccess.h:740:20: warning: unused variable '_tmpptr' [-Wunused-variable]
740 | with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
| ^~~~~~~
include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
| ^~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
>> include/linux/compiler.h:396:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
396 | for (declaration; !_with_done; _with_done = true)
| ^~~
include/linux/compiler.h:394:17: note: in expansion of macro 'and_with'
394 | and_with (declaration)
| ^~~~~~~~
include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
| ^~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
In file included from include/linux/compiler_types.h:173,
from <command-line>:
include/linux/compiler-gcc.h:118:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
118 | #define __diag(s) _Pragma(__diag_str(GCC diagnostic s))
| ^~~~~~~
include/linux/compiler-gcc.h:129:9: note: in expansion of macro '__diag'
129 | __diag(__diag_GCC_ignore option)
| ^~~~~~
include/linux/uaccess.h:742:31: note: in expansion of macro '__diag_ignore_all'
742 | __diag_push() __diag_ignore_all("-Wshadow", "uptr is readonly copy") \
| ^~~~~~~~~~~~~~~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
In file included from include/asm-generic/div64.h:27,
from ./arch/nios2/include/generated/asm/div64.h:1,
from include/linux/math.h:6,
from include/linux/math64.h:6,
from include/linux/time.h:6,
from include/linux/compat.h:10,
from kernel/futex/core.c:34:
>> include/linux/uaccess.h:743:90: error: '_tmpptr' undeclared (first use in this function)
743 | and_with (const auto uptr __cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
| ^~~~~~~
include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
>> include/linux/compiler.h:396:28: error: '_with_done' undeclared (first use in this function)
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~
include/linux/uaccess.h:743:17: note: in expansion of macro 'and_with'
743 | and_with (const auto uptr __cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
| ^~~~~~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
>> include/linux/uaccess.h:740:20: warning: unused variable '_tmpptr' [-Wunused-variable]
740 | with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
| ^~~~~~~
include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
| ^~~~
include/linux/uaccess.h:778:9: note: in expansion of macro '__scoped_user_access'
778 | __scoped_user_access(write, udst, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:790:9: note: in expansion of macro 'scoped_user_write_access_size'
790 | scoped_user_write_access_size(udst, sizeof(*(udst)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:856:9: note: in expansion of macro 'scoped_user_write_access'
856 | scoped_user_write_access(_tmpdst, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:604:37: note: in expansion of macro 'put_user_inline'
604 | if (node_updated && put_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
>> include/linux/compiler.h:396:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
396 | for (declaration; !_with_done; _with_done = true)
| ^~~
include/linux/compiler.h:394:17: note: in expansion of macro 'and_with'
394 | and_with (declaration)
| ^~~~~~~~
include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
| ^~~~
include/linux/uaccess.h:778:9: note: in expansion of macro '__scoped_user_access'
778 | __scoped_user_access(write, udst, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:790:9: note: in expansion of macro 'scoped_user_write_access_size'
790 | scoped_user_write_access_size(udst, sizeof(*(udst)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:856:9: note: in expansion of macro 'scoped_user_write_access'
856 | scoped_user_write_access(_tmpdst, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:604:37: note: in expansion of macro 'put_user_inline'
604 | if (node_updated && put_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
In file included from include/linux/compiler_types.h:173,
from <command-line>:
include/linux/compiler-gcc.h:118:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
118 | #define __diag(s) _Pragma(__diag_str(GCC diagnostic s))
| ^~~~~~~
include/linux/compiler-gcc.h:129:9: note: in expansion of macro '__diag'
129 | __diag(__diag_GCC_ignore option)
| ^~~~~~
include/linux/uaccess.h:742:31: note: in expansion of macro '__diag_ignore_all'
742 | __diag_push() __diag_ignore_all("-Wshadow", "uptr is readonly copy") \
| ^~~~~~~~~~~~~~~~~
include/linux/uaccess.h:778:9: note: in expansion of macro '__scoped_user_access'
778 | __scoped_user_access(write, udst, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:790:9: note: in expansion of macro 'scoped_user_write_access_size'
790 | scoped_user_write_access_size(udst, sizeof(*(udst)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:856:9: note: in expansion of macro 'scoped_user_write_access'
856 | scoped_user_write_access(_tmpdst, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:604:37: note: in expansion of macro 'put_user_inline'
604 | if (node_updated && put_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
..
vim +/_tmpptr +743 include/linux/uaccess.h
689
690 /**
691 * __scoped_user_access - Open a scope for user access
692 * @mode: The mode of the access class (read, write, rw)
693 * @uptr: The pointer to access user space memory
694 * @size: Size of the access
695 * @elbl: Error label to goto when the access region is rejected. It
696 * must be placed outside the scope
697 *
698 * If the user access function inside the scope requires a fault label, it
699 * can use @elbl or a different label outside the scope, which requires
700 * that user access which is implemented with ASM GOTO has been properly
701 * wrapped. See unsafe_get_user() for reference.
702 *
703 * scoped_user_rw_access(ptr, efault) {
704 * unsafe_get_user(rval, &ptr->rval, efault);
705 * unsafe_put_user(wval, &ptr->wval, efault);
706 * }
707 * return 0;
708 * efault:
709 * return -EFAULT;
710 *
711 * The scope is internally implemented as a autoterminating nested for()
712 * loop, which can be left with 'return', 'break' and 'goto' at any
713 * point.
714 *
715 * When the scope is left user_##@_mode##_access_end() is automatically
716 * invoked.
717 *
718 * When the architecture supports masked user access and the access region
719 * which is determined by @uptr and @size is not a valid user space
720 * address, i.e. < TASK_SIZE, the scope sets the pointer to a faulting user
721 * space address and does not terminate early. This optimizes for the good
722 * case and lets the performance uncritical bad case go through the fault.
723 *
724 * The eventual modification of the pointer is limited to the scope.
725 * Outside of the scope the original pointer value is unmodified, so that
726 * the original pointer value is available for diagnostic purposes in an
727 * out of scope fault path.
728 *
729 * Nesting scoped user access into a user access scope is invalid and fails
730 * the build. Nesting into other guards, e.g. pagefault is safe.
731 *
732 * The masked variant does not check the size of the access and relies on a
733 * mapping hole (e.g. guard page) to catch an out of range pointer, the
734 * first access to user memory inside the scope has to be within
735 * @uptr ... @uptr + PAGE_SIZE - 1
736 *
737 * Don't use directly. Use scoped_masked_user_$MODE_access() instead.
738 */
739 #define __scoped_user_access(mode, uptr, size, elbl) \
> 740 with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
741 /* Force modified pointer usage within the scope */ \
742 __diag_push() __diag_ignore_all("-Wshadow", "uptr is readonly copy") \
> 743 and_with (const auto uptr __cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
744 __diag_pop()
745
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH v2 4/5] uaccess: Disable -Wshadow in __scoped_user_access()
@ 2026-03-05 8:10 ` kernel test robot
0 siblings, 0 replies; 28+ messages in thread
From: kernel test robot @ 2026-03-05 8:10 UTC (permalink / raw)
To: david.laight.linux, Alexander Viro, Andre Almeida, Andrew Cooper,
Christian Borntraeger, Christian Brauner, Christophe Leroy,
Christophe Leroy (CS GROUP), Darren Hart, Davidlohr Bueso,
Heiko Carstens, Jan Kara, Julia Lawall, Linus Torvalds,
linux-arm-kernel, linux-fsdevel, linuxppc-dev, linux-riscv,
linux-s390, Madhavan Srinivasan, Mathieu Desnoyers,
Michael Ellerman, Nicholas Piggin, Nicolas Palix, Palmer Dabbelt,
Paul Walmsley, Peter Zijlstra, Russell King, Sven Schnelle
Cc: oe-kbuild-all, LKML
Hi,
kernel test robot noticed the following build errors:
[auto build test ERROR on brauner-vfs/vfs.all]
[also build test ERROR on v7.0-rc2]
[cannot apply to linus/master next-20260303]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/david-laight-linux-gmail-com/uaccess-Fix-scoped_user_read_access-for-pointer-to-const/20260302-213317
base: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git vfs.all
patch link: https://lore.kernel.org/r/20260302132755.1475451-5-david.laight.linux%40gmail.com
patch subject: [PATCH v2 4/5] uaccess: Disable -Wshadow in __scoped_user_access()
config: nios2-allnoconfig (https://download.01.org/0day-ci/archive/20260305/202603051642.i46zzlJ8-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 11.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260305/202603051642.i46zzlJ8-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603051642.i46zzlJ8-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
In file included from include/asm-generic/div64.h:27,
from ./arch/nios2/include/generated/asm/div64.h:1,
from include/linux/math.h:6,
from include/linux/math64.h:6,
from include/linux/time.h:6,
from include/linux/compat.h:10,
from kernel/futex/core.c:34:
kernel/futex/futex.h: In function 'futex_get_value_locked':
>> include/linux/uaccess.h:740:20: warning: unused variable '_tmpptr' [-Wunused-variable]
740 | with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
| ^~~~~~~
include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
| ^~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
>> include/linux/compiler.h:396:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
396 | for (declaration; !_with_done; _with_done = true)
| ^~~
include/linux/compiler.h:394:17: note: in expansion of macro 'and_with'
394 | and_with (declaration)
| ^~~~~~~~
include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
| ^~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
In file included from include/linux/compiler_types.h:173,
from <command-line>:
include/linux/compiler-gcc.h:118:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
118 | #define __diag(s) _Pragma(__diag_str(GCC diagnostic s))
| ^~~~~~~
include/linux/compiler-gcc.h:129:9: note: in expansion of macro '__diag'
129 | __diag(__diag_GCC_ignore option)
| ^~~~~~
include/linux/uaccess.h:742:31: note: in expansion of macro '__diag_ignore_all'
742 | __diag_push() __diag_ignore_all("-Wshadow", "uptr is readonly copy") \
| ^~~~~~~~~~~~~~~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
In file included from include/asm-generic/div64.h:27,
from ./arch/nios2/include/generated/asm/div64.h:1,
from include/linux/math.h:6,
from include/linux/math64.h:6,
from include/linux/time.h:6,
from include/linux/compat.h:10,
from kernel/futex/core.c:34:
>> include/linux/uaccess.h:743:90: error: '_tmpptr' undeclared (first use in this function)
743 | and_with (const auto uptr __cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
| ^~~~~~~
include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
include/linux/uaccess.h:743:90: note: each undeclared identifier is reported only once for each function it appears in
743 | and_with (const auto uptr __cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
| ^~~~~~~
include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
>> include/linux/compiler.h:396:28: error: '_with_done' undeclared (first use in this function)
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~
include/linux/uaccess.h:743:17: note: in expansion of macro 'and_with'
743 | and_with (const auto uptr __cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
| ^~~~~~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/futex.h:288:16: note: in expansion of macro 'get_user_inline'
288 | return get_user_inline(*dest, from);
| ^~~~~~~~~~~~~~~
kernel/futex/core.c: In function 'get_futex_key':
>> include/linux/uaccess.h:740:20: warning: unused variable '_tmpptr' [-Wunused-variable]
740 | with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
| ^~~~~~~
include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
| ^~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
>> include/linux/compiler.h:396:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
396 | for (declaration; !_with_done; _with_done = true)
| ^~~
include/linux/compiler.h:394:17: note: in expansion of macro 'and_with'
394 | and_with (declaration)
| ^~~~~~~~
include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
| ^~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
In file included from include/linux/compiler_types.h:173,
from <command-line>:
include/linux/compiler-gcc.h:118:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
118 | #define __diag(s) _Pragma(__diag_str(GCC diagnostic s))
| ^~~~~~~
include/linux/compiler-gcc.h:129:9: note: in expansion of macro '__diag'
129 | __diag(__diag_GCC_ignore option)
| ^~~~~~
include/linux/uaccess.h:742:31: note: in expansion of macro '__diag_ignore_all'
742 | __diag_push() __diag_ignore_all("-Wshadow", "uptr is readonly copy") \
| ^~~~~~~~~~~~~~~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
In file included from include/asm-generic/div64.h:27,
from ./arch/nios2/include/generated/asm/div64.h:1,
from include/linux/math.h:6,
from include/linux/math64.h:6,
from include/linux/time.h:6,
from include/linux/compat.h:10,
from kernel/futex/core.c:34:
>> include/linux/uaccess.h:743:90: error: '_tmpptr' undeclared (first use in this function)
743 | and_with (const auto uptr __cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
| ^~~~~~~
include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
>> include/linux/compiler.h:396:28: error: '_with_done' undeclared (first use in this function)
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~
include/linux/uaccess.h:743:17: note: in expansion of macro 'and_with'
743 | and_with (const auto uptr __cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
| ^~~~~~~~
include/linux/uaccess.h:755:9: note: in expansion of macro '__scoped_user_access'
755 | __scoped_user_access(read, usrc, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:767:9: note: in expansion of macro 'scoped_user_read_access_size'
767 | scoped_user_read_access_size(usrc, sizeof(*(usrc)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:831:9: note: in expansion of macro 'scoped_user_read_access'
831 | scoped_user_read_access(_tmpsrc, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:584:21: note: in expansion of macro 'get_user_inline'
584 | if (get_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
>> include/linux/uaccess.h:740:20: warning: unused variable '_tmpptr' [-Wunused-variable]
740 | with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
| ^~~~~~~
include/linux/compiler.h:396:14: note: in definition of macro 'and_with'
396 | for (declaration; !_with_done; _with_done = true)
| ^~~~~~~~~~~
include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
| ^~~~
include/linux/uaccess.h:778:9: note: in expansion of macro '__scoped_user_access'
778 | __scoped_user_access(write, udst, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:790:9: note: in expansion of macro 'scoped_user_write_access_size'
790 | scoped_user_write_access_size(udst, sizeof(*(udst)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:856:9: note: in expansion of macro 'scoped_user_write_access'
856 | scoped_user_write_access(_tmpdst, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:604:37: note: in expansion of macro 'put_user_inline'
604 | if (node_updated && put_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
>> include/linux/compiler.h:396:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
396 | for (declaration; !_with_done; _with_done = true)
| ^~~
include/linux/compiler.h:394:17: note: in expansion of macro 'and_with'
394 | and_with (declaration)
| ^~~~~~~~
include/linux/uaccess.h:740:9: note: in expansion of macro 'with'
740 | with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
| ^~~~
include/linux/uaccess.h:778:9: note: in expansion of macro '__scoped_user_access'
778 | __scoped_user_access(write, udst, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:790:9: note: in expansion of macro 'scoped_user_write_access_size'
790 | scoped_user_write_access_size(udst, sizeof(*(udst)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:856:9: note: in expansion of macro 'scoped_user_write_access'
856 | scoped_user_write_access(_tmpdst, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:604:37: note: in expansion of macro 'put_user_inline'
604 | if (node_updated && put_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
In file included from include/linux/compiler_types.h:173,
from <command-line>:
include/linux/compiler-gcc.h:118:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
118 | #define __diag(s) _Pragma(__diag_str(GCC diagnostic s))
| ^~~~~~~
include/linux/compiler-gcc.h:129:9: note: in expansion of macro '__diag'
129 | __diag(__diag_GCC_ignore option)
| ^~~~~~
include/linux/uaccess.h:742:31: note: in expansion of macro '__diag_ignore_all'
742 | __diag_push() __diag_ignore_all("-Wshadow", "uptr is readonly copy") \
| ^~~~~~~~~~~~~~~~~
include/linux/uaccess.h:778:9: note: in expansion of macro '__scoped_user_access'
778 | __scoped_user_access(write, udst, size, elbl)
| ^~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:790:9: note: in expansion of macro 'scoped_user_write_access_size'
790 | scoped_user_write_access_size(udst, sizeof(*(udst)), elbl)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/uaccess.h:856:9: note: in expansion of macro 'scoped_user_write_access'
856 | scoped_user_write_access(_tmpdst, efault) \
| ^~~~~~~~~~~~~~~~~~~~~~~~
kernel/futex/core.c:604:37: note: in expansion of macro 'put_user_inline'
604 | if (node_updated && put_user_inline(node, naddr))
| ^~~~~~~~~~~~~~~
..
vim +/_tmpptr +743 include/linux/uaccess.h
689
690 /**
691 * __scoped_user_access - Open a scope for user access
692 * @mode: The mode of the access class (read, write, rw)
693 * @uptr: The pointer to access user space memory
694 * @size: Size of the access
695 * @elbl: Error label to goto when the access region is rejected. It
696 * must be placed outside the scope
697 *
698 * If the user access function inside the scope requires a fault label, it
699 * can use @elbl or a different label outside the scope, which requires
700 * that user access which is implemented with ASM GOTO has been properly
701 * wrapped. See unsafe_get_user() for reference.
702 *
703 * scoped_user_rw_access(ptr, efault) {
704 * unsafe_get_user(rval, &ptr->rval, efault);
705 * unsafe_put_user(wval, &ptr->wval, efault);
706 * }
707 * return 0;
708 * efault:
709 * return -EFAULT;
710 *
711 * The scope is internally implemented as a autoterminating nested for()
712 * loop, which can be left with 'return', 'break' and 'goto' at any
713 * point.
714 *
715 * When the scope is left user_##@_mode##_access_end() is automatically
716 * invoked.
717 *
718 * When the architecture supports masked user access and the access region
719 * which is determined by @uptr and @size is not a valid user space
720 * address, i.e. < TASK_SIZE, the scope sets the pointer to a faulting user
721 * space address and does not terminate early. This optimizes for the good
722 * case and lets the performance uncritical bad case go through the fault.
723 *
724 * The eventual modification of the pointer is limited to the scope.
725 * Outside of the scope the original pointer value is unmodified, so that
726 * the original pointer value is available for diagnostic purposes in an
727 * out of scope fault path.
728 *
729 * Nesting scoped user access into a user access scope is invalid and fails
730 * the build. Nesting into other guards, e.g. pagefault is safe.
731 *
732 * The masked variant does not check the size of the access and relies on a
733 * mapping hole (e.g. guard page) to catch an out of range pointer, the
734 * first access to user memory inside the scope has to be within
735 * @uptr ... @uptr + PAGE_SIZE - 1
736 *
737 * Don't use directly. Use scoped_masked_user_$MODE_access() instead.
738 */
739 #define __scoped_user_access(mode, uptr, size, elbl) \
> 740 with (auto _tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)) \
741 /* Force modified pointer usage within the scope */ \
742 __diag_push() __diag_ignore_all("-Wshadow", "uptr is readonly copy") \
> 743 and_with (const auto uptr __cleanup(__scoped_user_##mode##_access_end) = _tmpptr) \
744 __diag_pop()
745
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 28+ messages in thread