Skip to content

Commit 3f29251

Browse files
geertukees
authored andcommitted
lib/prime_numbers: KUnit test should not select PRIME_NUMBERS
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: 313b38a ("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>
1 parent 9b04461 commit 3f29251

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/Kconfig.debug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3290,7 +3290,7 @@ config GCD_KUNIT_TEST
32903290
config PRIME_NUMBERS_KUNIT_TEST
32913291
tristate "Prime number generator test" if !KUNIT_ALL_TESTS
32923292
depends on KUNIT
3293-
select PRIME_NUMBERS
3293+
depends on PRIME_NUMBERS
32943294
default KUNIT_ALL_TESTS
32953295
help
32963296
This option enables the KUnit test suite for the {is,next}_prime_number

tools/testing/selftests/lib/config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
CONFIG_TEST_BITMAP=m
2+
CONFIG_PRIME_NUMBERS=m
23
CONFIG_TEST_BITOPS=m

0 commit comments

Comments
 (0)