diff options
author | Ben Gamari <ben@smart-cactus.org> | 2021-04-19 14:07:21 -0400 |
---|---|---|
committer | Zubin Duggal <zubin.duggal@gmail.com> | 2021-08-05 02:32:19 +0530 |
commit | f0cdbcce9718052f89700619556d69e6032f0b1c (patch) | |
tree | 4797093ca57cee760c58cecf74fbd2e82c9a1467 | |
parent | 62311a7f72c0c7b66a7629e3399070ec3dddf4ba (diff) | |
download | haskell-f0cdbcce9718052f89700619556d69e6032f0b1c.tar.gz |
rts/m32: Fix bounds check
Previously we would check only that the *start* of the mapping was in
the bottom 32-bits of address space. However, we need the *entire*
mapping to be in low memory. Fix this.
Noticed by @Phyx.
-rw-r--r-- | rts/linker/M32Alloc.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/rts/linker/M32Alloc.c b/rts/linker/M32Alloc.c index d0e4df14dc..9f745c2608 100644 --- a/rts/linker/M32Alloc.c +++ b/rts/linker/M32Alloc.c @@ -263,8 +263,9 @@ m32_alloc_page(void) * pages. */ const size_t pgsz = getPageSize(); - uint8_t *chunk = mmapAnonForLinker(pgsz * M32_MAP_PAGES); - if (chunk > (uint8_t *) 0xffffffff) { + const size_t map_sz = pgsz * M32_MAP_PAGES; + uint8_t *chunk = mmapAnonForLinker(map_sz); + if (chunk + map_sz > (uint8_t *) 0xffffffff) { barf("m32_alloc_page: failed to get allocation in lower 32-bits"); } |