add ARG_MMAP for routines that operate on mappings we're going to track.
[trinity.git] / syscalls / mprotect.c
blob606f13c600d1883c8fb7363a24d7f9b612bb453c
1 /*
2 * sys_mprotect(unsigned long start, size_t len, unsigned long prot)
3 */
4 #include <asm/mman.h>
5 #include "trinity.h" // page_size
6 #include "arch.h"
7 #include "random.h"
8 #include "sanitise.h"
9 #include "shm.h"
11 static void sanitise_mprotect(int childno)
13 unsigned long end;
15 shm->a1[childno] &= PAGE_MASK;
17 retry_end:
18 end = shm->a1[childno] + shm->a2[childno];
19 /* Length must not be zero. */
20 if (shm->a2[childno] == 0) {
21 shm->a2[childno] = rand64();
22 goto retry_end;
25 /* End must be after start */
26 if (end <= shm->a1[childno]) {
27 shm->a2[childno] = rand64();
28 goto retry_end;
32 struct syscall syscall_mprotect = {
33 .name = "mprotect",
34 .num_args = 3,
35 .arg1name = "start",
36 .arg1type = ARG_MMAP,
37 .arg2name = "len",
38 .arg2type = ARG_LEN,
39 .arg3name = "prot",
40 .arg3type = ARG_LIST,
41 .arg3list = {
42 .num = 6,
43 .values = { PROT_READ, PROT_WRITE, PROT_EXEC, PROT_SEM, PROT_GROWSDOWN, PROT_GROWSUP },
45 .sanitise = sanitise_mprotect,
46 .group = GROUP_VM,
48 .flags = AVOID_SYSCALL, // hopefully temporary.