PKUOS - Pintos
Pintos source browser for PKU Operating System course
exec-bound-3.c
Go to the documentation of this file.
1/** Invokes an exec system call with the exec string straddling a
2 page boundary such that the first byte of the string is valid
3 but the remainder of the string is in invalid memory. Must
4 kill process. */
5
6#include <syscall-nr.h>
8#include "tests/lib.h"
9#include "tests/main.h"
10
11void
12test_main (void)
13{
14 char *p = get_bad_boundary () - 1;
15 *p = 'a';
16 exec(p);
17
18 /* Note: if this test fails to pass even with the official solutions,
19 it's probably because memory layout has changed and p no longer
20 refers to the proper page boundary. To fix the problem, uncomment
21 the line below to print out the boundary address. In addition,
22 add a printf line in load_segment to print out the address range
23 of each segment. From that, you'll be able to figure out how to
24 modify get_bad_boundary to make things work again. */
25
26 // msg("boundary address: 0x%x", p);
27 fail ("should have killed process");
28}
void * get_bad_boundary(void)
Returns an address that is invalid, but the preceding bytes are all valid (the highest address in the...
Definition: boundary.c:42
void test_main(void)
Invokes an exec system call with the exec string straddling a page boundary such that the first byte ...
Definition: exec-bound-3.c:12
pid_t exec(const char *file)
Definition: syscall.c:79
void fail(const char *format,...)
Definition: lib.c:40