syscalls/finit_module02: Rewrite lockdown skips
PATCH 1/1 syscalls/finit_module02: Rewrite lockdown skips
Different kernels may return different module signature validation errors for null-param and invalid-param test cases. Skip both test cases when the kernel is in lockdown.
Signed-off-by Martin Doucha <[email protected]>
--- .../syscalls/finit_module/finit_module02.c | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-)
testcases/kernel/syscalls/finit_module/finit_module02.c +20 -24
@@ -38,6 +38,7 @@ struct tcase {int flags;int cap;int exp_errno; +int skip_in_lockdown;void (*fix_errno)(struct tcase *tc); };
@@ -65,24 +66,21 @@ static void dir_setup(struct tcase *tc) tc->exp_errno =EINVAL ; } -static void lockdown_setup (struct tcase *tc) -{ -if (kernel_lockdown) - tc->exp_errno =EPERM ; -} -static struct tcase tcases[] = { - {"invalid-fd" , &fd_invalid,"" ,O_RDONLY |O_CLOEXEC ,0 ,0 ,0 , bad_fd_setup}, - {"zero-fd" , &fd_zero,"" ,O_RDONLY |O_CLOEXEC ,0 ,0 ,EINVAL ,NULL }, - {"null-param" , &fd,NULL ,O_RDONLY |O_CLOEXEC ,0 ,0 ,EFAULT , - lockdown_setup}, + {"invalid-fd" , &fd_invalid,"" ,O_RDONLY |O_CLOEXEC ,0 ,0 ,0 ,0 , + bad_fd_setup}, + {"zero-fd" , &fd_zero,"" ,O_RDONLY |O_CLOEXEC ,0 ,0 ,EINVAL ,0 ,NULL }, + {"null-param" , &fd,NULL ,O_RDONLY |O_CLOEXEC ,0 ,0 ,EFAULT ,1 ,NULL }, {"invalid-param" , &fd,"status=invalid" ,O_RDONLY |O_CLOEXEC ,0 ,0 , -EINVAL , lockdown_setup}, - {"invalid-flags" , &fd,"" ,O_RDONLY |O_CLOEXEC ,-1 ,0 ,EINVAL ,NULL }, - {"no-perm" , &fd,"" ,O_RDONLY |O_CLOEXEC ,0 ,1 ,EPERM ,NULL }, - {"module-exists" , &fd,"" ,O_RDONLY |O_CLOEXEC ,0 ,0 ,EEXIST ,NULL }, - {"file-not-readable" , &fd,"" ,O_WRONLY |O_CLOEXEC ,0 ,0 ,0 , wo_file_setup}, - {"directory" , &fd_dir,"" ,O_RDONLY |O_CLOEXEC ,0 ,0 ,0 , dir_setup}, +EINVAL ,1 ,NULL }, + {"invalid-flags" , &fd,"" ,O_RDONLY |O_CLOEXEC ,-1 ,0 ,EINVAL ,0 , +NULL }, + {"no-perm" , &fd,"" ,O_RDONLY |O_CLOEXEC ,0 ,1 ,EPERM ,0 ,NULL }, + {"module-exists" , &fd,"" ,O_RDONLY |O_CLOEXEC ,0 ,0 ,EEXIST ,1 , +NULL }, + {"file-not-readable" , &fd,"" ,O_WRONLY |O_CLOEXEC ,0 ,0 ,0 ,0 , + wo_file_setup}, + {"directory" , &fd_dir,"" ,O_RDONLY |O_CLOEXEC ,0 ,0 ,0 ,0 , dir_setup}, };static void setup (void )
@@ -112,21 +110,19 @@ static void run(unsigned int n) {struct tcase *tc = &tcases[n]; +if (tc->skip_in_lockdown && kernel_lockdown) { +tst_res (TCONF ,"Kernel is locked down, skipping %s" , tc->name); +return ; + } + fd =SAFE_OPEN (mod_path, tc->open_flags);if (tc->cap)tst_cap_action (&cap_drop);/* Insert module twice */ -if (tc->exp_errno ==EEXIST ) { -if (kernel_lockdown) { -tst_res (TCONF ,"Kernel is locked down, skipping %s" , - tc->name); -return ; - } - +if (tc->exp_errno ==EEXIST )tst_module_load (MODULE_NAME ,NULL ); - }TST_EXP_FAIL (finit_module (*tc->fd, tc->param, tc->flags), tc->exp_errno,"TestName: %s" , tc->name);
Signature · 5 lines
2.33.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 3 lines
Different kernels may return different module signature validation errors for null-param and invalid-param test cases. Skip both test cases when the kernel is in lockdown.
Looks good, Reviewed-by: Cyril Hrubis <[email protected]>
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Martin, Cyril,
thanks, pushed!
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp