diff options
author | Andrew Waterman <andrew@sifive.com> | 2021-02-10 17:03:03 -0800 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2021-03-25 22:21:06 -0700 |
commit | 817e7d0dfea820a369a5b5c2d5d729942b7daf42 (patch) | |
tree | a725081a6966d928cb9ddacdd2172251ef1691f9 /pk/elf.c | |
parent | b7f64fe5584094a6fe65d94d5e2382ff9289cbda (diff) | |
download | riscv-pk-817e7d0dfea820a369a5b5c2d5d729942b7daf42.zip riscv-pk-817e7d0dfea820a369a5b5c2d5d729942b7daf42.tar.gz riscv-pk-817e7d0dfea820a369a5b5c2d5d729942b7daf42.tar.bz2 |
pk: only access user memory through explicit accessors
Enforced with sstatus.SUM.
Diffstat (limited to 'pk/elf.c')
-rw-r--r-- | pk/elf.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -5,6 +5,7 @@ #include "boot.h" #include "bits.h" #include "elf.h" +#include "usermem.h" #include <sys/stat.h> #include <fcntl.h> #include <string.h> @@ -83,7 +84,7 @@ void load_elf(const char* fn, elf_info* info) int prot = get_prot(ph[i].p_flags); if (__do_mmap(vaddr - prepad, ph[i].p_filesz + prepad, prot | PROT_WRITE, flags2, file, ph[i].p_offset - prepad) != vaddr - prepad) goto fail; - memset((void*)vaddr - prepad, 0, prepad); + memset_user((void*)vaddr - prepad, 0, prepad); if (!(prot & PROT_WRITE)) if (do_mprotect(vaddr - prepad, ph[i].p_filesz + prepad, prot)) goto fail; |