mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-22 19:31:08 +01:00
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
This commit is contained in:
parent
85c9d36497
commit
a9174861ea
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user