]> www.infradead.org Git - nvme.git/commitdiff
lib/prime_numbers: KUnit test should not select PRIME_NUMBERS
authorGeert Uytterhoeven <geert@linux-m68k.org>
Mon, 14 Apr 2025 14:35:00 +0000 (16:35 +0200)
committerKees Cook <kees@kernel.org>
Tue, 15 Apr 2025 20:50:43 +0000 (13:50 -0700)
Enabling a (modular) test should not silently enable additional kernel
functionality, as that may increase the attack vector of a product.

Fix this by making PRIME_NUMBERS_KUNIT_TEST depend on PRIME_NUMBERS
instead of selecting it.

After this, one can safely enable CONFIG_KUNIT_ALL_TESTS=m to build
modules for all appropriate tests for ones system, without pulling in
extra unwanted functionality, while still allowing a tester to manually
enable PRIME_NUMBERS and this test suite on a system where PRIME_NUMBERS
is not enabled by default.  Resurrect CONFIG_PRIME_NUMBERS=m in
tools/testing/selftests/lib/config for the latter use case.

Fixes: 313b38a6ecb46db4 ("lib/prime_numbers: convert self-test to KUnit")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Tamir Duberstein <tamird@gmail.com>
Link: https://lore.kernel.org/r/40f8a40eef4930d3ac9febd205bc171eb04e171c.1744641237.git.geert@linux-m68k.org
Signed-off-by: Kees Cook <kees@kernel.org>
lib/Kconfig.debug
tools/testing/selftests/lib/config

index 9fe4d8dfe5782981cc0b2b6614106aac570bd229..f9051ab610d54358b21d61c141b737bb345b4cee 100644 (file)
@@ -3290,7 +3290,7 @@ config GCD_KUNIT_TEST
 config PRIME_NUMBERS_KUNIT_TEST
        tristate "Prime number generator test" if !KUNIT_ALL_TESTS
        depends on KUNIT
-       select PRIME_NUMBERS
+       depends on PRIME_NUMBERS
        default KUNIT_ALL_TESTS
        help
          This option enables the KUnit test suite for the {is,next}_prime_number
index 81a1f64a22e860a69ec8e27b9efa2a3767b77940..377b3699ff312933742455f4201cba1eb3327e5f 100644 (file)
@@ -1,2 +1,3 @@
 CONFIG_TEST_BITMAP=m
+CONFIG_PRIME_NUMBERS=m
 CONFIG_TEST_BITOPS=m