Skip to content

Commit 6976744

Browse files
Alexandre Ghitigregkh
authored andcommitted
riscv: Fix sparse warning about different address spaces
commit a03ee11 upstream. We did not propagate the __user attribute of the pointers in __get_kernel_nofault() and __put_kernel_nofault(), which results in sparse complaining: >> mm/maccess.c:41:17: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const [noderef] __user *from @@ got unsigned long long [usertype] * @@ mm/maccess.c:41:17: sparse: expected void const [noderef] __user *from mm/maccess.c:41:17: sparse: got unsigned long long [usertype] * So fix this by correctly casting those pointers. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202508161713.RWu30Lv1-lkp@intel.com/ Suggested-by: Al Viro <viro@zeniv.linux.org.uk> Fixes: f6bff78 ("riscv: uaccess: use 'asm_goto_output' for get_user()") Cc: stable@vger.kernel.org Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com> Reviewed-by: Cyril Bur <cyrilbur@tenstorrent.com> Link: https://lore.kernel.org/r/20250903-dev-alex-sparse_warnings_v1-v1-2-7e6350beb700@rivosinc.com Signed-off-by: Paul Walmsley <pjw@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8b94eb3 commit 6976744

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/riscv/include/asm/uaccess.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,10 @@ unsigned long __must_check clear_user(void __user *to, unsigned long n)
438438
}
439439

440440
#define __get_kernel_nofault(dst, src, type, err_label) \
441-
__get_user_nocheck(*((type *)(dst)), (type *)(src), err_label)
441+
__get_user_nocheck(*((type *)(dst)), (__force __user type *)(src), err_label)
442442

443443
#define __put_kernel_nofault(dst, src, type, err_label) \
444-
__put_user_nocheck(*((type *)(src)), (type *)(dst), err_label)
444+
__put_user_nocheck(*((type *)(src)), (__force __user type *)(dst), err_label)
445445

446446
static __must_check __always_inline bool user_access_begin(const void __user *ptr, size_t len)
447447
{

0 commit comments

Comments
 (0)