The patch titled Subject: selftests/vm/pkeys: associate key on a mapped page and detect write violation has been added to the -mm tree. Its filename is selftests-vm-pkeys-associate-key-on-a-mapped-page-and-detect-write-violation.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/selftests-vm-pkeys-associate-key-on-a-mapped-page-and-detect-write-violation.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/selftests-vm-pkeys-associate-key-on-a-mapped-page-and-detect-write-violation.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Ram Pai <linuxram@xxxxxxxxxx> Subject: 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. Link: http://lkml.kernel.org/r/6bfe3b3832f8bcfb07d7f2cf116b45197f4587dd.1585646528.git.sandipan@xxxxxxxxxxxxx Signed-off-by: Ram Pai <linuxram@xxxxxxxxxx> Acked-by: Dave Hansen <dave.hansen@xxxxxxxxx> Signed-off-by: Sandipan Das <sandipan@xxxxxxxxxxxxx> Cc: Dave Hansen <dave.hansen@xxxxxxxxx> Cc: Florian Weimer <fweimer@xxxxxxxxxx> Cc: "Desnes A. Nunes do Rosario" <desnesn@xxxxxxxxxxxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxxxxx> Cc: Thiago Jung Bauermann <bauerman@xxxxxxxxxxxxx> Cc: "Aneesh Kumar K.V" <aneesh.kumar@xxxxxxxxxxxxx> Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Michal Suchanek <msuchanek@xxxxxxx> Cc: Shuah Khan <shuah@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- tools/testing/selftests/vm/protection_keys.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- a/tools/testing/selftests/vm/protection_keys.c~selftests-vm-pkeys-associate-key-on-a-mapped-page-and-detect-write-violation +++ a/tools/testing/selftests/vm/protection_keys.c @@ -1002,6 +1002,17 @@ void test_read_of_access_disabled_region 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, _ Patches currently in -mm which might be from linuxram@xxxxxxxxxx are selftests-x86-pkeys-move-selftests-to-arch-neutral-directory.patch selftests-vm-pkeys-rename-all-references-to-pkru-to-a-generic-name.patch selftests-vm-pkeys-move-generic-definitions-to-header-file.patch selftests-vm-pkeys-fix-pkey_disable_clear.patch selftests-vm-pkeys-fix-assertion-in-pkey_disable_set-clear.patch selftests-vm-pkeys-fix-alloc_random_pkey-to-make-it-really-random.patch selftests-vm-pkeys-introduce-generic-pkey-abstractions.patch selftests-vm-pkeys-introduce-powerpc-support.patch selftests-vm-pkeys-fix-assertion-in-test_pkey_alloc_exhaust.patch selftests-vm-pkeys-improve-checks-to-determine-pkey-support.patch selftests-vm-pkeys-associate-key-on-a-mapped-page-and-detect-access-violation.patch selftests-vm-pkeys-associate-key-on-a-mapped-page-and-detect-write-violation.patch selftests-vm-pkeys-detect-write-violation-on-a-mapped-access-denied-key-page.patch selftests-vm-pkeys-introduce-a-sub-page-allocator.patch selftests-vm-pkeys-test-correct-behaviour-of-pkey-0.patch selftests-vm-pkeys-override-access-right-definitions-on-powerpc.patch