[PATCH] lib: PRIME_NUMBERS_KUNIT_TEST should not select PRIME_NUMBERS

Geert Uytterhoeven posted 1 patch 8 months, 1 week ago
There is a newer version of this series
lib/Kconfig.debug | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] lib: PRIME_NUMBERS_KUNIT_TEST should not select PRIME_NUMBERS
Posted by Geert Uytterhoeven 8 months, 1 week ago
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.

Fixes: 313b38a6ecb46db4 ("lib/prime_numbers: convert self-test to KUnit")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
 lib/Kconfig.debug | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 4060a89866626c0a..51722f5d041970aa 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -3326,7 +3326,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
-- 
2.43.0
Re: [PATCH] lib: PRIME_NUMBERS_KUNIT_TEST should not select PRIME_NUMBERS
Posted by Geert Uytterhoeven 8 months, 1 week ago
On Mon, 14 Apr 2025 at 10:50, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> 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.
>
> Fixes: 313b38a6ecb46db4 ("lib/prime_numbers: convert self-test to KUnit")
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
>  lib/Kconfig.debug | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index 4060a89866626c0a..51722f5d041970aa 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -3326,7 +3326,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

Oops, I forgot to resurrect CONFIG_PRIME_NUMBERS=m in
tools/testing/selftests/lib/config.  Will fix in v2.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Re: [PATCH] lib: PRIME_NUMBERS_KUNIT_TEST should not select PRIME_NUMBERS
Posted by Tamir Duberstein 8 months, 1 week ago
On Mon, Apr 14, 2025 at 5:02 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> On Mon, 14 Apr 2025 at 10:50, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > 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.
> >
> > 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>