File tree 3 files changed +14
-7
lines changed
3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -75,17 +75,17 @@ exec(char *path, char **argv)
75
75
p = myproc ();
76
76
uint64 oldsz = p -> sz ;
77
77
78
- // Allocate two pages at the next page boundary.
78
+ // Allocate some pages at the next page boundary.
79
79
// Make the first inaccessible as a stack guard.
80
- // Use the second as the user stack.
80
+ // Use the rest as the user stack.
81
81
sz = PGROUNDUP (sz );
82
82
uint64 sz1 ;
83
- if ((sz1 = uvmalloc (pagetable , sz , sz + 2 * PGSIZE , PTE_W )) == 0 )
83
+ if ((sz1 = uvmalloc (pagetable , sz , sz + ( USERSTACK + 1 ) * PGSIZE , PTE_W )) == 0 )
84
84
goto bad ;
85
85
sz = sz1 ;
86
- uvmclear (pagetable , sz - 2 * PGSIZE );
86
+ uvmclear (pagetable , sz - ( USERSTACK + 1 ) * PGSIZE );
87
87
sp = sz ;
88
- stackbase = sp - PGSIZE ;
88
+ stackbase = sp - USERSTACK * PGSIZE ;
89
89
90
90
// Push argument strings, prepare rest of stack in ustack.
91
91
for (argc = 0 ; argv [argc ]; argc ++ ) {
Original file line number Diff line number Diff line change 11
11
#define NBUF (MAXOPBLOCKS*3) // size of disk block cache
12
12
#define FSSIZE 2000 // size of file system in blocks
13
13
#define MAXPATH 128 // maximum file path name
14
+ #define USERSTACK 1 // user stack pages
15
+
Original file line number Diff line number Diff line change @@ -2310,9 +2310,14 @@ bigargtest(char *s)
2310
2310
if (pid == 0 ){
2311
2311
static char * args [MAXARG ];
2312
2312
int i ;
2313
+ char big [400 ];
2314
+ memset (big , ' ' , sizeof (big ));
2315
+ big [sizeof (big )- 1 ] = '\0' ;
2313
2316
for (i = 0 ; i < MAXARG - 1 ; i ++ )
2314
- args [i ] = "bigargs test: failed\n " ;
2317
+ args [i ] = big ;
2315
2318
args [MAXARG - 1 ] = 0 ;
2319
+ // this exec() should fail (and return) because the
2320
+ // arguments are too large.
2316
2321
exec ("echo" , args );
2317
2322
fd = open ("bigarg-ok" , O_CREATE );
2318
2323
close (fd );
@@ -2409,7 +2414,7 @@ stacktest(char *s)
2409
2414
pid = fork ();
2410
2415
if (pid == 0 ) {
2411
2416
char * sp = (char * ) r_sp ();
2412
- sp -= PGSIZE ;
2417
+ sp -= USERSTACK * PGSIZE ;
2413
2418
// the *sp should cause a trap.
2414
2419
printf ("%s: stacktest: read below stack %d\n" , s , * sp );
2415
2420
exit (1 );
You can’t perform that action at this time.
0 commit comments