aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Luck <tony.luck@intel.com>2021-03-25 13:03:44 -0700
committerTony Luck <tony.luck@intel.com>2021-03-25 13:03:44 -0700
commit06670d719a24f57d7a412aee6ce9a0a61eee4788 (patch)
treeb802a5261ca76ef9e1ea7acc35b915f2359609c3
parent9696a1fa3b56440e4ce1cdd0c2e92e0fcd57ebfb (diff)
downloadras-tools-06670d719a24f57d7a412aee6ce9a0a61eee4788.tar.gz
einj_mem_uc: Add a case for kernel accessing a poisoned futex(2) operand
[Also changed flags for the copyin case to remove F_SIGBUS] Signed-off-by: Tony Luck <tony.luck@intel.com>
-rw-r--r--einj_mem_uc.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/einj_mem_uc.c b/einj_mem_uc.c
index 74b55e1..5adc85a 100644
--- a/einj_mem_uc.c
+++ b/einj_mem_uc.c
@@ -21,6 +21,8 @@
#define __USE_GNU 1
#include <sched.h>
#include <errno.h>
+#include <sys/syscall.h>
+#include <linux/futex.h>
extern long long vtop(long long);
extern void proc_cpuinfo(int *nsockets, int *ncpus, char *model, int **apicmap);
@@ -359,6 +361,25 @@ int trigger_instr(char *addr)
return ret;
}
+static int futex(int *uaddr, int futex_op, int val,
+ const struct timespec *timeout, int *uaddr2, int val3)
+{
+ return syscall(SYS_futex, uaddr, futex_op, val, timeout, uaddr, val3);
+}
+
+int trigger_futex(char *addr)
+{
+ int ret;
+
+ ret = futex((int *)addr, FUTEX_WAIT, 0, NULL, NULL, 0);
+ if (ret == -1)
+ printf("futex returned with errno=%d\n", errno);
+ else
+ printf("futex return %d\n", ret);
+
+ return ret;
+}
+
/* attributes of the test and which events will follow our trigger */
#define F_MCE 1
#define F_CMCI 2
@@ -412,13 +433,17 @@ struct test {
},
{
"copyin", "Kernel copies data from user. Probably fatal",
- data_alloc, inject_uc, 1, trigger_copyin, F_MCE|F_CMCI|F_SIGBUS|F_FATAL,
+ data_alloc, inject_uc, 1, trigger_copyin, F_MCE|F_CMCI|F_FATAL,
},
{
"copyout", "Kernel copies data to user. Probably fatal",
page_cache_alloc, inject_uc, 1, trigger_copyout, F_MCE|F_CMCI|F_SIGBUS|F_FATAL,
},
{
+ "futex", "Kernel access to futex(2). Probably fatal",
+ data_alloc, inject_uc, 1, trigger_futex, F_MCE|F_CMCI|F_FATAL,
+ },
+ {
"mlock", "mlock target page then inject/read to generates SRAR machine check",
mlock_data_alloc, inject_uc, 1, trigger_single, F_MCE|F_CMCI|F_SIGBUS,
},