diff options
author | Ram Pai <[email protected]> | 2020-06-04 16:52:32 -0700 |
---|---|---|
committer | Linus Torvalds <[email protected]> | 2020-06-04 19:06:27 -0700 |
commit | 39351c1326cf72d9b01c5faa3de23153727832f5 (patch) | |
tree | 2fd6eee4d1b4017b372864a56835c66bc6d19df2 | |
parent | aef759db63fd4cfad5b585db96cf05f34d04cbd9 (diff) |
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]>
-rw-r--r-- | tools/testing/selftests/vm/protection_keys.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index f65d384ef6a0..cb31a5cdf6d9 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -1002,6 +1002,17 @@ void test_read_of_access_disabled_region_with_page_already_mapped(int *ptr, expected_pkey_fault(pkey); } +void test_write_of_write_disabled_region_with_page_already_mapped(int *ptr, + u16 pkey) +{ + *ptr = __LINE__; + dprintf1("disabling write access; after accessing the page, " + "to PKEY[%02d], doing write\n", pkey); + pkey_write_deny(pkey); + *ptr = __LINE__; + expected_pkey_fault(pkey); +} + void test_write_of_write_disabled_region(int *ptr, u16 pkey) { dprintf1("disabling write access to PKEY[%02d], doing write\n", pkey); @@ -1410,6 +1421,7 @@ void (*pkey_tests[])(int *ptr, u16 pkey) = { test_read_of_access_disabled_region, test_read_of_access_disabled_region_with_page_already_mapped, test_write_of_write_disabled_region, + test_write_of_write_disabled_region_with_page_already_mapped, test_write_of_access_disabled_region, test_kernel_write_of_access_disabled_region, test_kernel_write_of_write_disabled_region, |