diff options
author | Ram Pai <[email protected]> | 2020-06-04 16:52:36 -0700 |
---|---|---|
committer | Linus Torvalds <[email protected]> | 2020-06-04 19:06:27 -0700 |
commit | 4e06e718afd71f99592a76a29167e9cd617b2b09 (patch) | |
tree | b5baeb52761025abd174df94e17e31649881e917 | |
parent | 39351c1326cf72d9b01c5faa3de23153727832f5 (diff) |
selftests/vm/pkeys: detect write violation on a mapped access-denied-key page
Detect write-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-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/6a7dd4069ee18a2a51b207a55aa197f3f3c59753.1585646528.git.sandipan@linux.ibm.com
Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r-- | tools/testing/selftests/vm/protection_keys.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c index cb31a5cdf6d9..8bb4de103874 100644 --- a/tools/testing/selftests/vm/protection_keys.c +++ b/tools/testing/selftests/vm/protection_keys.c @@ -1027,6 +1027,18 @@ void test_write_of_access_disabled_region(int *ptr, u16 pkey) *ptr = __LINE__; expected_pkey_fault(pkey); } + +void test_write_of_access_disabled_region_with_page_already_mapped(int *ptr, + u16 pkey) +{ + *ptr = __LINE__; + dprintf1("disabling access; after accessing the page, " + " to PKEY[%02d], doing write\n", pkey); + pkey_access_deny(pkey); + *ptr = __LINE__; + expected_pkey_fault(pkey); +} + void test_kernel_write_of_access_disabled_region(int *ptr, u16 pkey) { int ret; @@ -1423,6 +1435,7 @@ void (*pkey_tests[])(int *ptr, u16 pkey) = { test_write_of_write_disabled_region, test_write_of_write_disabled_region_with_page_already_mapped, test_write_of_access_disabled_region, + test_write_of_access_disabled_region_with_page_already_mapped, test_kernel_write_of_access_disabled_region, test_kernel_write_of_write_disabled_region, test_kernel_gup_of_access_disabled_region, |