syscall_desc.c 16.4 KB
Newer Older
Gabor Buella's avatar
Gabor Buella committed
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
/*
 * Copyright 2017, Intel Corporation
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in
 *       the documentation and/or other materials provided with the
 *       distribution.
 *
 *     * Neither the name of the copyright holder nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "syscall_desc.h"

#include <stddef.h>
#include <syscall.h>
37
#include <fcntl.h>
Gabor Buella's avatar
Gabor Buella committed
38 39 40 41

#define SARGS(name, r, ...) \
	[SYS_##name] = {#name, r, {__VA_ARGS__, }}

42
/* Linux syscalls on X86_64 */
Gabor Buella's avatar
Gabor Buella committed
43 44 45
static const struct syscall_desc table[] = {
	SARGS(read, rdec, arg_fd, arg_, arg_),
	SARGS(write, rdec, arg_fd, arg_, arg_),
46
	SARGS(open, rdec, arg_cstr, arg_open_flags, arg_mode),
Gabor Buella's avatar
Gabor Buella committed
47 48 49 50 51 52 53 54 55 56 57 58
	SARGS(close, rdec, arg_fd),
	SARGS(stat, rdec, arg_cstr, arg_),
	SARGS(fstat, rdec, arg_fd, arg_),
	SARGS(lstat, rdec, arg_cstr, arg_),
	SARGS(poll, rdec, arg_, arg_, arg_),
	SARGS(lseek, rdec, arg_fd, arg_, arg_),
	SARGS(mmap, rhex, arg_, arg_, arg_, arg_, arg_fd, arg_),
	SARGS(mprotect, rdec, arg_, arg_, arg_),
	SARGS(munmap, rdec, arg_, arg_, arg_, arg_, arg_fd, arg_),
	SARGS(brk, rdec, arg_),
	SARGS(rt_sigaction, rdec, arg_, arg_, arg_),
	SARGS(rt_sigprocmask, rdec, arg_, arg_, arg_, arg_),
59
	SARGS(rt_sigreturn, rnoreturn, arg_none),
Gabor Buella's avatar
Gabor Buella committed
60 61 62 63 64
	SARGS(ioctl, rdec, arg_fd, arg_, arg_),
	SARGS(pread64, rdec, arg_fd, arg_, arg_, arg_),
	SARGS(pwrite64, rdec, arg_fd, arg_, arg_, arg_),
	SARGS(readv, rdec, arg_fd, arg_, arg_),
	SARGS(writev, rdec, arg_fd, arg_, arg_),
65
	SARGS(access, rdec, arg_cstr, arg_mode),
Gabor Buella's avatar
Gabor Buella committed
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
	SARGS(pipe, rdec, arg_),
	SARGS(select, rdec, arg_, arg_, arg_, arg_, arg_),
	SARGS(sched_yield, rdec, arg_none),
	SARGS(mremap, rhex, arg_, arg_, arg_, arg_, arg_),
	SARGS(msync, rdec, arg_, arg_, arg_),
	SARGS(mincore, rdec, arg_, arg_, arg_),
	SARGS(madvise, rdec, arg_, arg_, arg_),
	SARGS(shmget, rdec, arg_, arg_, arg_),
	SARGS(shmat, rhex, arg_, arg_, arg_),
	SARGS(shmctl, rdec, arg_, arg_, arg_),
	SARGS(dup, rdec, arg_fd),
	SARGS(dup2, rdec, arg_fd, arg_fd),
	SARGS(pause, rdec, arg_none),
	SARGS(nanosleep, rdec, arg_, arg_),
	SARGS(getitimer, rdec, arg_, arg_),
	SARGS(alarm, runsigned, arg_),
	SARGS(setitimer, rdec, arg_, arg_, arg_),
	SARGS(getpid, rdec, arg_none),
	SARGS(sendfile, rdec, arg_fd, arg_fd, arg_, arg_),
	SARGS(socket, rdec, arg_, arg_, arg_),
	SARGS(connect, rdec, arg_fd, arg_, arg_),
	SARGS(accept, rdec, arg_fd, arg_, arg_),
	SARGS(sendto, rdec, arg_fd, arg_, arg_, arg_),
	SARGS(recvfrom, rdec, arg_fd, arg_, arg_, arg_, arg_, arg_),
	SARGS(sendmsg, rdec, arg_fd, arg_, arg_),
	SARGS(recvmsg, rdec, arg_fd, arg_, arg_),
	SARGS(shutdown, rdec, arg_fd, arg_),
	SARGS(bind, rdec, arg_fd, arg_, arg_),
	SARGS(listen, rdec, arg_fd, arg_),
	SARGS(getsockname, rdec, arg_fd, arg_, arg_),
	SARGS(getpeername, rdec, arg_fd, arg_, arg_),
	SARGS(socketpair, rdec, arg_, arg_, arg_, arg_),
	SARGS(setsockopt, rdec, arg_fd, arg_, arg_, arg_, arg_),
	SARGS(getsockopt, rdec, arg_fd, arg_, arg_, arg_, arg_),
	SARGS(clone, rdec, arg_, arg_, arg_, arg_, arg_, arg_),
	SARGS(fork, rdec, arg_none),
	SARGS(vfork, rdec, arg_none),
	SARGS(execve, rdec, arg_, arg_, arg_),
104
	SARGS(exit, rnoreturn, arg_),
Gabor Buella's avatar
Gabor Buella committed
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
	SARGS(wait4, rdec, arg_, arg_, arg_, arg_),
	SARGS(kill, rdec, arg_, arg_),
	SARGS(uname, rdec, arg_),
	SARGS(semget, rdec, arg_, arg_, arg_),
	SARGS(semop, rdec, arg_, arg_, arg_),
	SARGS(semctl, rdec, arg_, arg_, arg_, arg_, arg_, arg_),
	SARGS(shmdt, rdec, arg_),
	SARGS(msgget, rdec, arg_, arg_),
	SARGS(msgsnd, rdec, arg_, arg_, arg_, arg_),
	SARGS(msgrcv, rdec, arg_, arg_, arg_, arg_, arg_),
	SARGS(msgctl, rdec, arg_, arg_, arg_),
	SARGS(fcntl, rdec, arg_fd, arg_, arg_),
	SARGS(flock, rdec, arg_fd, arg_),
	SARGS(fsync, rdec, arg_fd),
	SARGS(fdatasync, rdec, arg_fd),
	SARGS(truncate, rdec, arg_cstr, arg_),
	SARGS(ftruncate, rdec, arg_fd, arg_),
	SARGS(getdents, rdec, arg_fd, arg_, arg_),
	SARGS(getcwd, rdec, arg_, arg_),
	SARGS(chdir, rdec, arg_cstr),
	SARGS(fchdir, rdec, arg_fd),
	SARGS(rename, rdec, arg_cstr, arg_cstr),
127
	SARGS(mkdir, rdec, arg_cstr, arg_mode),
Gabor Buella's avatar
Gabor Buella committed
128
	SARGS(rmdir, rdec, arg_cstr),
129
	SARGS(creat, rdec, arg_cstr, arg_mode),
Gabor Buella's avatar
Gabor Buella committed
130 131 132 133
	SARGS(link, rdec, arg_cstr, arg_cstr),
	SARGS(unlink, rdec, arg_cstr),
	SARGS(symlink, rdec, arg_cstr, arg_cstr),
	SARGS(readlink, rdec, arg_cstr, arg_, arg_),
134 135
	SARGS(chmod, rdec, arg_cstr, arg_mode),
	SARGS(fchmod, rdec, arg_fd, arg_mode),
Gabor Buella's avatar
Gabor Buella committed
136 137 138
	SARGS(chown, rdec, arg_cstr, arg_, arg_),
	SARGS(fchown, rdec, arg_fd, arg_, arg_),
	SARGS(lchown, rdec, arg_cstr, arg_, arg_),
139
	SARGS(umask, rmode, arg_mode),
Gabor Buella's avatar
Gabor Buella committed
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
	SARGS(gettimeofday, rdec, arg_, arg_),
	SARGS(getrlimit, rdec, arg_, arg_),
	SARGS(getrusage, rdec, arg_, arg_),
	SARGS(sysinfo, rdec, arg_, arg_),
	SARGS(times, rdec, arg_),
	SARGS(ptrace, rhex, arg_, arg_, arg_, arg_),
	SARGS(getuid, rdec, arg_none),
	SARGS(syslog, rdec, arg_, arg_, arg_),
	SARGS(getgid, rdec, arg_none),
	SARGS(setuid, rdec, arg_),
	SARGS(setgid, rdec, arg_),
	SARGS(geteuid, rdec, arg_none),
	SARGS(getegid, rdec, arg_none),
	SARGS(setpgid, rdec, arg_none),
	SARGS(getpgrp, rdec, arg_none),
	SARGS(setsid, rdec, arg_none),
	SARGS(setreuid, rdec, arg_, arg_),
	SARGS(setregid, rdec, arg_, arg_),
	SARGS(getgroups, rdec, arg_, arg_),
	SARGS(setgroups, rdec, arg_, arg_),
	SARGS(setresuid, rdec, arg_, arg_, arg_),
	SARGS(getresuid, rdec, arg_, arg_, arg_),
	SARGS(setresgid, rdec, arg_, arg_, arg_),
	SARGS(getresgid, rdec, arg_, arg_, arg_),
	SARGS(getpgid, rdec, arg_),
	SARGS(setfsuid, rdec, arg_),
	SARGS(setfsgid, rdec, arg_),
	SARGS(getsid, rdec, arg_),
	SARGS(capget, rdec, arg_, arg_),
	SARGS(capset, rdec, arg_, arg_),
	SARGS(rt_sigpending, rdec, arg_),
	SARGS(rt_sigtimedwait, rdec, arg_, arg_, arg_, arg_),
	SARGS(rt_sigqueueinfo, rdec, arg_, arg_, arg_),
	SARGS(rt_sigsuspend, rdec, arg_, arg_),
	SARGS(sigaltstack, rdec, arg_, arg_),
	SARGS(utime, rdec, arg_cstr, arg_),
	SARGS(mknod, rdec, arg_cstr, arg_, arg_),
	SARGS(uselib, rdec, arg_cstr),
	SARGS(personality, rdec, arg_),
	SARGS(ustat, rdec, arg_, arg_),
	SARGS(statfs, rdec, arg_cstr, arg_),
	SARGS(fstatfs, rdec, arg_fd, arg_),
	SARGS(sysfs, rdec, arg_, arg_, arg_),
	SARGS(getpriority, rdec, arg_, arg_),
	SARGS(setpriority, rdec, arg_, arg_, arg_),
	SARGS(sched_setparam, rdec, arg_, arg_),
	SARGS(sched_getparam, rdec, arg_, arg_),
	SARGS(sched_setscheduler, rdec, arg_, arg_, arg_),
	SARGS(sched_getscheduler, rdec, arg_),
	SARGS(sched_get_priority_max, rdec, arg_),
	SARGS(sched_get_priority_min, rdec, arg_),
	SARGS(sched_rr_get_interval, rdec, arg_, arg_),
	SARGS(mlock, rdec, arg_, arg_),
	SARGS(munlock, rdec, arg_, arg_),
	SARGS(mlockall, rdec, arg_),
	SARGS(munlockall, rdec, arg_none),
	SARGS(vhangup, rdec, arg_none),
	SARGS(modify_ldt, rdec, arg_, arg_, arg_),
	SARGS(pivot_root, rdec, arg_cstr, arg_),
	SARGS(_sysctl, rdec, arg_),
	SARGS(prctl, rdec, arg_, arg_, arg_, arg_, arg_),
	SARGS(arch_prctl, rdec, arg_, arg_, arg_),
	SARGS(adjtimex, rdec, arg_),
	SARGS(setrlimit, rdec, arg_, arg_),
	SARGS(chroot, rdec, arg_cstr),
	SARGS(sync, rdec, arg_none),
	SARGS(acct, rdec, arg_cstr),
	SARGS(settimeofday, rdec, arg_, arg_),
	SARGS(mount, rdec, arg_cstr, arg_cstr, arg_, arg_, arg_),
	SARGS(umount2, rdec, arg_cstr, arg_),
	SARGS(swapon, rdec, arg_cstr, arg_),
	SARGS(swapoff, rdec, arg_cstr),
	SARGS(reboot, rdec, arg_, arg_, arg_, arg_),
	SARGS(sethostname, rdec, arg_, arg_),
	SARGS(setdomainname, rdec, arg_, arg_),
	SARGS(iopl, rdec, arg_),
	SARGS(ioperm, rdec, arg_, arg_, arg_),
	SARGS(gettid, rdec, arg_none),
	SARGS(readahead, rdec, arg_fd, arg_, arg_),
	SARGS(setxattr, rdec, arg_cstr, arg_cstr, arg_, arg_, arg_),
	SARGS(lsetxattr, rdec, arg_cstr, arg_cstr, arg_, arg_, arg_),
	SARGS(fsetxattr, rdec, arg_fd, arg_cstr, arg_, arg_, arg_),
	SARGS(getxattr, rdec, arg_cstr, arg_cstr, arg_, arg_),
	SARGS(lgetxattr, rdec, arg_cstr, arg_cstr, arg_, arg_),
	SARGS(fgetxattr, rdec, arg_fd, arg_cstr, arg_, arg_),
	SARGS(listxattr, rdec, arg_cstr, arg_, arg_),
	SARGS(llistxattr, rdec, arg_cstr, arg_, arg_),
	SARGS(flistxattr, rdec, arg_cstr, arg_, arg_),
	SARGS(removexattr, rdec, arg_cstr, arg_cstr),
	SARGS(lremovexattr, rdec, arg_cstr, arg_cstr),
	SARGS(fremovexattr, rdec, arg_fd, arg_cstr),
	SARGS(tkill, rdec, arg_, arg_),
	SARGS(time, rdec, arg_),
	SARGS(futex, rdec, arg_, arg_, arg_, arg_, arg_, arg_),
	SARGS(sched_setaffinity, rdec, arg_, arg_, arg_),
	SARGS(sched_getaffinity, rdec, arg_, arg_, arg_),
	SARGS(set_thread_area, rdec, arg_),
	SARGS(io_setup, rdec, arg_, arg_),
	SARGS(io_destroy, rdec, arg_),
	SARGS(io_getevents, rdec, arg_, arg_, arg_, arg_, arg_),
	SARGS(io_submit, rdec, arg_, arg_, arg_),
	SARGS(io_cancel, rdec, arg_, arg_, arg_),
	SARGS(get_thread_area, rdec, arg_),
	SARGS(lookup_dcookie, rdec, arg_, arg_, arg_),
	SARGS(epoll_create, rdec, arg_),
	SARGS(getdents64, rdec, arg_fd, arg_, arg_),
	SARGS(set_tid_address, rdec, arg_),
	SARGS(semtimedop, rdec, arg_, arg_, arg_, arg_),
	SARGS(fadvise64, rdec, arg_fd, arg_, arg_, arg_),
	SARGS(timer_create, rdec, arg_, arg_, arg_),
	SARGS(timer_settime, rdec, arg_, arg_, arg_, arg_),
	SARGS(timer_gettime, rdec, arg_, arg_),
	SARGS(timer_getoverrun, rdec, arg_),
253 254 255 256 257
	SARGS(timer_delete, rdec, arg_),
	SARGS(clock_settime, rdec, arg_, arg_),
	SARGS(clock_gettime, rdec, arg_, arg_),
	SARGS(clock_getres, rdec, arg_, arg_),
	SARGS(clock_nanosleep, rdec, arg_, arg_, arg_, arg_),
258
	SARGS(exit_group, rnoreturn, arg_),
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
	SARGS(epoll_wait, rdec, arg_fd, arg_, arg_, arg_),
	SARGS(epoll_ctl, rdec, arg_fd, arg_, arg_fd, arg_),
	SARGS(tgkill, rdec, arg_, arg_, arg_),
	SARGS(utimes, rdec, arg_cstr, arg_),
	SARGS(mbind, rdec, arg_, arg_, arg_, arg_, arg_),
	SARGS(set_mempolicy, rdec, arg_, arg_, arg_),
	SARGS(get_mempolicy, rdec, arg_, arg_, arg_, arg_, arg_),
	SARGS(mq_open, rdec, arg_cstr, arg_, arg_, arg_, arg_),
	SARGS(mq_unlink, rdec, arg_cstr),
	SARGS(mq_timedsend, rdec, arg_, arg_, arg_, arg_, arg_),
	SARGS(mq_timedreceive, rdec, arg_, arg_, arg_, arg_, arg_),
	SARGS(mq_notify, rdec, arg_, arg_),
	SARGS(mq_getsetattr, rdec, arg_, arg_, arg_),
	SARGS(kexec_load, rdec, arg_, arg_, arg_, arg_),
	SARGS(waitid, rdec, arg_, arg_, arg_, arg_),
	SARGS(add_key, rdec, arg_, arg_, arg_, arg_, arg_),
	SARGS(request_key, rdec, arg_, arg_, arg_, arg_),
	SARGS(keyctl, rdec, arg_, arg_, arg_, arg_, arg_),
	SARGS(ioprio_set, rdec, arg_, arg_, arg_),
	SARGS(ioprio_get, rdec, arg_, arg_),
	SARGS(inotify_init, rdec, arg_none),
	SARGS(inotify_add_watch, rdec, arg_fd, arg_cstr, arg_),
	SARGS(inotify_rm_watch, rdec, arg_fd, arg_),
	SARGS(migrate_pages, rdec, arg_, arg_, arg_, arg_),
283 284 285
	SARGS(openat, rdec, arg_atfd, arg_cstr, arg_open_flags, arg_mode),
	SARGS(mkdirat, rdec, arg_atfd, arg_cstr, arg_mode),
	SARGS(mknodat, rdec, arg_atfd, arg_cstr, arg_mode, arg_),
286 287 288 289 290 291 292 293
	SARGS(fchownat, rdec, arg_atfd, arg_cstr, arg_, arg_, arg_),
	SARGS(futimesat, rdec, arg_atfd, arg_cstr, arg_),
	SARGS(newfstatat, rdec, arg_atfd, arg_cstr, arg_, arg_),
	SARGS(unlinkat, rdec, arg_atfd, arg_cstr, arg_),
	SARGS(renameat, rdec, arg_atfd, arg_cstr, arg_atfd, arg_cstr),
	SARGS(linkat, rdec, arg_atfd, arg_cstr, arg_atfd, arg_cstr, arg_),
	SARGS(symlinkat, rdec, arg_atfd, arg_cstr, arg_cstr),
	SARGS(readlinkat, rdec, arg_atfd, arg_cstr, arg_, arg_),
294 295
	SARGS(fchmodat, rdec, arg_atfd, arg_cstr, arg_mode),
	SARGS(faccessat, rdec, arg_atfd, arg_cstr, arg_mode),
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393
	SARGS(pselect6, rdec, arg_, arg_, arg_, arg_, arg_, arg_),
	SARGS(ppoll, rdec, arg_, arg_, arg_, arg_, arg_),
	SARGS(unshare, rdec, arg_),
	SARGS(set_robust_list, rdec, arg_, arg_),
	SARGS(get_robust_list, rdec, arg_, arg_, arg_),
	SARGS(splice, rdec, arg_fd, arg_, arg_fd, arg_, arg_, arg_),
	SARGS(tee, rdec, arg_fd, arg_fd, arg_, arg_),
	SARGS(sync_file_range, rdec, arg_fd, arg_, arg_, arg_),
	SARGS(vmsplice, rdec, arg_fd, arg_, arg_, arg_),
	SARGS(move_pages, rdec, arg_, arg_, arg_, arg_, arg_, arg_),
	SARGS(utimensat, rdec, arg_atfd, arg_cstr, arg_, arg_),
	SARGS(epoll_pwait, rdec, arg_fd, arg_, arg_, arg_, arg_, arg_),
	SARGS(signalfd, rdec, arg_fd, arg_, arg_),
	SARGS(timerfd_create, rdec, arg_, arg_),
	SARGS(eventfd, rdec, arg_),
	SARGS(fallocate, rdec, arg_fd, arg_, arg_, arg_),
	SARGS(timerfd_settime, rdec, arg_fd, arg_, arg_, arg_),
	SARGS(timerfd_gettime, rdec, arg_fd, arg_),
	SARGS(accept4, rdec, arg_fd, arg_, arg_, arg_, arg_),
	SARGS(signalfd4, rdec, arg_fd, arg_, arg_, arg_, arg_),
	SARGS(eventfd2, rdec, arg_, arg_),
	SARGS(epoll_create1, rdec, arg_),
	SARGS(dup3, rdec, arg_fd, arg_fd, arg_),
	SARGS(pipe2, rdec, arg_, arg_),
	SARGS(inotify_init1, rdec, arg_),
	SARGS(preadv, rdec, arg_fd, arg_, arg_, arg_),
	SARGS(pwritev, rdec, arg_fd, arg_, arg_, arg_),
	SARGS(rt_tgsigqueueinfo, rdec, arg_, arg_, arg_, arg_),
	SARGS(perf_event_open, rdec, arg_, arg_, arg_, arg_, arg_),
	SARGS(recvmmsg, rdec, arg_fd, arg_, arg_, arg_, arg_),
	SARGS(fanotify_init, rdec, arg_, arg_),
	SARGS(fanotify_mark, rdec, arg_, arg_, arg_, arg_, arg_),
	SARGS(prlimit64, rdec, arg_, arg_, arg_, arg_),
	SARGS(name_to_handle_at, rdec, arg_atfd, arg_cstr, arg_, arg_, arg_),
	SARGS(open_by_handle_at, rdec, arg_atfd, arg_cstr, arg_),
	SARGS(clock_adjtime, rdec, arg_, arg_),
	SARGS(syncfs, rdec, arg_fd),
	SARGS(sendmmsg, rdec, arg_fd, arg_, arg_, arg_),
	SARGS(setns, rdec, arg_fd, arg_),
	SARGS(getcpu, rdec, arg_, arg_, arg_),
	SARGS(process_vm_readv, rdec, arg_, arg_, arg_, arg_, arg_, arg_),
	SARGS(process_vm_writev, rdec, arg_, arg_, arg_, arg_, arg_, arg_),
	SARGS(kcmp, rdec, arg_, arg_, arg_, arg_, arg_),
	SARGS(finit_module, rdec, arg_fd, arg_, arg_),
#ifdef SYS_sched_setattr
	SARGS(sched_setattr, rdec, arg_, arg_, arg_),
#endif
#ifdef SYS_sched_getattr
	SARGS(sched_getattr, rdec, arg_, arg_, arg_, arg_),
#endif
#ifdef SYS_renameat2
	SARGS(renameat2, rdec, arg_atfd, arg_cstr, arg_atfd, arg_cstr, arg_),
#endif
#ifdef SYS_seccomp
	SARGS(seccomp, rdec, arg_, arg_, arg_),
#endif
#ifdef SYS_getrandom
	SARGS(getrandom, rdec, arg_, arg_, arg_),
#endif
#ifdef SYS_memfd_create
	SARGS(memfd_create, rdec, arg_cstr, arg_),
#endif
#ifdef SYS_kexec_file_load
	SARGS(kexec_file_load, rdec, arg_, arg_, arg_, arg_, arg_),
#endif
#ifdef SYS_bpf
	SARGS(bpf, rdec, arg_, arg_, arg_),
#endif
#ifdef SYS_execveat
	SARGS(execveat, rdec, arg_atfd, arg_cstr, arg_, arg_, arg_),
#endif
#ifdef SYS_userfaultfd
	SARGS(userfaultfd, rdec, arg_),
#endif
#ifdef SYS_membarrier
	SARGS(membarrier, rdec, arg_, arg_),
#endif
#ifdef SYS_mlock2
	SARGS(mlock2, rdec, arg_, arg_, arg_),
#endif
#ifdef SYS_copy_file_range
	SARGS(copy_file_range, rdec, arg_fd, arg_, arg_fd, arg_, arg_, arg_),
#endif
#ifdef SYS_preadv2
	SARGS(preadv2, rdec, arg_fd, arg_, arg_, arg_, arg_),
#endif
#ifdef SYS_pwritev2
	SARGS(pwritev2, rdec, arg_fd, arg_, arg_, arg_, arg_),
#endif
#ifdef SYS_pkey_mprotect
	SARGS(pkey_mprotect, rdec, arg_, arg_, arg_, arg_),
#endif
#ifdef SYS_pkey_alloc
	SARGS(pkey_alloc, rdec, arg_, arg_),
#endif
#ifdef SYS_pkey_free
	SARGS(pkey_free, rdec, arg_),
#endif
Gabor Buella's avatar
Gabor Buella committed
394 395 396 397
};

#undef SARGS

398 399 400 401 402 403 404 405 406 407 408 409
static const struct syscall_desc open_without_mode = {
	.name = "open",
	.return_type = rdec,
	.args = {arg_cstr, arg_open_flags, }
};

static const struct syscall_desc openat_without_mode = {
	.name = "openat",
	.return_type = rdec,
	.args = {arg_atfd, arg_cstr, arg_open_flags, }
};

Gabor Buella's avatar
Gabor Buella committed
410
const struct syscall_desc *
411
get_syscall_desc(long syscall_number, const long args[6])
Gabor Buella's avatar
Gabor Buella committed
412 413 414 415 416 417 418
{
	if (syscall_number < 0)
		return NULL;

	if ((size_t)syscall_number >= (sizeof(table) / sizeof(table[0])))
		return NULL;

419 420 421 422 423 424
	if (syscall_number == SYS_open && (args[1] & O_CREAT) == 0)
		return &open_without_mode;

	if (syscall_number == SYS_openat && (args[2] & O_CREAT) == 0)
		return &openat_without_mode;

Gabor Buella's avatar
Gabor Buella committed
425 426
	return table + syscall_number;
}