Skip to contentSkip to conversation

selftests/vm/pkeys: fix assert when DEBUG_LEVEL is set to 2

PATCH New Dave Kleikamp 1 participant 1 message Apr 12, 2021 Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/vm/pkeys: fix assert when DEBUG_LEVEL is set to 2

test_implicit_mprotect_exec_only_memory() hits an assert in _read_pkey_reg() when DEBUG_LEVEL=2.

test 12 starting with pkey: 2
doing malloc_pkey_anon_huge(size=4096, prot=0x3, pkey=2)
new_nr_records: 1
new_size: 24
sys_mprotect_pkey(0x0x7f44144bb000, 400000, prot=3, pkey=2)
mprotect_pkey(0x7f44144bb000, 400000, prot=0x3, pkey=2) ret: 0
mprotect_pkey()::628, ret: 0 pkey_reg: 0x0000000000000000 shadow: 0x0000000000000000 unaligned protection_keys: pkey-helpers.h:127: _read_pkey_reg: Assertion `pkey_reg == shadow_pkey_reg' failed.

This patch provides one way to fix it. Would it be better to make sure that shadow_pkey_reg is properly set?

---
 tools/testing/selftests/vm/protection_keys.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/vm/protection_keys.c +1 -1
index fdbb602ecf32..070f6f90dcce 100644
@@ -1449,7 +1449,7 @@ void test_implicit_mprotect_exec_only_memory(int *ptr, u16 pkey)
 	ret = mprotect(p1, PAGE_SIZE, PROT_EXEC);
 	pkey_assert(!ret);
 
-	dprintf2("pkey_reg: %016llx\n", read_pkey_reg());
+	dprintf2("pkey_reg: %016llx\n", __read_pkey_reg());
 
 	/* Make sure this is an *instruction* fault */
 	madvise(p1, PAGE_SIZE, MADV_DONTNEED);
Signature · 1 line
2.31.1