2 * SYSCALL_DEFINE3(execve,
3 * const char __user *, filename,
4 * const char __user *const __user *, argv,
5 * const char __user *const __user *, envp)
7 * On success, execve() does not return
8 * on error -1 is returned, and errno is set appropriately.
10 * TODO: Redirect stdin/stdout.
14 #include "arch.h" // page_size
15 #include "random.h" // generate_random_page
18 #include "trinity.h" // __unused__
20 static unsigned long ** gen_ptrs_to_crap(void)
24 unsigned int count
= rand() % 32;
27 ptr
= malloc(count
* sizeof(void *)); // FIXME: LEAK
31 for (i
= 0; i
< count
; i
++) {
32 ptr
[i
] = malloc(page_size
); // FIXME: LEAK
34 generate_random_page((char *) ptr
[i
]);
37 return (unsigned long **) ptr
;
40 static void sanitise_execve(__unused__
int childno
)
42 /* we don't want to block if something tries to read from stdin */
46 shm
->syscall
[childno
].a2
= (unsigned long) gen_ptrs_to_crap();
49 shm
->syscall
[childno
].a3
= (unsigned long) gen_ptrs_to_crap();
52 struct syscallentry syscall_execve
= {
56 .arg1type
= ARG_PATHNAME
,
58 .arg2type
= ARG_ADDRESS
,
60 .arg3type
= ARG_ADDRESS
,
61 .sanitise
= sanitise_execve
,