1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
/*
* SYSCALL_DEFINE(sync_file_range)(int fd, loff_t offset, loff_t nbytes, unsigned int flags)
* SYSCALL_DEFINE(sync_file_range2)(int fd, unsigned int flags, loff_t offset, loff_t nbytes)
*/
#include <linux/fs.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include "arch.h"
#include "random.h"
#include "sanitise.h"
#include "shm.h"
#include "tables.h"
struct syscall syscall_sync_file_range;
static void sanitise_sync_file_range(int childno)
{
unsigned int call = shm->syscallno[childno];
struct syscall *syscall_entry = syscalls[call].entry;
long endbyte;
loff_t nbytes;
loff_t off;
retry:
off = rand64() & 0x0fffffffffffffff;
nbytes = rand64() & 0x0fffffffffffffff;
endbyte = off + nbytes;
if (endbyte < off)
goto retry;
if (off >= (0x100000000LL << PAGE_SHIFT))
goto retry;
if (strcmp("sync_file_range2", syscall_entry->name) == 0) {
shm->a2[childno] = off;
shm->a3[childno] = nbytes;
} else {
shm->a3[childno] = off;
shm->a4[childno] = nbytes;
}
}
struct syscall syscall_sync_file_range = {
.name = "sync_file_range",
.num_args = 4,
.sanitise = sanitise_sync_file_range,
.arg1name = "fd",
.arg1type = ARG_FD,
.arg2name = "offset",
.arg3name = "nbytes",
.arg3type = ARG_LEN,
.arg4name = "flags",
.arg4type = ARG_LIST,
.arg4list = {
.num = 3,
.values = { SYNC_FILE_RANGE_WAIT_BEFORE, SYNC_FILE_RANGE_WRITE, SYNC_FILE_RANGE_WAIT_AFTER },
},
.flags = NEED_ALARM,
.group = GROUP_VFS,
};
/*
* ARM & PowerPC have different argument order.
* See edd5cd4a9424f22b0fa08bef5e299d41befd5622 in kernel tree.
*/
struct syscall syscall_sync_file_range2 = {
.name = "sync_file_range2",
.num_args = 4,
.sanitise = sanitise_sync_file_range,
.arg1name = "fd",
.arg1type = ARG_FD,
.arg2name = "flags",
.arg2type = ARG_LIST,
.arg2list = {
.num = 3,
.values = { SYNC_FILE_RANGE_WAIT_BEFORE, SYNC_FILE_RANGE_WRITE, SYNC_FILE_RANGE_WAIT_AFTER },
},
.arg3name = "offset",
.arg4name = "nbytes",
.arg4type = ARG_LEN,
.flags = NEED_ALARM,
.group = GROUP_VFS,
};
|