2 * Enhanced Seccomp x86_64 Syscall Table
4 * Copyright (c) 2012 Red Hat <pmoore@redhat.com>
5 * Author: Paul Moore <paul@paul-moore.com>
9 * This library is free software; you can redistribute it and/or modify it
10 * under the terms of version 2.1 of the GNU Lesser General Public License as
11 * published by the Free Software Foundation.
13 * This library is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this library; if not, see <http://www.gnu.org/licenses>.
27 #include "arch-x86_64.h"
29 /* NOTE: based on Linux 4.5-rc4 */
30 const struct arch_syscall_def x86_64_syscall_table
[] = { \
31 { "_llseek", __PNR__llseek
},
32 { "_newselect", __PNR__newselect
},
40 { "afs_syscall", 183 },
42 { "arm_fadvise64_64", __PNR_arm_fadvise64_64
},
43 { "arm_sync_file_range", __PNR_arm_sync_file_range
},
44 { "arch_prctl", 158 },
45 { "bdflush", __PNR_bdflush
},
48 { "break", __PNR_break
},
49 { "breakpoint", __PNR_breakpoint
},
51 { "cachectl", __PNR_cachectl
},
52 { "cacheflush", __PNR_cacheflush
},
58 { "chown32", __PNR_chown32
},
60 { "clock_adjtime", 305 },
61 { "clock_getres", 229 },
62 { "clock_gettime", 228 },
63 { "clock_nanosleep", 230 },
64 { "clock_settime", 227 },
68 { "copy_file_range", 326 },
70 { "create_module", 174 },
71 { "delete_module", 176 },
75 { "epoll_create", 213 },
76 { "epoll_create1", 291 },
78 { "epoll_ctl_old", 214 },
79 { "epoll_pwait", 281 },
80 { "epoll_wait", 232 },
81 { "epoll_wait_old", 215 },
87 { "exit_group", 231 },
90 { "fadvise64_64", __PNR_fadvise64_64
},
92 { "fanotify_init", 300 },
93 { "fanotify_mark", 301 },
98 { "fchown32", __PNR_fchown32
},
101 { "fcntl64", __PNR_fcntl64
},
103 { "fgetxattr", 193 },
104 { "finit_module", 313 },
105 { "flistxattr", 196 },
108 { "fremovexattr", 199 },
109 { "fsetxattr", 190 },
111 { "fstat64", __PNR_fstat64
},
112 { "fstatat64", __PNR_fstatat64
},
114 { "fstatfs64", __PNR_fstatfs64
},
116 { "ftime", __PNR_ftime
},
118 { "ftruncate64", __PNR_ftruncate64
},
120 { "futimesat", 261 },
121 { "get_kernel_syms", 177 },
122 { "get_mempolicy", 239 },
123 { "get_robust_list", 274 },
124 { "get_thread_area", 211 },
128 { "getdents64", 217 },
130 { "getegid32", __PNR_getegid32
},
132 { "geteuid32", __PNR_geteuid32
},
134 { "getgid32", __PNR_getgid32
},
135 { "getgroups", 115 },
136 { "getgroups32", __PNR_getgroups32
},
138 { "getpeername", 52 },
144 { "getpriority", 140 },
145 { "getrandom", 318 },
146 { "getresgid", 120 },
147 { "getresgid32", __PNR_getresgid32
},
148 { "getresuid", 118 },
149 { "getresuid32", __PNR_getresuid32
},
153 { "getsockname", 51 },
154 { "getsockopt", 55 },
156 { "gettimeofday", 96 },
158 { "getuid32", __PNR_getuid32
},
160 { "gtty", __PNR_gtty
},
161 { "idle", __PNR_idle
},
162 { "init_module", 175 },
163 { "inotify_add_watch", 254 },
164 { "inotify_init", 253 },
165 { "inotify_init1", 294 },
166 { "inotify_rm_watch", 255 },
167 { "io_cancel", 210 },
168 { "io_destroy", 207 },
169 { "io_getevents", 208 },
171 { "io_submit", 209 },
175 { "ioprio_get", 252 },
176 { "ioprio_set", 251 },
177 { "ipc", __PNR_ipc
},
179 { "kexec_file_load", 320 },
180 { "kexec_load", 246 },
184 { "lchown32", __PNR_lchown32
},
185 { "lgetxattr", 192 },
189 { "listxattr", 194 },
190 { "llistxattr", 195 },
191 { "lock", __PNR_lock
},
192 { "lookup_dcookie", 212 },
193 { "lremovexattr", 198 },
195 { "lsetxattr", 189 },
197 { "lstat64", __PNR_lstat64
},
200 { "membarrier", 324 },
201 { "memfd_create", 319 },
202 { "migrate_pages", 256 },
212 { "mmap2", __PNR_mmap2
},
213 { "modify_ldt", 154 },
215 { "move_pages", 279 },
217 { "mpx", __PNR_mpx
},
218 { "mq_getsetattr", 245 },
219 { "mq_notify", 244 },
221 { "mq_timedreceive", 243 },
222 { "mq_timedsend", 242 },
223 { "mq_unlink", 241 },
230 { "multiplexer", __PNR_multiplexer
},
232 { "munlockall", 152 },
234 { "name_to_handle_at", 303 },
236 { "newfstatat", 262 },
237 { "nfsservctl", 180 },
238 { "nice", __PNR_nice
},
239 { "oldfstat", __PNR_oldfstat
},
240 { "oldlstat", __PNR_oldlstat
},
241 { "oldolduname", __PNR_oldolduname
},
242 { "oldstat", __PNR_oldstat
},
243 { "olduname", __PNR_olduname
},
244 { "oldwait4", __PNR_oldwait4
},
246 { "open_by_handle_at", 304 },
249 { "pciconfig_iobase", __PNR_pciconfig_iobase
},
250 { "pciconfig_read", __PNR_pciconfig_read
},
251 { "pciconfig_write", __PNR_pciconfig_write
},
252 { "perf_event_open", 298 },
253 { "personality", 135 },
256 { "pivot_root", 155 },
262 { "prlimit64", 302 },
263 { "process_vm_readv", 310 },
264 { "process_vm_writev", 311 },
265 { "prof", __PNR_prof
},
266 { "profil", __PNR_profil
},
272 { "query_module", 178 },
275 { "readahead", 187 },
276 { "readdir", __PNR_readdir
},
278 { "readlinkat", 267 },
281 { "recv", __PNR_recv
},
285 { "remap_file_pages", 216 },
286 { "removexattr", 197 },
289 { "renameat2", 316 },
290 { "request_key", 249 },
291 { "restart_syscall", 219 },
293 { "rt_sigaction", 13 },
294 { "rt_sigpending", 127 },
295 { "rt_sigprocmask", 14 },
296 { "rt_sigqueueinfo", 129 },
297 { "rt_sigreturn", 15 },
298 { "rt_sigsuspend", 130 },
299 { "rt_sigtimedwait", 128 },
300 { "rt_tgsigqueueinfo", 297 },
301 { "rtas", __PNR_rtas
},
302 { "s390_pci_mmio_read", __PNR_s390_pci_mmio_read
},
303 { "s390_pci_mmio_write", __PNR_s390_pci_mmio_write
},
304 { "s390_runtime_instr", __PNR_s390_runtime_instr
},
305 { "sched_get_priority_max", 146 },
306 { "sched_get_priority_min", 147 },
307 { "sched_getaffinity", 204 },
308 { "sched_getattr", 315 },
309 { "sched_getparam", 143 },
310 { "sched_getscheduler", 145 },
311 { "sched_rr_get_interval", 148 },
312 { "sched_setaffinity", 203 },
313 { "sched_setattr", 314 },
314 { "sched_setparam", 142 },
315 { "sched_setscheduler", 144 },
316 { "sched_yield", 24 },
323 { "semtimedop", 220 },
324 { "send", __PNR_send
},
326 { "sendfile64", __PNR_sendfile64
},
330 { "set_mempolicy", 238 },
331 { "set_robust_list", 273 },
332 { "set_thread_area", 205 },
333 { "set_tid_address", 218 },
334 { "set_tls", __PNR_set_tls
},
335 { "setdomainname", 171 },
337 { "setfsgid32", __PNR_setfsgid32
},
339 { "setfsuid32", __PNR_setfsuid32
},
341 { "setgid32", __PNR_setgid32
},
342 { "setgroups", 116 },
343 { "setgroups32", __PNR_setgroups32
},
344 { "sethostname", 170 },
348 { "setpriority", 141 },
350 { "setregid32", __PNR_setregid32
},
351 { "setresgid", 119 },
352 { "setresgid32", __PNR_setresgid32
},
353 { "setresuid", 117 },
354 { "setresuid32", __PNR_setresuid32
},
356 { "setreuid32", __PNR_setreuid32
},
357 { "setrlimit", 160 },
359 { "setsockopt", 54 },
360 { "settimeofday", 164 },
362 { "setuid32", __PNR_setuid32
},
364 { "sgetmask", __PNR_sgetmask
},
370 { "sigaction", __PNR_sigaction
},
371 { "sigaltstack", 131 },
372 { "signal", __PNR_signal
},
374 { "signalfd4", 289 },
375 { "sigpending", __PNR_sigpending
},
376 { "sigprocmask", __PNR_sigprocmask
},
377 { "sigreturn", __PNR_sigreturn
},
378 { "sigsuspend", __PNR_sigsuspend
},
380 { "socketcall", __PNR_socketcall
},
381 { "socketpair", 53 },
383 { "spu_create", __PNR_spu_create
},
384 { "spu_run", __PNR_spu_run
},
385 { "ssetmask", __PNR_ssetmask
},
387 { "stat64", __PNR_stat64
},
389 { "statfs64", __PNR_statfs64
},
390 { "stime", __PNR_stime
},
391 { "stty", __PNR_stty
},
392 { "subpage_prot", __PNR_subpage_prot
},
393 { "swapcontext", __PNR_swapcontext
},
396 { "switch_endian", __PNR_switch_endian
},
398 { "symlinkat", 266 },
400 { "sync_file_range", 277 },
401 { "sync_file_range2", __PNR_sync_file_range2
},
403 { "syscall", __PNR_syscall
},
404 { "sys_debug_setcontext", __PNR_sys_debug_setcontext
},
408 { "sysmips", __PNR_sysmips
},
412 { "timer_create", 222 },
413 { "timer_delete", 226 },
414 { "timer_getoverrun", 225 },
415 { "timer_gettime", 224 },
416 { "timer_settime", 223 },
417 { "timerfd", __PNR_timerfd
},
418 { "timerfd_create", 283 },
419 { "timerfd_gettime", 287 },
420 { "timerfd_settime", 286 },
424 { "truncate64", __PNR_truncate64
},
426 { "ugetrlimit", __PNR_ugetrlimit
},
427 { "ulimit", __PNR_ulimit
},
429 { "umount", __PNR_umount
},
436 { "userfaultfd", 323 },
437 { "usr26", __PNR_usr26
},
438 { "usr32", __PNR_usr32
},
441 { "utimensat", 280 },
445 { "vm86", __PNR_vm86
},
446 { "vm86old", __PNR_vm86old
},
451 { "waitpid", __PNR_waitpid
},
454 { NULL
, __NR_SCMP_ERROR
},
458 * Resolve a syscall name to a number
459 * @param name the syscall name
461 * Resolve the given syscall name to the syscall number using the syscall table.
462 * Returns the syscall number on success, including negative pseudo syscall
463 * numbers; returns __NR_SCMP_ERROR on failure.
466 int x86_64_syscall_resolve_name(const char *name
)
469 const struct arch_syscall_def
*table
= x86_64_syscall_table
;
471 /* XXX - plenty of room for future improvement here */
472 for (iter
= 0; table
[iter
].name
!= NULL
; iter
++) {
473 if (strcmp(name
, table
[iter
].name
) == 0)
474 return table
[iter
].num
;
477 return __NR_SCMP_ERROR
;
481 * Resolve a syscall number to a name
482 * @param num the syscall number
484 * Resolve the given syscall number to the syscall name using the syscall table.
485 * Returns a pointer to the syscall name string on success, including pseudo
486 * syscall names; returns NULL on failure.
489 const char *x86_64_syscall_resolve_num(int num
)
492 const struct arch_syscall_def
*table
= x86_64_syscall_table
;
494 /* XXX - plenty of room for future improvement here */
495 for (iter
= 0; table
[iter
].num
!= __NR_SCMP_ERROR
; iter
++) {
496 if (num
== table
[iter
].num
)
497 return table
[iter
].name
;
504 * Iterate through the syscall table and return the syscall name
505 * @param spot the offset into the syscall table
507 * Return the syscall name at position @spot or NULL on failure. This function
508 * should only ever be used internally by libseccomp.
511 const char *x86_64_syscall_iterate_name(unsigned int spot
)
513 /* XXX - no safety checks here */
514 return x86_64_syscall_table
[spot
].name
;