From fbb02ed8a14f54d0d07975025757e861e680e3be Mon Sep 17 00:00:00 2001 From: Shuah Khan Date: Thu, 5 Jan 2017 14:03:39 -0700 Subject: selftests: x86 protection_keys fix unused variable compile warnings Fix unused variable compile warnings in protection_keys.c Signed-off-by: Shuah Khan --- tools/testing/selftests/x86/protection_keys.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'tools/testing/selftests/x86/protection_keys.c') diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c index bdd58c78902e..70402cd96265 100644 --- a/tools/testing/selftests/x86/protection_keys.c +++ b/tools/testing/selftests/x86/protection_keys.c @@ -812,8 +812,6 @@ void setup_hugetlbfs(void) { int err; int fd; - int validated_nr_pages; - int i; char buf[] = "123"; if (geteuid() != 0) { @@ -1133,7 +1131,6 @@ void test_pkey_syscalls_on_non_allocated_pkey(int *ptr, u16 pkey) void test_pkey_syscalls_bad_args(int *ptr, u16 pkey) { int err; - int bad_flag = (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE) + 1; int bad_pkey = NR_PKEYS+99; /* not enforced when pkey_get() is not a syscall @@ -1149,8 +1146,6 @@ void test_pkey_syscalls_bad_args(int *ptr, u16 pkey) /* Assumes that all pkeys other than 'pkey' are unallocated */ void test_pkey_alloc_exhaust(int *ptr, u16 pkey) { - unsigned long flags; - unsigned long init_val; int err; int allocated_pkeys[NR_PKEYS] = {0}; int nr_allocated_pkeys = 0; -- cgit v1.2.3 From 3e91293ffccafe30daa7310526bbfbc287e0c0fd Mon Sep 17 00:00:00 2001 From: Shuah Khan Date: Thu, 5 Jan 2017 14:11:00 -0700 Subject: selftests: x86 protection_keys remove dead code Remove commented out calls to pkey_get(). Signed-off-by: Shuah Khan --- tools/testing/selftests/x86/protection_keys.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'tools/testing/selftests/x86/protection_keys.c') diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c index 70402cd96265..46f53ec502f6 100644 --- a/tools/testing/selftests/x86/protection_keys.c +++ b/tools/testing/selftests/x86/protection_keys.c @@ -1114,11 +1114,6 @@ void test_pkey_syscalls_on_non_allocated_pkey(int *ptr, u16 pkey) err = sys_pkey_free(i); pkey_assert(err); - /* not enforced when pkey_get() is not a syscall - err = pkey_get(i, 0); - pkey_assert(err < 0); - */ - err = sys_pkey_free(i); pkey_assert(err); @@ -1133,11 +1128,6 @@ void test_pkey_syscalls_bad_args(int *ptr, u16 pkey) int err; int bad_pkey = NR_PKEYS+99; - /* not enforced when pkey_get() is not a syscall - err = pkey_get(bad_pkey, bad_flag); - pkey_assert(err < 0); - */ - /* pass a known-invalid pkey in: */ err = sys_mprotect_pkey(ptr, PAGE_SIZE, PROT_READ, bad_pkey); pkey_assert(err); -- cgit v1.2.3 From 16846c2d96b0d7b3f7123257c4b58b06768c6d65 Mon Sep 17 00:00:00 2001 From: Dave Hansen Date: Fri, 3 Feb 2017 10:51:34 -0800 Subject: selftests, x86, protection_keys: fix uninitialized variable warning 'orig_pkru' might have been uninitialized here. Fix it. Signed-off-by: Dave Hansen Signed-off-by: Shuah Khan --- tools/testing/selftests/x86/protection_keys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/testing/selftests/x86/protection_keys.c') diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c index 46f53ec502f6..bccc6f2a2f7e 100644 --- a/tools/testing/selftests/x86/protection_keys.c +++ b/tools/testing/selftests/x86/protection_keys.c @@ -462,7 +462,7 @@ void pkey_disable_set(int pkey, int flags) unsigned long syscall_flags = 0; int ret; int pkey_rights; - u32 orig_pkru; + u32 orig_pkru = rdpkru(); dprintf1("START->%s(%d, 0x%x)\n", __func__, pkey, flags); -- cgit v1.2.3 From 2195bff041486eb7fcceaf058acaedcd057efbdc Mon Sep 17 00:00:00 2001 From: Dave Hansen Date: Fri, 3 Feb 2017 10:51:35 -0800 Subject: selftests, x86, protection_keys: fix wrong offset in siginfo The siginfo contains a bunch of information about the fault. For protection keys, it tells us which protection key's permissions were violated. The wrong offset in here leads to reading garbage and thus failures in the tests. We should probably eventually move this over to using the kernel's headers defining the siginfo instead of a hard-coded offset. But, for now, just do the simplest fix. Signed-off-by: Dave Hansen Cc: Ingo Molnar Cc: Shuah Khan Signed-off-by: Shuah Khan --- tools/testing/selftests/x86/protection_keys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/testing/selftests/x86/protection_keys.c') diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testing/selftests/x86/protection_keys.c index bccc6f2a2f7e..f39c5bc6e01a 100644 --- a/tools/testing/selftests/x86/protection_keys.c +++ b/tools/testing/selftests/x86/protection_keys.c @@ -192,7 +192,7 @@ void lots_o_noops_around_write(int *write_to_me) #define SYS_pkey_alloc 381 #define SYS_pkey_free 382 #define REG_IP_IDX REG_EIP -#define si_pkey_offset 0x18 +#define si_pkey_offset 0x14 #else #define SYS_mprotect_key 329 #define SYS_pkey_alloc 330 -- cgit v1.2.3