diff options
author | Andrew Waterman <andrew@sifive.com> | 2024-04-17 14:58:31 -0700 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2024-04-17 14:58:31 -0700 |
commit | 6b5c8dbb6f40eacbce5b698e957630e56ec30879 (patch) | |
tree | cd003f0734ad76ecc9ddf7333ed2ffdda410b396 /pk | |
parent | c917315bf7a91e897f6464c62bdda01f9635536a (diff) | |
download | pk-6b5c8dbb6f40eacbce5b698e957630e56ec30879.zip pk-6b5c8dbb6f40eacbce5b698e957630e56ec30879.tar.gz pk-6b5c8dbb6f40eacbce5b698e957630e56ec30879.tar.bz2 |
mprotect whole ELF segment, not just file portion
Diffstat (limited to 'pk')
-rw-r--r-- | pk/elf.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -89,13 +89,13 @@ void load_elf(const char* fn, elf_info* info) goto fail; } memset_user((void*)vaddr - prepad, 0, prepad); - if (!(prot & PROT_WRITE)) - if (do_mprotect(vaddr - prepad, ph[i].p_filesz + prepad, prot)) - goto fail; size_t mapped = ROUNDUP(ph[i].p_filesz + prepad, RISCV_PGSIZE) - prepad; if (ph[i].p_memsz > mapped) if (__do_mmap(vaddr + mapped, ph[i].p_memsz - mapped, prot, flags|MAP_ANONYMOUS, 0, 0) != vaddr + mapped) goto fail; + if (!(prot & PROT_WRITE)) + if (do_mprotect(vaddr - prepad, ph[i].p_memsz + prepad, prot)) + goto fail; } } |