Skip to contentSkip to conversation

umip_basic_test.c: update umip basic test for new kernel v5.4

PATCH New Pengfei Xu 2 participants 2 messages Oct 3, 2019 – Oct 18, 2019

lore
Share & tools
lore

Pengfei Xu

author
#0 lore raw

PATCH v2 1/1 umip_basic_test.c: update umip basic test for new kernel v5.4

After linux kernel v5.4 mainline, 64bit SGDT SIDT SMSW will return dummy value and not trigger SIGSEGV due to kernel code change. For detailed kernel update info, you could check v5.4 commit:
x86/umip: Add emulation (spoofing) for UMIP covered instructions in 64-bit processes as well

---
 testcases/kernel/security/umip/umip_basic_test.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
testcases/kernel/security/umip/umip_basic_test.c +19 -0
index 37850ef9f..5a2b71013 100644
@@ -112,6 +112,25 @@ static void verify_umip_instruction(unsigned int n)
 
 	SAFE_WAITPID(pid, &status, 0);
 
+	switch (n) {
+	case 0:
+	case 1:
+	case 3:
+		/* after linux kernel v5.4 mainline, 64bit SGDT SIDT SMSW will return
+		   dummy value and not trigger SIGSEGV due to kernel code change */
+		if ((tst_kvercmp(5, 4, 0)) >= 0) {
+			tst_res(TINFO, "Linux kernel version is v5.4 or after than v5.4");
+			if (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {
+				tst_res(TFAIL, "Got SIGSEGV");
+				return;
+			}
+			tst_res(TPASS, "Didn't receive SIGSEGV, child exited with %s",
+				tst_strstatus(status));
+			return;
+		} else
+			tst_res(TINFO, "Linux kernel version is before than v5.4");
+	}
+
 	if (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {
 		tst_res(TPASS, "Got SIGSEGV");
 		return;
Signature · 1 line
2.14.1