[LTP] [PATCH] device-drivers/uaccess: add a workaround for Intel's SMAP feature
Xiaoguang Wang
wangxg.fnst@cn.fujitsu.com
Tue Mar 15 10:25:17 CET 2016
When Intel's new "Supervisor Mode Access Prevention" (SMAP) feature is
enabled, kernel will be forbidden to visit user space memory, please
see url: https://lwn.net/Articles/517475/ for detailed infomation.
Here, we explicitly call stac()/clac() to enable/disable SMAP feature.
Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
---
testcases/kernel/device-drivers/uaccess/ltp_uaccess.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c b/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c
index a9a06e9..35a9aa0 100644
--- a/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c
+++ b/testcases/kernel/device-drivers/uaccess/ltp_uaccess.c
@@ -68,6 +68,9 @@ static ssize_t sys_tcase(struct device *dev,
str = (char *) ptr;
test_result = 0;
+#ifdef CONFIG_X86_SMAP
+ stac();
+#endif
switch (tc) {
case TC_READ_USER:
if (copy_from_user(buffer, str, str_size))
@@ -90,6 +93,11 @@ static ssize_t sys_tcase(struct device *dev,
break;
}
+#ifdef CONFIG_X86_SMAP
+ clac();
+#endif
+
+
return count;
}
static DEVICE_ATTR(tcase, S_IWUSR, NULL, sys_tcase);
--
1.8.3.1
More information about the ltp
mailing list