1 /* Utility function for tests that try to break system calls by
2 passing them data that crosses from one virtual page to
8 #include "tests/userprog/boundary.h"
10 /* Together with statements in src/lib/user/user.lds, arranges
11 for the following array to be at the very end of the .bss
12 segment (needed for get_bad_boundary below). */
13 static char dst[8192] __attribute__ ((section (".testEndmem,\"aw\",@nobits#")));
15 /* Returns the beginning of a page. There are at least 2048
16 modifiable bytes on either side of the pointer returned. */
18 get_boundary_area (void)
20 char *p = (char *) ROUND_UP ((uintptr_t) dst, 4096);
26 /* Returns a copy of SRC split across the boundary between two
29 copy_string_across_boundary (const char *src)
31 char *p = get_boundary_area ();
32 p -= strlen (src) < 4096 ? strlen (src) / 2 : 4096;
33 strlcpy (p, src, 4096);
37 /* Returns an address that is invalid, but the preceding bytes
38 * are all valid (the highest address in the bss segment). Used
39 * to position information such that the first byte of the
40 * information is valid, but not all the information is valid. */
42 get_bad_boundary (void)
44 /* This code assumes that dst will be in the highest page
45 * allocated to the user process. */
46 return (void *) ROUND_UP ((uintptr_t) (dst + sizeof(dst) - 1), 4096);