public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] uaccess: Updates to scoped_user_access()
@ 2026-03-02 13:27 david.laight.linux
  2026-03-02 13:27 ` [PATCH v2 1/5] uaccess: Fix scoped_user_read_access() for 'pointer to const' david.laight.linux
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ 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>

Converting kernel/signal.c to use scoped_user_access() had compilation
warnings because some of the pointers are 'pointer to const'.
This is fixed in patch 1.

The same problem has been found compiling arch/powerpc/lib/checksum_wrappers.c

For v2 I've changed the code to use 'auto' and replaced the over-complex
CLASS definition (and its for loop) with a much simpler __cleanup() function
on the second loop.

Patches 2 and 3 factor out the 'autoterminating nested for loops'.
I'm sure there'll be a 'bikeshed' discussion about the names.

Patch 4 stops warnings from -Wshadow (enabled by W=2).
I did think about making the _diag_xxx conditional on a W=2 build,
but since the pre-processor just emits #pragma lines and they are
smaller that the for() loop it doesn't seem worth while.

Patch 5 is the change to signal.c that prompted patch 1.
The generated code looks fine, but I've not tested it.
Most of the changes are to 'compat' code - so are probably not
usually performance critical.
IIRC the non-compat code uses copy_to/from_user() for the structures
so is probably slower than the compat code's member by member copy.

David Laight (5):
  uaccess: Fix scoped_user_read_access() for 'pointer to const'
  compiler.h: Add generic support for 'autoterminating nested for()
    loops'
  uaccess.h: Use with() and and_with() in __scoped_user_access()
  uaccess: Disable -Wshadow in __scoped_user_access()
  signal: Use scoped_user_access() instead of __put/get_user()

 include/linux/compiler.h | 26 +++++++++++++++
 include/linux/uaccess.h  | 51 ++++++++++------------------
 kernel/signal.c          | 72 +++++++++++++++++++++++-----------------
 3 files changed, 86 insertions(+), 63 deletions(-)

-- 
2.39.5


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2026-03-05  8:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-02 13:27 [PATCH v2 0/5] uaccess: Updates to scoped_user_access() david.laight.linux
2026-03-02 13:27 ` [PATCH v2 1/5] uaccess: Fix scoped_user_read_access() for 'pointer to const' david.laight.linux
2026-03-02 14:59   ` Christophe Leroy (CS GROUP)
2026-03-02 17:26     ` Linus Torvalds
2026-03-02 18:55       ` David Laight
2026-03-02 13:27 ` [PATCH v2 2/5] compiler.h: Add generic support for 'autoterminating nested for() loops' david.laight.linux
2026-03-02 13:27 ` [PATCH v2 3/5] uaccess.h: Use with() and and_with() in __scoped_user_access() david.laight.linux
2026-03-02 13:27 ` [PATCH v2 4/5] uaccess: Disable -Wshadow " david.laight.linux
2026-03-02 15:00   ` Christophe Leroy (CS GROUP)
2026-03-03  9:12     ` David Laight
2026-03-02 17:17   ` Linus Torvalds
2026-03-05  8:10   ` kernel test robot
2026-03-02 13:27 ` [PATCH v2 next 5/5] signal: Use scoped_user_access() instead of __put/get_user() david.laight.linux
2026-03-02 16:07   ` Christophe Leroy (CS GROUP)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox