Skip to contentSkip to conversation

selftests, x86: updates for x86 protection keys self tests

PATCH In review Dave Hansen 2 participants 4 messages Feb 3, 2017 – Feb 8, 2017

Subsystems (2)
lore
Share & tools
lore

Dave Hansen

author maintainer
#0 lore raw

cover selftests, x86: updates for x86 protection keys self tests

The memory protection keys selftests are spewing an uninitialized variable warning

I also included a fix that affected the 32-bit version of the pkeys test case. It was parsing the siginfo incorrectly.

author maintainer
#1 lore raw

PATCH 1/2 selftests, x86, protection_keys: fix uninitialized variable warning

From: Dave Hansen <[email protected]>

'orig_pkru' might have been uninitialized here. Fix it.

---

 b/tools/testing/selftests/x86/protection_keys.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/x86/protection_keys.c renamed from tools/testing/selftests/x86/protection_keys.c~pkeys-selftests-cleanrup-4-10-ish +1 -1
diff -puN tools/testing/selftests/x86/protection_keys.c~pkeys-selftests-cleanrup-4-10-ish tools/testing/selftests/x86/protection_keys.c
@@ -462,7 +462,7 @@ void pkey_disable_set(int pkey, int flag
 	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);

_

author maintainer
#2 lore raw

PATCH 2/2 selftests, x86, protection_keys: fix wrong offset in siginfo

In reply to Dave Hansen

From: Dave Hansen <[email protected]>

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.

Cc Ingo Molnar <[email protected]>
Cc Shuah Khan <[email protected]>

---

 b/tools/testing/selftests/x86/protection_keys.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/x86/protection_keys.c renamed from tools/testing/selftests/x86/protection_keys.c~pkeys-selftest-fix-32bit-offset +1 -1
diff -puN tools/testing/selftests/x86/protection_keys.c~pkeys-selftest-fix-32bit-offset tools/testing/selftests/x86/protection_keys.c
@@ -192,7 +192,7 @@ void lots_o_noops_around_write(int *writ
 #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

_

#3 lore raw
In reply to Dave Hansen
Quoted 6 lines · Dave Hansen

The memory protection keys selftests are spewing an uninitialized variable warning

I also included a fix that affected the 32-bit version of the pkeys test case. It was parsing the siginfo incorrectly.

Dave,

Thanks. Applied to linux-kselftest next for 4.11-rc1

-- Shuah