Re: [PATCH 1/4] microblaze: uaccess: Zero out destination on failed get_user()

David Gow <[email protected]> Wed, 5 Aug 2026 21:59:00 +0800
Newsgroups org.kernel.vger.linux-kselftest,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Le 04/08/2026 à 13:32, Thomas Weißschuh a écrit :
> On failure get_user() is supposed to zero out the destination variable.
> This is documented in the kdoc of the microblaze get_user()
> implementation and validated in lib/tests/usercopy_kunit.c.
> 
> Currently that zeroing is missing.
> 
> Add it.
> 
> Fixes: 0d6de9532663 ("microblaze_mmu_v2: uaccess MMU update")
> Signed-off-by: Thomas Weißschuh <[email protected]>
> ---

This test seems to be the gift which keeps on giving. Every architecture 
seems to have had a buggy get_user() at some point.

Reviewed-by: David Gow <[email protected]>

Cheers,
-- David

>   arch/microblaze/include/asm/uaccess.h | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
> index afa0dd8d013f..77203af255e5 100644
> --- a/arch/microblaze/include/asm/uaccess.h
> +++ b/arch/microblaze/include/asm/uaccess.h
> @@ -95,7 +95,8 @@ extern long __user_bad(void);
>   #define get_user(x, ptr) ({				\
>   	const typeof(*(ptr)) __user *__gu_ptr = (ptr);	\
>   	access_ok(__gu_ptr, sizeof(*__gu_ptr)) ?	\
> -		__get_user(x, __gu_ptr) : -EFAULT;	\
> +		__get_user(x, __gu_ptr) :		\
> +		((x) = 0, -EFAULT);			\
>   })
>   
>   #define __get_user(x, ptr)						\
>