11 static const unsigned long o_flags
[] = {
12 O_EXCL
, O_NOCTTY
, O_TRUNC
, O_APPEND
,
13 O_NONBLOCK
, O_SYNC
, O_ASYNC
, O_DIRECTORY
,
14 O_NOFOLLOW
, O_CLOEXEC
, O_DIRECT
, O_NOATIME
,
15 O_PATH
, O_DSYNC
, O_LARGEFILE
, O_TMPFILE
,
19 * Choose a random number of file flags to OR into the mask.
20 * also used in files.c:open_file()
22 unsigned long get_o_flags(void)
26 mask
= set_rand_bitmask(ARRAY_SIZE(o_flags
), o_flags
);
32 * SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, int, mode)
34 static void sanitise_open(int childno
);
36 struct syscallentry syscall_open
= {
39 .arg1name
= "filename",
40 .arg1type
= ARG_PATHNAME
,
45 .values
= { O_RDONLY
, O_WRONLY
, O_RDWR
, O_CREAT
, },
48 .arg3type
= ARG_MODE_T
,
49 .sanitise
= sanitise_open
,
52 static void sanitise_open(int childno
)
56 flags
= get_o_flags();
58 shm
->syscall
[childno
].a2
|= flags
;
62 * SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags, int, mode)
64 static void sanitise_openat(int childno
);
66 struct syscallentry syscall_openat
= {
71 .arg2name
= "filename",
72 .arg2type
= ARG_PATHNAME
,
77 .values
= { O_RDONLY
, O_WRONLY
, O_RDWR
, O_CREAT
, },
80 .arg4type
= ARG_MODE_T
,
82 .sanitise
= sanitise_openat
,
85 static void sanitise_openat(int childno
)
89 flags
= get_o_flags();
91 shm
->syscall
[childno
].a3
|= flags
;
95 * SYSCALL_DEFINE3(open_by_handle_at, int, mountdirfd,
96 * struct file_handle __user *, handle,
99 struct syscallentry syscall_open_by_handle_at
= {
100 .name
= "open_by_handle_at",
102 .arg1name
= "mountdirfd",
104 .arg2name
= "handle",
105 .arg2type
= ARG_ADDRESS
,
110 .values
= { O_RDONLY
, O_WRONLY
, O_RDWR
, O_CREAT
, },
113 .sanitise
= sanitise_openat
, // For now we only sanitise .flags, which is also arg3