[LTP] [PATCH 2/2] device-drivers: *module: Use helpers for module signature enforcement

Petr Vorel pvorel@suse.cz
Tue Dec 31 12:50:40 CET 2024


Hi Po-Hsu Lin,

> > +++ b/testcases/kernel/device-drivers/acpi/ltp_acpi.c
> > @@ -22,7 +22,6 @@
> >  #include <stdlib.h>

> >  #include "test.h"
> > -#include "tst_kconfig.h"
> >  #include "old_module.h"
> >  #include "safe_macros.h"

> > @@ -129,20 +128,12 @@ static void test_run(void)
> >  int main(int argc, char *argv[])
> >  {
> >  	int acpi_disabled;
> > -	struct tst_kcmdline_var params = TST_KCMDLINE_INIT("module.sig_enforce");
> > -	struct tst_kconfig_var kconfig = TST_KCONFIG_INIT("CONFIG_MODULE_SIG_FORCE");

> >  	tst_parse_opts(argc, argv, NULL, NULL);
> > -
> >  	tst_require_root();
> > -
> > -	tst_kcmdline_parse(&params, 1);
> > -	tst_kconfig_read(&kconfig, 1);
> > -	if (params.found || kconfig.choice == 'y')
> > -		tst_brkm(TCONF, tst_exit, "module signature is enforced, skip test");
> > -
> >  	tst_sig(FORK, DEF_HANDLER, cleanup);

> > +	tst_check_module_signature_enforced();

> One question, should we put this tst_check_module_signature_enforced()
> before or after tst_sig()? Asking because it's different in tpci.c

I suppose either way is ok, because we don't call the cleanup function anyway.
Best would be to convert the test to the new LTP API.
But I'll move it in tpci.c below tst_sig().

...
> > +++ b/testcases/kernel/syscalls/finit_module/finit_module01.c
> > @@ -17,7 +17,6 @@
> >  #include <errno.h>
> >  #include "lapi/init_module.h"
> >  #include "tst_module.h"
> > -#include "tst_kconfig.h"

> >  #define MODULE_NAME	"finit_module.ko"

> > @@ -27,14 +26,7 @@ static char *mod_path;

> >  static void setup(void)
> >  {
> > -	struct tst_kcmdline_var params = TST_KCMDLINE_INIT("module.sig_enforce");
> > -	struct tst_kconfig_var kconfig = TST_KCONFIG_INIT("CONFIG_MODULE_SIG_FORCE");
> > -
> > -	tst_kcmdline_parse(&params, 1);
> > -	tst_kconfig_read(&kconfig, 1);
> > -	if (params.found || kconfig.choice == 'y')
> > -		sig_enforce = 1;

> This test will expect an EKEYREJECTED error if the module signature is
> enforced. So I think:

> if (tst_module_signature_enforced())
> 	sig_enforce = 1;

> And remove tst_check_module_signature_enforced() below, otherwise the
> test will be skipped.

+1. I have this in other tests, but obviously I omitted this in
finit_module01.c. I'll fix it in v2.

Thanks for your review!

Kind regards,
Petr


More information about the ltp mailing list