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/mmap.c | |
parent | b7f64fe5584094a6fe65d94d5e2382ff9289cbda (diff) | |
download | pk-817e7d0dfea820a369a5b5c2d5d729942b7daf42.zip pk-817e7d0dfea820a369a5b5c2d5d729942b7daf42.tar.gz pk-817e7d0dfea820a369a5b5c2d5d729942b7daf42.tar.bz2 |
pk: only access user memory through explicit accessors
Enforced with sstatus.SUM.
Diffstat (limited to 'pk/mmap.c')
-rw-r--r-- | pk/mmap.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -175,6 +175,7 @@ static int __handle_page_fault(uintptr_t vaddr, int prot) else if (!(*pte & PTE_V)) { uintptr_t ppn = vpn + (first_free_paddr / RISCV_PGSIZE); + uintptr_t kva = ppn * RISCV_PGSIZE; vmr_t* v = (vmr_t*)*pte; *pte = pte_create(ppn, prot_to_type(PROT_READ|PROT_WRITE, 0)); @@ -182,7 +183,7 @@ static int __handle_page_fault(uintptr_t vaddr, int prot) if (v->file) { size_t flen = MIN(RISCV_PGSIZE, v->length - (vaddr - v->addr)); - ssize_t ret = file_pread(v->file, (void*)vaddr, flen, vaddr - v->addr + v->offset); + ssize_t ret = file_pread(v->file, (void*)kva, flen, vaddr - v->addr + v->offset); kassert(ret > 0); if (ret < RISCV_PGSIZE) memset((void*)vaddr + ret, 0, RISCV_PGSIZE - ret); |