<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 27, 2019 at 11:39 AM Pengfei Xu <<a href="mailto:pengfei.xu@intel.com">pengfei.xu@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">After linux kernel v5.4 mainline, 64bit SGDT SIDT SMSW will return<br>
dummy value and not trigger SIGSEGV due to kernel code change.<br>
For detailed kernel update info, you could check v5.4 commit:<br>
x86/umip: Add emulation (spoofing) for UMIP covered instructions in<br>
64-bit processes as well<br>
<br>
Signed-off-by: Pengfei Xu <<a href="mailto:pengfei.xu@intel.com" target="_blank">pengfei.xu@intel.com</a>><br>
---<br>
testcases/kernel/security/umip/umip_basic_test.c | 25 ++++++++++++++++++++++--<br>
1 file changed, 23 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/testcases/kernel/security/umip/umip_basic_test.c b/testcases/kernel/security/umip/umip_basic_test.c<br>
index 37850ef9f..278ae92f6 100644<br>
--- a/testcases/kernel/security/umip/umip_basic_test.c<br>
+++ b/testcases/kernel/security/umip/umip_basic_test.c<br>
@@ -21,6 +21,7 @@<br>
#include <string.h><br>
#include <sys/wait.h><br>
#include <signal.h><br>
+#include <linux/version.h><br>
<br>
#include "tst_test.h"<br>
#include "tst_safe_stdio.h"<br>
@@ -112,11 +113,31 @@ static void verify_umip_instruction(unsigned int n)<br>
<br>
SAFE_WAITPID(pid, &status, 0);<br>
<br>
+ switch (n) {<br>
+ case 0:<br>
+ case 1:<br>
+ case 3:<br>
+ /* after linux kernel v5.4 mainline, 64bit SGDT SIDT SMSW will return<br>
+ dummy value and not trigger SIGSEGV due to kernel code change */<br>
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,0)<br>
+ tst_res(TINFO, "Linux kernel version is after than v5.4");<br>
+ if (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {<br>
+ tst_res(TFAIL, "Got SIGSEGV\n\n");<br>
+ return;<br>
+ }<br>
+ tst_res(TPASS, "Didn't receive SIGSEGV, child exited with %s\n\n",<br>
+ tst_strstatus(status));<br>
+ return;<br>
+ #else<br>
+ tst_res(TINFO, "Linux kernel version is before than v5.4");<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Thank you for fixing this.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">My concern is that if an LTS distro backports the patch(commit e86c2c8b93), then it will break this hardcode kernel-version comparing.</div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ #endif<br>
+ }<br>
+<br>
if (WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {<br>
- tst_res(TPASS, "Got SIGSEGV");<br>
+ tst_res(TPASS, "Got SIGSEGV\n\n");<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Why we need two '\n' here?</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
return;<br>
}<br>
- tst_res(TFAIL, "Didn't receive SIGSEGV, child exited with %s",<br>
+ tst_res(TFAIL, "Didn't receive SIGSEGV, child exited with %s\n\n",<br>
tst_strstatus(status));<br>
}<br>
<br>
-- <br>
2.14.1<br>
<br>
<br>
-- <br>
Mailing list info: <a href="https://lists.linux.it/listinfo/ltp" rel="noreferrer" target="_blank">https://lists.linux.it/listinfo/ltp</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>