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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
/*
* SYSCALL_DEFINE3(read, unsigned int, fd, char __user *, buf, size_t, count)
*/
#include <stdlib.h>
#include <string.h>
#include "arch.h"
#include "maps.h"
#include "random.h"
#include "sanitise.h"
#include "shm.h"
#include "syscall.h"
#include "trinity.h"
#include "compat.h"
static void sanitise_read(struct syscallrecord *rec)
{
rec->a2 = (unsigned long) get_non_null_address();
if (RAND_BOOL())
rec->a3 = rnd() % page_size;
else
rec->a3 = page_size;
}
struct syscallentry syscall_read = {
.name = "read",
.num_args = 3,
.sanitise = sanitise_read,
.arg1name = "fd",
.arg1type = ARG_FD,
.arg2name = "buf",
.arg2type = ARG_ADDRESS,
.arg3name = "count",
.arg3type = ARG_LEN,
.flags = NEED_ALARM,
};
/*
* SYSCALL_DEFINE3(readv, unsigned long, fd, const struct iovec __user *, vec, unsigned long>
*/
struct syscallentry syscall_readv = {
.name = "readv",
.num_args = 3,
.arg1name = "fd",
.arg1type = ARG_FD,
.arg2name = "vec",
.arg2type = ARG_IOVEC,
.arg3name = "vlen",
.arg3type = ARG_IOVECLEN,
.flags = NEED_ALARM,
};
/*
* SYSCALL_DEFINE(pread64)(unsigned int fd, char __user *buf, size_t count, loff_t pos)
*/
static void sanitise_pread64(struct syscallrecord *rec)
{
rec->a3 = rnd() % page_size;
retry_pos:
if ((int) rec->a4 < 0) {
rec->a4 = rand64();
goto retry_pos;
}
}
struct syscallentry syscall_pread64 = {
.name = "pread64",
.num_args = 4,
.sanitise = sanitise_pread64,
.arg1name = "fd",
.arg1type = ARG_FD,
.arg2name = "buf",
.arg2type = ARG_ADDRESS,
.arg3name = "count",
.arg3type = ARG_LEN,
.arg4name = "pos",
.flags = NEED_ALARM,
};
/*
* SYSCALL_DEFINE5(preadv, unsigned long, fd, const struct iovec __user *, vec,
unsigned long, vlen, unsigned long, pos_l, unsigned long, pos_h)
*/
struct syscallentry syscall_preadv = {
.name = "preadv",
.num_args = 5,
.arg1name = "fd",
.arg1type = ARG_FD,
.arg2name = "vec",
.arg2type = ARG_IOVEC,
.arg3name = "vlen",
.arg3type = ARG_IOVECLEN,
.arg4name = "pos_l",
.arg5name = "pos_h",
.flags = NEED_ALARM,
};
/*
* SYSCALL_DEFINE5(preadv2, unsigned long, fd, const struct iovec __user *, vec,
unsigned long, vlen, unsigned long, pos_l, unsigned long, pos_h,
int, flags)
*/
static unsigned long preadv2_flags[] = {
RWF_HIPRI, RWF_DSYNC, RWF_SYNC,
};
struct syscallentry syscall_preadv2 = {
.name = "preadv2",
.num_args = 6,
.arg1name = "fd",
.arg1type = ARG_FD,
.arg2name = "vec",
.arg2type = ARG_IOVEC,
.arg3name = "vlen",
.arg3type = ARG_IOVECLEN,
.arg4name = "pos_l",
.arg5name = "pos_h",
.arg6name = "flags",
.arg6type = ARG_LIST,
.arg6list = ARGLIST(preadv2_flags),
.flags = NEED_ALARM,
};
|