[PATCH] kunit/usercopy: Disable u64 test on 32-bit SPARC

Thomas Weißschuh posted 1 patch 8 months ago
lib/tests/usercopy_kunit.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] kunit/usercopy: Disable u64 test on 32-bit SPARC
Posted by Thomas Weißschuh 8 months ago
usercopy of 64 bit values does not work on 32-bit SPARC:

    # usercopy_test_valid: EXPECTATION FAILED at lib/tests/usercopy_kunit.c:209
    Expected val_u64 == 0x5a5b5c5d6a6b6c6d, but
        val_u64 == 1515936861 (0x5a5b5c5d)
        0x5a5b5c5d6a6b6c6d == 6510899242581322861 (0x5a5b5c5d6a6b6c6d)

Disable the test.

Fixes: 4c5d7bc63775 ("usercopy: Add tests for all get_user() sizes")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
To be honest I think sparc32 wants to support usercopy of 64 bit values.
But it does seem to be broken.

(+Cc SPARC maintainers)
---
 lib/tests/usercopy_kunit.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/tests/usercopy_kunit.c b/lib/tests/usercopy_kunit.c
index 77fa00a13df775074a19772bfbc9120ef33634bb..80f8abe10968c1d91c61006f1eaa63858c633872 100644
--- a/lib/tests/usercopy_kunit.c
+++ b/lib/tests/usercopy_kunit.c
@@ -27,6 +27,7 @@
 			    !defined(CONFIG_MICROBLAZE) &&	\
 			    !defined(CONFIG_NIOS2) &&		\
 			    !defined(CONFIG_PPC32) &&		\
+			    !defined(CONFIG_SPARC32) &&		\
 			    !defined(CONFIG_SUPERH))
 # define TEST_U64
 #endif

---
base-commit: 1a1d569a75f3ab2923cb62daf356d102e4df2b86
change-id: 20250416-kunit-sparc-usercopy-c36de3ca4ef8

Best regards,
-- 
Thomas Weißschuh <thomas.weissschuh@linutronix.de>

Re: [PATCH] kunit/usercopy: Disable u64 test on 32-bit SPARC
Posted by Kees Cook 8 months ago
On Wed, 16 Apr 2025 14:44:19 +0200, Thomas Weißschuh wrote:
> usercopy of 64 bit values does not work on 32-bit SPARC:
> 
>     # usercopy_test_valid: EXPECTATION FAILED at lib/tests/usercopy_kunit.c:209
>     Expected val_u64 == 0x5a5b5c5d6a6b6c6d, but
>         val_u64 == 1515936861 (0x5a5b5c5d)
>         0x5a5b5c5d6a6b6c6d == 6510899242581322861 (0x5a5b5c5d6a6b6c6d)
> 
> [...]

Applied to for-next/hardening, thanks!

[1/1] kunit/usercopy: Disable u64 test on 32-bit SPARC
      https://git.kernel.org/kees/c/b2044b94a6a9

Take care,

-- 
Kees Cook

Re: [PATCH] kunit/usercopy: Disable u64 test on 32-bit SPARC
Posted by Kees Cook 8 months ago
On Wed, Apr 16, 2025 at 02:44:19PM +0200, Thomas Weißschuh wrote:
> usercopy of 64 bit values does not work on 32-bit SPARC:
> 
>     # usercopy_test_valid: EXPECTATION FAILED at lib/tests/usercopy_kunit.c:209
>     Expected val_u64 == 0x5a5b5c5d6a6b6c6d, but
>         val_u64 == 1515936861 (0x5a5b5c5d)
>         0x5a5b5c5d6a6b6c6d == 6510899242581322861 (0x5a5b5c5d6a6b6c6d)
> 
> Disable the test.
> 
> Fixes: 4c5d7bc63775 ("usercopy: Add tests for all get_user() sizes")
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> ---
> To be honest I think sparc32 wants to support usercopy of 64 bit values.
> But it does seem to be broken.
> 
> (+Cc SPARC maintainers)

I wonder if these archs need to explicitly fail to build if they trigger
a 64-bit wide put_user/get_user call? It seems weird to me that it
should be possible at all to provide access to the function if we know
it's going to 100% fail.

-Kees

> ---
>  lib/tests/usercopy_kunit.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/tests/usercopy_kunit.c b/lib/tests/usercopy_kunit.c
> index 77fa00a13df775074a19772bfbc9120ef33634bb..80f8abe10968c1d91c61006f1eaa63858c633872 100644
> --- a/lib/tests/usercopy_kunit.c
> +++ b/lib/tests/usercopy_kunit.c
> @@ -27,6 +27,7 @@
>  			    !defined(CONFIG_MICROBLAZE) &&	\
>  			    !defined(CONFIG_NIOS2) &&		\
>  			    !defined(CONFIG_PPC32) &&		\
> +			    !defined(CONFIG_SPARC32) &&		\
>  			    !defined(CONFIG_SUPERH))
>  # define TEST_U64
>  #endif
> 
> ---
> base-commit: 1a1d569a75f3ab2923cb62daf356d102e4df2b86
> change-id: 20250416-kunit-sparc-usercopy-c36de3ca4ef8
> 
> Best regards,
> -- 
> Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> 

-- 
Kees Cook