diff options
author | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2022-10-25 11:20:48 +0100 |
---|---|---|
committer | Szabolcs Nagy <szabolcs.nagy@arm.com> | 2022-11-22 14:31:25 +0000 |
commit | 8e860da0db41471ac5a4c68b4838308c13ba5f41 (patch) | |
tree | bd491886dca244ac9375a19c6a12b0d565c3fe2d /locale | |
parent | cb78f7d9d3cfd05d71208d199dafdb28ea05a92c (diff) | |
download | glibc-8e860da0db41471ac5a4c68b4838308c13ba5f41.tar.gz glibc-8e860da0db41471ac5a4c68b4838308c13ba5f41.tar.xz glibc-8e860da0db41471ac5a4c68b4838308c13ba5f41.zip |
cheri: Fix capability permissions of PROT_NONE map in locarchive
Diffstat (limited to 'locale')
-rw-r--r-- | locale/programs/locarchive.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c index eeb2fa6ffe..81a980b60b 100644 --- a/locale/programs/locarchive.c +++ b/locale/programs/locarchive.c @@ -84,6 +84,13 @@ static const char *locnames[] = /* Size of the reserved address space area. */ #define RESERVE_MMAP_SIZE 512 * 1024 * 1024 +/* On CHERI targets ensure the mmap returned capability has RW permissions. */ +#ifdef PROT_MAX +# define PROT_MAX_RW PROT_MAX (PROT_READ | PROT_WRITE) +#else +# define PROT_MAX_RW 0 +#endif + /* To prepare for enlargements of the mmaped area reserve some address space. On some machines, being a file mapping rather than an anonymous mapping affects the address selection. So do this mapping from the @@ -94,7 +101,8 @@ prepare_address_space (int fd, size_t total, size_t *reserved, int *xflags, { if (total < RESERVE_MMAP_SIZE) { - void *p = mmap64 (NULL, RESERVE_MMAP_SIZE, PROT_NONE, MAP_SHARED, fd, 0); + void *p = mmap64 (NULL, RESERVE_MMAP_SIZE, + PROT_NONE | PROT_MAX_RW, MAP_SHARED, fd, 0); if (p != MAP_FAILED) { void *aligned_p = PTR_ALIGN_UP (p, MAP_FIXED_ALIGNMENT); |