public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] uaccess: Fix build of scoped user access with const pointer
@ 2026-03-01 19:33 Christophe Leroy (CS GROUP)
  2026-03-01 20:01 ` Linus Torvalds
  2026-03-01 21:52 ` David Laight
  0 siblings, 2 replies; 5+ messages in thread
From: Christophe Leroy (CS GROUP) @ 2026-03-01 19:33 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: Christophe Leroy (CS GROUP), Christophe Leroy, Mathieu Desnoyers,
	Andrew Cooper, Linus Torvalds, David Laight, kernel test robot,
	Russell King, linux-arm-kernel, x86, Madhavan Srinivasan,
	Michael Ellerman, Nicholas Piggin, linuxppc-dev, Paul Walmsley,
	Palmer Dabbelt, linux-riscv, Heiko Carstens,
	Christian Borntraeger, Sven Schnelle, linux-s390, Julia Lawall,
	Nicolas Palix, Peter Zijlstra, Darren Hart, Davidlohr Bueso,
	Andre Almeida, Alexander Viro, Christian Brauner, Jan Kara,
	linux-fsdevel

After converting powerpc checksum wrappers to scoped user access,
following build failure happens:

	  CC      arch/powerpc/lib/checksum_wrappers.o
	In file included from arch/powerpc/lib/checksum_wrappers.c:12:
	arch/powerpc/lib/checksum_wrappers.c: In function 'csum_and_copy_from_user':
	./include/linux/uaccess.h:691:1: error: initialization discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
	  691 | ({                                                                      \
	      | ^
	./include/linux/uaccess.h:755:37: note: in expansion of macro '__scoped_user_access_begin'
	  755 |         for (void __user *_tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl); \
	      |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~
	./include/linux/uaccess.h:770:9: note: in expansion of macro '__scoped_user_access'
	  770 |         __scoped_user_access(read, usrc, size, elbl)
	      |         ^~~~~~~~~~~~~~~~~~~~
	arch/powerpc/lib/checksum_wrappers.c:17:9: note: in expansion of macro 'scoped_user_read_access_size'
	   17 |         scoped_user_read_access_size(src, len, efault)
	      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Cast __scoped_user_access_begin() to (void __user *) to fix it.

Fixes: e497310b4ffb ("uaccess: Provide scoped user access regions")
Signed-off-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
---
Thomas, I encountered this problem while preparing some patches to start using
scope user access widely on powerpc in order to benefit more from masked user
access. Can you make this patch go into 7.0 as a fix in order avoid dependency
on this change when we start using scoped user access ?

 include/linux/uaccess.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
index 1f3804245c06..5d9f6d45d301 100644
--- a/include/linux/uaccess.h
+++ b/include/linux/uaccess.h
@@ -752,7 +752,8 @@ USER_ACCESS_GUARD(rw)
  */
 #define __scoped_user_access(mode, uptr, size, elbl)					\
 for (bool done = false; !done; done = true)						\
-	for (void __user *_tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl); \
+	for (void __user *_tmpptr = (void __user *)					\
+				    __scoped_user_access_begin(mode, uptr, size, elbl); \
 	     !done; done = true)							\
 		for (CLASS(user_##mode##_access, scope)(_tmpptr); !done; done = true)	\
 			/* Force modified pointer usage within the scope */		\
-- 
2.49.0


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

end of thread, other threads:[~2026-03-01 22:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-01 19:33 [PATCH] uaccess: Fix build of scoped user access with const pointer Christophe Leroy (CS GROUP)
2026-03-01 20:01 ` Linus Torvalds
2026-03-01 21:59   ` David Laight
2026-03-01 22:16   ` David Laight
2026-03-01 21:52 ` David Laight

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