public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH tbt_cases] umip_basic_test.c: update umip basic test for new kernel v5.4
@ 2019-09-27  3:19 Pengfei Xu
  2019-10-03 12:14 ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Pengfei Xu @ 2019-09-27  3:19 UTC (permalink / raw)
  To: ltp

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

Signed-off-by: Pengfei Xu <pengfei.xu@intel.com>
---
 testcases/kernel/security/umip/umip_basic_test.c | 25 ++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/security/umip/umip_basic_test.c b/testcases/kernel/security/umip/umip_basic_test.c
index 37850ef9f..278ae92f6 100644
--- a/testcases/kernel/security/umip/umip_basic_test.c
+++ b/testcases/kernel/security/umip/umip_basic_test.c
@@ -21,6 +21,7 @@
 #include <string.h>
 #include <sys/wait.h>
 #include <signal.h>
+#include <linux/version.h>
 
 #include "tst_test.h"
 #include "tst_safe_stdio.h"
@@ -112,11 +113,31 @@ 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 LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0)
+			tst_res(TINFO, "Linux kernel version is after than v5.4");
+			if (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {
+				tst_res(TFAIL, "Got SIGSEGV\n\n");
+				return;
+			}
+			tst_res(TPASS, "Didn't receive SIGSEGV, child exited with %s\n\n",
+				tst_strstatus(status));
+				return;
+		#else
+			tst_res(TINFO, "Linux kernel version is before than v5.4");
+		#endif
+	}
+
 	if (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {
-		tst_res(TPASS, "Got SIGSEGV");
+		tst_res(TPASS, "Got SIGSEGV\n\n");
 		return;
 	}
-	tst_res(TFAIL, "Didn't receive SIGSEGV, child exited with %s",
+	tst_res(TFAIL, "Didn't receive SIGSEGV, child exited with %s\n\n",
 		tst_strstatus(status));
 }
 
-- 
2.14.1


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

end of thread, other threads:[~2019-10-03 15:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-27  3:19 [LTP] [PATCH tbt_cases] umip_basic_test.c: update umip basic test for new kernel v5.4 Pengfei Xu
2019-10-03 12:14 ` Cyril Hrubis
2019-10-03 15:43   ` Pengfei Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox