2 * asmlinkage unsigned long sys_mremap(unsigned long addr,
3 * unsigned long old_len, unsigned long new_len,
4 * unsigned long flags, unsigned long new_addr)
9 #include "utils.h" // page_size
17 static unsigned long rand_size(void)
19 const unsigned long sizes
[] = { 1 * MB
, 2 * MB
, 4 * MB
, 10 * MB
, 1 * GB
, 2 * GB
};
21 return sizes
[rand() % ARRAY_SIZE(sizes
)];
24 static void sanitise_mremap(int childno
)
28 map
= common_set_mmap_ptr_len(childno
);
30 shm
->a3
[childno
] = map
->size
; //TODO: Munge this.
32 if (shm
->a4
[childno
] & MREMAP_FIXED
) {
33 shm
->a5
[childno
] = rand_size();
38 /* Sometimes dirty the mapping first. */
39 if (!(map
->prot
& PROT_WRITE
))
47 * If we successfully remapped a range, we need to update our record of it
48 * so we don't re-use the old address.
50 static void post_mremap(int childno
)
52 struct map
*map
= (struct map
*) shm
->scratch
[childno
];
53 void *ptr
= (void *) shm
->retval
[childno
];
55 if (ptr
!= MAP_FAILED
)
58 shm
->scratch
[childno
] = 0;
61 struct syscallentry syscall_mremap
= {
64 .sanitise
= sanitise_mremap
,
67 .arg2name
= "old_len",
68 .arg3name
= "new_len",
73 .values
= { MREMAP_MAYMOVE
, MREMAP_FIXED
},
75 .arg5name
= "new_addr",
76 .arg5type
= ARG_ADDRESS
,