diff options
author | Andrew Waterman <andrew@sifive.com> | 2024-04-17 14:58:31 -0700 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2024-05-20 18:37:48 -0700 |
commit | 86ed1b3b062bc81c2f42d6676a71cfba52880915 (patch) | |
tree | 6cd428095a1df16c417b4f7ad12f4a5ad8f395ba /pk | |
parent | dd86101e7148e95f60eeb58a498b0ab6be8829dd (diff) | |
download | riscv-pk-86ed1b3b062bc81c2f42d6676a71cfba52880915.zip riscv-pk-86ed1b3b062bc81c2f42d6676a71cfba52880915.tar.gz riscv-pk-86ed1b3b062bc81c2f42d6676a71cfba52880915.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; } } |