All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/finit_module02: Rewrite lockdown skips
@ 2021-09-21 10:30 Martin Doucha
  2021-09-21 13:58 ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Doucha @ 2021-09-21 10:30 UTC (permalink / raw)
  To: ltp

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 <mdoucha@suse.cz>
---
 .../syscalls/finit_module/finit_module02.c    | 44 +++++++++----------
 1 file changed, 20 insertions(+), 24 deletions(-)

diff --git a/testcases/kernel/syscalls/finit_module/finit_module02.c b/testcases/kernel/syscalls/finit_module/finit_module02.c
index 503c8e994..0d2bf917e 100644
--- a/testcases/kernel/syscalls/finit_module/finit_module02.c
+++ b/testcases/kernel/syscalls/finit_module/finit_module02.c
@@ -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);
-- 
2.33.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH] syscalls/finit_module02: Rewrite lockdown skips
  2021-09-21 10:30 [LTP] [PATCH] syscalls/finit_module02: Rewrite lockdown skips Martin Doucha
@ 2021-09-21 13:58 ` Cyril Hrubis
  2021-09-23 14:39   ` Petr Vorel
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2021-09-21 13:58 UTC (permalink / raw)
  To: Martin Doucha; +Cc: ltp

Hi!
> 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 <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH] syscalls/finit_module02: Rewrite lockdown skips
  2021-09-21 13:58 ` Cyril Hrubis
@ 2021-09-23 14:39   ` Petr Vorel
  0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2021-09-23 14:39 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Martin, Cyril,

thanks, pushed!

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-23 14:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-21 10:30 [LTP] [PATCH] syscalls/finit_module02: Rewrite lockdown skips Martin Doucha
2021-09-21 13:58 ` Cyril Hrubis
2021-09-23 14:39   ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.