aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos Margiolis <christos@FreeBSD.org>2026-06-12 06:20:26 +0000
committerChristos Margiolis <christos@FreeBSD.org>2026-06-20 19:04:50 +0000
commit730eaf466493315c1d1164eb6b59b14766f49322 (patch)
tree6da8cdd946f6907b44d169ac615b28bf15c67587
parent47efa8128268c35ac8f0a552d7a7ce43cd1c5925 (diff)
sound tests: Add PROT_EXEC rejection test
Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: markj, kib Pull-Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/30
-rw-r--r--tests/sys/sound/mmap.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/sys/sound/mmap.c b/tests/sys/sound/mmap.c
index b44b16e7f312..e83193db9bc1 100644
--- a/tests/sys/sound/mmap.c
+++ b/tests/sys/sound/mmap.c
@@ -102,10 +102,38 @@ ATF_TC_BODY(mmap_buffer_lifetime, tc)
ATF_REQUIRE(munmap(buf, len) == 0);
}
+ATF_TC(mmap_reject_prot_exec);
+ATF_TC_HEAD(mmap_reject_prot_exec, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "mmap PROT_EXEC rejection test");
+ atf_tc_set_md_var(tc, "require.kmods", "snd_dummy");
+}
+
+ATF_TC_BODY(mmap_reject_prot_exec, tc)
+{
+ uint8_t *buf;
+ size_t len;
+ int fd;
+
+ fd = open("/dev/dsp.dummy", O_RDWR);
+ ATF_REQUIRE_MSG(fd >= 0, FMT_ERR("open"));
+
+ len = 8;
+
+ buf = mmap(NULL, len, PROT_READ | PROT_EXEC | PROT_EXEC, MAP_SHARED,
+ fd, 0);
+ ATF_REQUIRE_MSG(buf == MAP_FAILED, FMT_ERR("mmap"));
+
+ munmap(buf, len);
+
+ close(fd);
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, mmap_offset_overflow);
ATF_TP_ADD_TC(tp, mmap_buffer_lifetime);
+ ATF_TP_ADD_TC(tp, mmap_reject_prot_exec);
return (atf_no_error());
}