summaryrefslogtreecommitdiff
path: root/kernel/exec.c
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2022-08-12 13:22:10 -0400
committerFrans Kaashoek <[email protected]>2022-08-12 13:22:10 -0400
commit899cc02660232092209a5db57b326ab7b49813dd (patch)
treeabde95c343fb06294fba1c30036a3d6564602693 /kernel/exec.c
parent8f58cc7df99e9f697ca3843886802ecab5cb8991 (diff)
downloadxv6-labs-899cc02660232092209a5db57b326ab7b49813dd.tar.gz
xv6-labs-899cc02660232092209a5db57b326ab7b49813dd.tar.bz2
xv6-labs-899cc02660232092209a5db57b326ab7b49813dd.zip
Experiment with being more precise setting permissions for user pages.
Growing adds R|W pages (without X). Exec() marks the stack only R|W. Probably could setup permissions for text and data better if we call ld with --no-omagic instead of -N.
Diffstat (limited to 'kernel/exec.c')
-rw-r--r--kernel/exec.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/exec.c b/kernel/exec.c
index 09b4bdc..3c468e1 100644
--- a/kernel/exec.c
+++ b/kernel/exec.c
@@ -49,7 +49,7 @@ exec(char *path, char **argv)
if(ph.vaddr + ph.memsz < ph.vaddr)
goto bad;
uint64 sz1;
- if((sz1 = uvmalloc(pagetable, sz, ph.vaddr + ph.memsz)) == 0)
+ if((sz1 = uvmalloc(pagetable, sz, ph.vaddr + ph.memsz, PTE_X|PTE_W)) == 0)
goto bad;
sz = sz1;
if((ph.vaddr % PGSIZE) != 0)
@@ -69,7 +69,7 @@ exec(char *path, char **argv)
// Use the second as the user stack.
sz = PGROUNDUP(sz);
uint64 sz1;
- if((sz1 = uvmalloc(pagetable, sz, sz + 2*PGSIZE)) == 0)
+ if((sz1 = uvmalloc(pagetable, sz, sz + 2*PGSIZE, PTE_W)) == 0)
goto bad;
sz = sz1;
uvmclear(pagetable, sz-2*PGSIZE);