microblaze: uaccess: Zero out destination on failed get_user()
authorThomas Weißschuh <linux@weissschuh.net>
Sun, 13 Sep 2026 23:50:08 +0000 (01:50 +0200)
committerMichal Simek <michal.simek@amd.com>
Mon, 14 Sep 2026 09:40:24 +0000 (11:40 +0200)
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 <linux@weissschuh.net>
Reviewed-by: David Gow <david@davidgow.net>
Link: https://patch.msgid.link/20260914-kunit-microblaze-v2-1-7d5756e858f8@weissschuh.net
Signed-off-by: Michal Simek <michal.simek@amd.com>
arch/microblaze/include/asm/uaccess.h

index afa0dd8..77203af 100644 (file)
@@ -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)                                             \