Clear U bit for second stack page so that it functions as a guard page
This commit is contained in:
parent
38b430687c
commit
b2e9c8eea5
|
@ -192,9 +192,10 @@ void unmappages(pagetable_t, uint64, uint64, int);
|
|||
uint64 walkaddr(pagetable_t, uint64);
|
||||
int copyout(pagetable_t, uint64, char *, uint64);
|
||||
int copyin(pagetable_t, char *, uint64, uint64);
|
||||
int copyinstr(pagetable_t pagetable, char *dst, uint64 srcva, uint64 max);
|
||||
int copyinstr(pagetable_t, char *, uint64, uint64);
|
||||
char* map_kstack();
|
||||
uint64 kernelpa(uint64);
|
||||
void clearpteu(pagetable_t, uint64);
|
||||
|
||||
// plic.c
|
||||
void plicinit(void);
|
||||
|
|
|
@ -68,6 +68,7 @@ exec(char *path, char **argv)
|
|||
sz = PGROUNDUP(sz);
|
||||
if((sz = uvmalloc(pagetable, sz, sz + 2*PGSIZE)) == 0)
|
||||
goto bad;
|
||||
clearpteu(pagetable, sz-2*PGSIZE);
|
||||
sp = sz;
|
||||
stackbase = sp - PGSIZE;
|
||||
|
||||
|
|
10
kernel/vm.c
10
kernel/vm.c
|
@ -436,3 +436,13 @@ kernelpa(uint64 va) {
|
|||
pa = PTE2PA(*pte);
|
||||
return pa+off;
|
||||
}
|
||||
|
||||
void
|
||||
clearpteu(pagetable_t pagetable, uint64 va) {
|
||||
pte_t *pte;
|
||||
|
||||
pte = walk(pagetable, va, 0);
|
||||
if(pte == 0)
|
||||
panic("clearpteu");
|
||||
*pte &= ~PTE_U;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue