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)
16 static unsigned long rand_size(void)
18 const unsigned long sizes
[] = { 1 * MB
, 2 * MB
, 4 * MB
, 10 * MB
, 1 * GB
, 2 * GB
};
20 return sizes
[rand() % ARRAY_SIZE(sizes
)];
23 static void sanitise_mremap(int childno
)
27 map
= common_set_mmap_ptr_len(childno
);
29 shm
->syscall
[childno
].a3
= map
->size
; //TODO: Munge this.
31 if (shm
->syscall
[childno
].a4
& MREMAP_FIXED
) {
32 shm
->syscall
[childno
].a5
= rand_size();
34 shm
->syscall
[childno
].a5
= 0;
37 /* Sometimes dirty the mapping first. */
38 if (!(map
->prot
& PROT_WRITE
))
46 * If we successfully remapped a range, we need to update our record of it
47 * so we don't re-use the old address.
49 static void post_mremap(int childno
)
51 struct map
*map
= (struct map
*) shm
->scratch
[childno
];
52 void *ptr
= (void *) shm
->syscall
[childno
].retval
;
54 if (ptr
!= MAP_FAILED
)
57 shm
->scratch
[childno
] = 0;
60 struct syscallentry syscall_mremap
= {
63 .sanitise
= sanitise_mremap
,
66 .arg2name
= "old_len",
67 .arg3name
= "new_len",
72 .values
= { MREMAP_MAYMOVE
, MREMAP_FIXED
},
74 .arg5name
= "new_addr",
75 .arg5type
= ARG_ADDRESS
,