diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-10-28 00:34:09 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-11-04 03:41:44 -0500 |
commit | 120f2e5343d5ccd3ad117d530018b75302c6482b (patch) | |
tree | 66b3e392325172021ef79518a0027de2962a2f84 /rts/linker/M32Alloc.h | |
parent | 5d4f16eed151caddf4624ff0a1fc23d5a4475957 (diff) | |
download | haskell-120f2e5343d5ccd3ad117d530018b75302c6482b.tar.gz |
rts/linker: Ensure that code isn't writable
For many years the linker would simply map all of its memory with
PROT_READ|PROT_WRITE|PROT_EXEC. However operating systems have been
becoming increasingly reluctant to accept this practice (e.g. #17353
and #12657) and for good reason: writable code is ripe for exploitation.
Consequently mmapForLinker now maps its memory with
PROT_READ|PROT_WRITE. After the linker has finished filling/relocating
the mapping it must then call mmapForLinkerMarkExecutable on the
sections of the mapping which contain executable code.
Moreover, to make all of this possible it was necessary to redesign the
m32 allocator. First, we gave (in an earlier commit) each ObjectCode its
own m32_allocator. This was necessary since code loading and symbol
resolution/relocation are currently interleaved, meaning that it is not
possible to enforce W^X when symbols from different objects reside in
the same page.
We then redesigned the m32 allocator to take advantage of the fact that
all of the pages allocated with the allocator die at the same time
(namely, when the owning ObjectCode is unloaded). This makes a number of
things simpler (e.g. no more page reference counting; the interface
provided by the allocator for freeing is simpler). See
Note [M32 Allocator] for details.
Diffstat (limited to 'rts/linker/M32Alloc.h')
-rw-r--r-- | rts/linker/M32Alloc.h | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/rts/linker/M32Alloc.h b/rts/linker/M32Alloc.h index 8af9235921..f5ab757b27 100644 --- a/rts/linker/M32Alloc.h +++ b/rts/linker/M32Alloc.h @@ -29,14 +29,12 @@ struct m32_allocator_t; typedef struct m32_allocator_t m32_allocator; -m32_allocator *m32_allocator_new(void) M32_NO_RETURN; +m32_allocator *m32_allocator_new(bool executable) M32_NO_RETURN; void m32_allocator_free(m32_allocator *alloc) M32_NO_RETURN; void m32_allocator_flush(m32_allocator *alloc) M32_NO_RETURN; -void m32_free(void *addr, size_t size) M32_NO_RETURN; - void * m32_alloc(m32_allocator *alloc, size_t size, size_t alignment) M32_NO_RETURN; #include "EndPrivate.h" |