Skip to content

Commit 39351c1

Browse files
Ram Paitorvalds
authored andcommitted
selftests/vm/pkeys: associate key on a mapped page and detect write violation
Detect write-violation on a page to which write-disabled key is associated much after the page is mapped. Signed-off-by: Ram Pai <[email protected]> Signed-off-by: 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/6bfe3b3832f8bcfb07d7f2cf116b45197f4587dd.1585646528.git.sandipan@linux.ibm.com Signed-off-by: Linus Torvalds <[email protected]>
1 parent aef759d commit 39351c1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tools/testing/selftests/vm/protection_keys.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,17 @@ void test_read_of_access_disabled_region_with_page_already_mapped(int *ptr,
10021002
expected_pkey_fault(pkey);
10031003
}
10041004

1005+
void test_write_of_write_disabled_region_with_page_already_mapped(int *ptr,
1006+
u16 pkey)
1007+
{
1008+
*ptr = __LINE__;
1009+
dprintf1("disabling write access; after accessing the page, "
1010+
"to PKEY[%02d], doing write\n", pkey);
1011+
pkey_write_deny(pkey);
1012+
*ptr = __LINE__;
1013+
expected_pkey_fault(pkey);
1014+
}
1015+
10051016
void test_write_of_write_disabled_region(int *ptr, u16 pkey)
10061017
{
10071018
dprintf1("disabling write access to PKEY[%02d], doing write\n", pkey);
@@ -1410,6 +1421,7 @@ void (*pkey_tests[])(int *ptr, u16 pkey) = {
14101421
test_read_of_access_disabled_region,
14111422
test_read_of_access_disabled_region_with_page_already_mapped,
14121423
test_write_of_write_disabled_region,
1424+
test_write_of_write_disabled_region_with_page_already_mapped,
14131425
test_write_of_access_disabled_region,
14141426
test_kernel_write_of_access_disabled_region,
14151427
test_kernel_write_of_write_disabled_region,

0 commit comments

Comments
 (0)