summaryrefslogtreecommitdiff
path: root/exec.c
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2011-09-01 13:25:34 -0400
committerRobert Morris <[email protected]>2011-09-01 13:25:34 -0400
commit371ab7fa96f8e439f4008c973c37aa44ab6ed81e (patch)
tree1c43722ff54ff90494689ae4202ba2a2a8bd5dcc /exec.c
parent62e3b8a92c6f8840cec8a0db13b2bcad10192b4a (diff)
downloadxv6-labs-371ab7fa96f8e439f4008c973c37aa44ab6ed81e.tar.gz
xv6-labs-371ab7fa96f8e439f4008c973c37aa44ab6ed81e.tar.bz2
xv6-labs-371ab7fa96f8e439f4008c973c37aa44ab6ed81e.zip
inaccessible page under the user stack page, to help exec deal w/ too-large args
Diffstat (limited to 'exec.c')
-rw-r--r--exec.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/exec.c b/exec.c
index dfff3e6..af9e006 100644
--- a/exec.c
+++ b/exec.c
@@ -49,13 +49,16 @@ exec(char *path, char **argv)
iunlockput(ip);
ip = 0;
- // Allocate a one-page stack at the next page boundary
+ // Allocate two pages at the next page boundary.
+ // Make the first inaccessible.
+ // Use the second as the user stack.
sz = PGROUNDUP(sz);
- if((sz = allocuvm(pgdir, sz, sz + PGSIZE)) == 0)
+ if((sz = allocuvm(pgdir, sz, sz + 2*PGSIZE)) == 0)
goto bad;
+ clear_pte_u(pgdir, (char*)(sz-2*PGSIZE));
+ sp = sz;
// Push argument strings, prepare rest of stack in ustack.
- sp = sz;
for(argc = 0; argv[argc]; argc++) {
if(argc >= MAXARG)
goto bad;