Date: Wed, 3 Jan 2024 16:50:47 GMT From: Brooks Davis <brooks@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: a9174861eab9 - main - posixshm largepage_mmap: fix a racy test Message-ID: <202401031650.403Gollb042346@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=a9174861eab9e786f6873fbe6374a1ac19a5e46a commit a9174861eab9e786f6873fbe6374a1ac19a5e46a Author: Brooks Davis <brooks@FreeBSD.org> AuthorDate: 2024-01-03 16:39:53 +0000 Commit: Brooks Davis <brooks@FreeBSD.org> CommitDate: 2024-01-03 16:39:53 +0000 posixshm largepage_mmap: fix a racy test You can't ever safely map a single page and then map a superpage sized mapping over it with MAP_FIXED. Even in a single-threaded program, ASLR might mean you land too close to another mapping and on CheriBSD we don't allow the initial reservation to grow because doing so requires program changes that are hard to automate. To avoid this, map the entire region we want to use upfront. Reviewed by: markj Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D43282 --- tests/sys/posixshm/posixshm_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/sys/posixshm/posixshm_test.c b/tests/sys/posixshm/posixshm_test.c index efc903d4ee04..ade07a118707 100644 --- a/tests/sys/posixshm/posixshm_test.c +++ b/tests/sys/posixshm/posixshm_test.c @@ -1407,7 +1407,7 @@ ATF_TC_BODY(largepage_mmap, tc) ATF_REQUIRE(munmap(addr, ps[i] == 0)); /* Clobber an anonymous mapping with a superpage. */ - addr1 = mmap(NULL, ps[0], PROT_READ | PROT_WRITE, + addr1 = mmap(NULL, ps[i], PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_ALIGNED(ffsl(ps[i]) - 1), -1, 0); ATF_REQUIRE_MSG(addr1 != MAP_FAILED,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401031650.403Gollb042346>