diff mbox series

[2/2] syscalls/init_module02: Rewrite lockdown skips

Message ID 20210921113317.16756-2-mdoucha@suse.cz
State Accepted
Headers show
Series [1/2] Add missig parentheses to TST_EXP_FAIL() errno check | expand

Commit Message

Martin Doucha Sept. 21, 2021, 11:33 a.m. UTC
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/init_module/init_module02.c      | 33 +++++++++----------
 1 file changed, 15 insertions(+), 18 deletions(-)

Comments

Petr Vorel Sept. 21, 2021, 1:32 p.m. UTC | #1
Hi Martin,

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Thanks!
Cyril Hrubis Sept. 21, 2021, 2:03 p.m. UTC | #2
Hi!
Looks good as well:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Petr Vorel Sept. 22, 2021, 9:46 a.m. UTC | #3
Hi Martin, Cyril,

thanks, merged!

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/init_module/init_module02.c b/testcases/kernel/syscalls/init_module/init_module02.c
index dac99a4da..ad6569a06 100644
--- a/testcases/kernel/syscalls/init_module/init_module02.c
+++ b/testcases/kernel/syscalls/init_module/init_module02.c
@@ -34,16 +34,16 @@  static struct tcase {
 	unsigned long *size;
 	const char *param;
 	int cap;
+	int skip_in_lockdown;
 	int exp_errno;
-	int lockdown_errno;
 } tcases[] = {
-	{"NULL-buffer", &null_buf, &size, "", 0, EFAULT, EFAULT},
-	{"faulty-buffer", &faulty_buf, &size, "", 0, EFAULT, EFAULT},
-	{"null-param", &buf, &size, NULL, 0, EFAULT, EPERM},
-	{"zero-size", &buf, &zero_size, "", 0, ENOEXEC, ENOEXEC},
-	{"invalid_param", &buf, &size, "status=invalid", 0, EINVAL, EPERM},
-	{"no-perm", &buf, &size, "", 1, EPERM, EPERM},
-	{"module-exists", &buf, &size, "", 0, EEXIST, EPERM},
+	{"NULL-buffer", &null_buf, &size, "", 0, 0, EFAULT},
+	{"faulty-buffer", &faulty_buf, &size, "", 0, 0, EFAULT},
+	{"null-param", &buf, &size, NULL, 0, 1, EFAULT},
+	{"zero-size", &buf, &zero_size, "", 0, 0, ENOEXEC},
+	{"invalid_param", &buf, &size, "status=invalid", 0, 1, EINVAL},
+	{"no-perm", &buf, &size, "", 1, 0, EPERM},
+	{"module-exists", &buf, &size, "", 0, 1, EEXIST},
 };
 
 static void setup(void)
@@ -67,23 +67,20 @@  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;
+	}
+
 	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(init_module(*tc->buf, *tc->size, tc->param),
-		     kernel_lockdown ? tc->lockdown_errno : tc->exp_errno,
-		     "TestName: %s", tc->name);
+		tc->exp_errno, "TestName: %s", tc->name);
 
 	if (tc->exp_errno == EEXIST)
 		tst_module_unload(MODULE_NAME);