Skip to content

Commit aef759d

Browse files
Ram Paitorvalds
authored andcommitted
selftests/vm/pkeys: associate key on a mapped page and detect access violation
Detect access-violation on a page to which access-disabled key is associated much after the page is mapped. Signed-off-by: Ram Pai <[email protected]> Signed-off: Sandipan Das <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Acked-by: Dave Hansen <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Florian Weimer <[email protected]> Cc: "Desnes A. Nunes do Rosario" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Thiago Jung Bauermann <[email protected]> Cc: "Aneesh Kumar K.V" <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Michal Suchanek <[email protected]> Cc: Shuah Khan <[email protected]> Link: http://lkml.kernel.org/r/4a19cf9252c03dd883887e9002881599e6900d06.1585646528.git.sandipan@linux.ibm.com Signed-off-by: Linus Torvalds <[email protected]>
1 parent 94c8a22 commit aef759d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tools/testing/selftests/vm/protection_keys.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,24 @@ void test_read_of_access_disabled_region(int *ptr, u16 pkey)
984984
dprintf1("*ptr: %d\n", ptr_contents);
985985
expected_pkey_fault(pkey);
986986
}
987+
988+
void test_read_of_access_disabled_region_with_page_already_mapped(int *ptr,
989+
u16 pkey)
990+
{
991+
int ptr_contents;
992+
993+
dprintf1("disabling access to PKEY[%02d], doing read @ %p\n",
994+
pkey, ptr);
995+
ptr_contents = read_ptr(ptr);
996+
dprintf1("reading ptr before disabling the read : %d\n",
997+
ptr_contents);
998+
read_pkey_reg();
999+
pkey_access_deny(pkey);
1000+
ptr_contents = read_ptr(ptr);
1001+
dprintf1("*ptr: %d\n", ptr_contents);
1002+
expected_pkey_fault(pkey);
1003+
}
1004+
9871005
void test_write_of_write_disabled_region(int *ptr, u16 pkey)
9881006
{
9891007
dprintf1("disabling write access to PKEY[%02d], doing write\n", pkey);
@@ -1390,6 +1408,7 @@ void test_mprotect_pkey_on_unsupported_cpu(int *ptr, u16 pkey)
13901408
void (*pkey_tests[])(int *ptr, u16 pkey) = {
13911409
test_read_of_write_disabled_region,
13921410
test_read_of_access_disabled_region,
1411+
test_read_of_access_disabled_region_with_page_already_mapped,
13931412
test_write_of_write_disabled_region,
13941413
test_write_of_access_disabled_region,
13951414
test_kernel_write_of_access_disabled_region,

0 commit comments

Comments
 (0)