aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrew Turner <andrew@FreeBSD.org>2020-10-13 10:26:15 +0000
committerAndrew Turner <andrew@FreeBSD.org>2020-10-13 10:26:15 +0000
commitf56a08c810a555a218f11aa172ed40f6a8dc3a5c (patch)
tree4185973fb494986c00171587e68f0a7404ddbaef /tests
parent2cef3afd7b50b18d30085f5943c09b061215a75f (diff)
downloadsrc-f56a08c810a555a218f11aa172ed40f6a8dc3a5c.tar.gz
src-f56a08c810a555a218f11aa172ed40f6a8dc3a5c.zip
Fix write only mappings on arm64
When trapping on a wrote access to a buffer the kernel has mapped as write only we should only pass the VM_PROT_WRITE flag. Previously the call to vm_fault_trap as the VM_PROT_READ flag was unexpected. Reported by: manu Sponsored by: Innovate UK
Notes
Notes: svn path=/head/; revision=366665
Diffstat (limited to 'tests')
-rw-r--r--tests/sys/vm/mmap_test.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/sys/vm/mmap_test.c b/tests/sys/vm/mmap_test.c
index afabb5c41b83..61ede96fc49b 100644
--- a/tests/sys/vm/mmap_test.c
+++ b/tests/sys/vm/mmap_test.c
@@ -259,6 +259,21 @@ ATF_TC_BODY(mmap__dev_zero_shared, tc)
close(fd);
}
+ATF_TC_WITHOUT_HEAD(mmap__write_only);
+ATF_TC_BODY(mmap__write_only, tc)
+{
+ void *p;
+ int pagesize;
+
+ ATF_REQUIRE((pagesize = getpagesize()) > 0);
+ p = mmap(NULL, pagesize, PROT_WRITE, MAP_ANON, -1, 0);
+ ATF_REQUIRE(p != MAP_FAILED);
+
+ *(volatile uint32_t *)p = 0x12345678;
+
+ munmap(p, pagesize);
+}
+
ATF_TP_ADD_TCS(tp)
{
@@ -266,6 +281,7 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, mmap__bad_arguments);
ATF_TP_ADD_TC(tp, mmap__dev_zero_private);
ATF_TP_ADD_TC(tp, mmap__dev_zero_shared);
+ ATF_TP_ADD_TC(tp, mmap__write_only);
return (atf_no_error());
}