On 03.08.23 16:32, David Hildenbrand wrote:
Let's test whether merging and unmerging in PROT_NONE areas works as expected.
Pass a page protection to mmap_and_merge_range(), which will trigger an mprotect() after writing to the pages, but before enabling merging.
Make sure that unsharing works as expected, by performing a ptrace write (using /proc/self/mem) and by setting MADV_UNMERGEABLE.
Note that this implicitly tests that ptrace writes in an inaccessible (PROT_NONE) mapping work as expected.
Signed-off-by: David Hildenbrand david@redhat.com
Andrew, can you squash the following?
From c2be7c02cb96b9189a52a5937821600ef4e259bd Mon Sep 17 00:00:00 2001 From: David Hildenbrand david@redhat.com Date: Mon, 7 Aug 2023 17:33:54 +0200 Subject: [PATCH] Fixup: selftest/mm: ksm_functional_tests: Add PROT_NONE test
As noted by Peter, we should be using sizeof(i) in test_prot_none().
Signed-off-by: David Hildenbrand david@redhat.com --- tools/testing/selftests/mm/ksm_functional_tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/mm/ksm_functional_tests.c b/tools/testing/selftests/mm/ksm_functional_tests.c index 8fa4889ab4f3..901e950f9138 100644 --- a/tools/testing/selftests/mm/ksm_functional_tests.c +++ b/tools/testing/selftests/mm/ksm_functional_tests.c @@ -516,7 +516,7 @@ static void test_prot_none(void) /* Store a unique value in each page on one half using ptrace */ for (i = 0; i < size / 2; i += pagesize) { lseek(mem_fd, (uintptr_t) map + i, SEEK_SET); - if (write(mem_fd, &i, sizeof(size)) != sizeof(size)) { + if (write(mem_fd, &i, sizeof(i)) != sizeof(i)) { ksft_test_result_fail("ptrace write failed\n"); goto unmap; }