Skip to contentSkip to conversation

kcsan: remove rng selftest

PATCH In review Jason A. Donenfeld 2 participants 4 messages Oct 17, 2022 KCSAN

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kcsan: remove rng selftest

The first test of the kcsan selftest appears to test if get_random_u32() returns two zeros in a row, and requires that it doesn't. This seems like a bogus critera. Remove it.

---
 kernel/kcsan/selftest.c | 8 --------
 1 file changed, 8 deletions(-)
kernel/kcsan/selftest.c +0 -8
index 00cdf8fa5693..1740ce389e7f 100644
@@ -22,13 +22,6 @@
 
 #define ITERS_PER_TEST 2000
 
-/* Test requirements. */
-static bool __init test_requires(void)
-{
-	/* random should be initialized for the below tests */
-	return get_random_u32() + get_random_u32() != 0;
-}
-
 /*
  * Test watchpoint encode and decode: check that encoding some access's info,
  * and then subsequent decode preserves the access's info.
@@ -259,7 +252,6 @@ static int __init kcsan_selftest(void)
 			pr_err("selftest: " #do_test " failed");               \
 	} while (0)
 
-	RUN_TEST(test_requires);
 	RUN_TEST(test_encode_decode);
 	RUN_TEST(test_matching_access);
 	RUN_TEST(test_barrier);
Signature · 1 line
2.37.3
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Jason A. Donenfeld

The first test of the kcsan selftest appears to test if get_random_u32() returns two zeros in a row, and requires that it doesn't. This seems like a bogus critera. Remove it.

Looks pretty redundant at this point (I think some early version had it because somehow I managed to run the test too early and wanted to avoid that accidentally happening again).

Quoted 33 lines
---
 kernel/kcsan/selftest.c | 8 --------
 1 file changed, 8 deletions(-)
kernel/kcsan/selftest.c +0 -9
index 00cdf8fa5693..1740ce389e7f 100644
@@ -22,13 +22,6 @@
 
 #define ITERS_PER_TEST 2000
 
-/* Test requirements. */
-static bool __init test_requires(void)
-{
-       /* random should be initialized for the below tests */
-       return get_random_u32() + get_random_u32() != 0;
-}
-
 /*
  * Test watchpoint encode and decode: check that encoding some access's info,
  * and then subsequent decode preserves the access's info.
@@ -259,7 +252,6 @@ static int __init kcsan_selftest(void)
                        pr_err("selftest: " #do_test " failed");               \
        } while (0)
 
-       RUN_TEST(test_requires);
        RUN_TEST(test_encode_decode);
        RUN_TEST(test_matching_access);
        RUN_TEST(test_barrier);
--

2.37.3

maintainer
#2 lore raw
Quoted 7 lines · Marco Elver
Quoted 5 lines · Jason A. Donenfeld

The first test of the kcsan selftest appears to test if get_random_u32() returns two zeros in a row, and requires that it doesn't. This seems like a bogus critera. Remove it.

Quoted 8 lines
Quoted 1 line

Looks pretty redundant at this point (I think some early version had it because somehow I managed to run the test too early and wanted to avoid that accidentally happening again).

And kindly queue it in your tree with all the rng related changes. Thanks!

Quoted 33 lines
Quoted 33 lines
---
 kernel/kcsan/selftest.c | 8 --------
 1 file changed, 8 deletions(-)
kernel/kcsan/selftest.c +0 -9
index 00cdf8fa5693..1740ce389e7f 100644
@@ -22,13 +22,6 @@
 
 #define ITERS_PER_TEST 2000
 
-/* Test requirements. */
-static bool __init test_requires(void)
-{
-       /* random should be initialized for the below tests */
-       return get_random_u32() + get_random_u32() != 0;
-}
-
 /*
  * Test watchpoint encode and decode: check that encoding some access's info,
  * and then subsequent decode preserves the access's info.
@@ -259,7 +252,6 @@ static int __init kcsan_selftest(void)
                        pr_err("selftest: " #do_test " failed");               \
        } while (0)
 
-       RUN_TEST(test_requires);
        RUN_TEST(test_encode_decode);
        RUN_TEST(test_matching_access);
        RUN_TEST(test_barrier);
--

2.37.3

#3 lore raw
Quoted 11 lines · Marco Elver
Quoted 9 lines · Marco Elver
Quoted 6 lines · Jason A. Donenfeld

The first test of the kcsan selftest appears to test if get_random_u32() returns two zeros in a row, and requires that it doesn't. This seems like a bogus critera. Remove it.

Quoted 8 lines
Quoted 6 lines

Looks pretty redundant at this point (I think some early version had it because somehow I managed to run the test too early and wanted to avoid that accidentally happening again).

And kindly queue it in your tree with all the rng related changes. Thanks!

Okay sure, will do.

Jason