blob: ab9d0e3c6d5072b624a37279b28eb6c440ebfb48 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002
3#include <linux/linkage.h>
4#include <linux/errno.h>
5
6#include <asm/unistd.h>
7
Dominik Brodowski7303e302018-04-05 11:53:03 +02008#ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
9/* Architectures may override COND_SYSCALL and COND_SYSCALL_COMPAT */
10#include <asm/syscall_wrapper.h>
11#endif /* CONFIG_ARCH_HAS_SYSCALL_WRAPPER */
12
Adrian Bunk0732a552007-10-16 23:29:25 -070013/* we can't #include <linux/syscalls.h> here,
14 but tell gcc to not warn with -Wmissing-prototypes */
15asmlinkage long sys_ni_syscall(void);
16
Linus Torvalds1da177e2005-04-16 15:20:36 -070017/*
18 * Non-implemented system calls get redirected here.
19 */
20asmlinkage long sys_ni_syscall(void)
21{
22 return -ENOSYS;
23}
24
Dominik Brodowski7303e302018-04-05 11:53:03 +020025#ifndef COND_SYSCALL
Dominik Brodowski67a7acd2018-03-04 19:06:35 +010026#define COND_SYSCALL(name) cond_syscall(sys_##name)
Dominik Brodowski7303e302018-04-05 11:53:03 +020027#endif /* COND_SYSCALL */
28
29#ifndef COND_SYSCALL_COMPAT
Dominik Brodowski67a7acd2018-03-04 19:06:35 +010030#define COND_SYSCALL_COMPAT(name) cond_syscall(compat_sys_##name)
Dominik Brodowski7303e302018-04-05 11:53:03 +020031#endif /* COND_SYSCALL_COMPAT */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +010032
Dominik Brodowski70dd4b32018-03-06 19:53:01 +010033/*
34 * This list is kept in the same order as include/uapi/asm-generic/unistd.h.
35 * Architecture specific entries go below, followed by deprecated or obsolete
36 * system calls.
37 */
38
Dominik Brodowski67a7acd2018-03-04 19:06:35 +010039COND_SYSCALL(io_setup);
40COND_SYSCALL_COMPAT(io_setup);
41COND_SYSCALL(io_destroy);
42COND_SYSCALL(io_submit);
43COND_SYSCALL_COMPAT(io_submit);
44COND_SYSCALL(io_cancel);
45COND_SYSCALL(io_getevents);
Christoph Hellwig7a074e92018-05-02 19:51:00 +020046COND_SYSCALL(io_pgetevents);
Dominik Brodowski67a7acd2018-03-04 19:06:35 +010047COND_SYSCALL_COMPAT(io_getevents);
Christoph Hellwig7a074e92018-05-02 19:51:00 +020048COND_SYSCALL_COMPAT(io_pgetevents);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +010049
50/* fs/xattr.c */
51
52/* fs/dcache.c */
53
54/* fs/cookies.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +010055COND_SYSCALL(lookup_dcookie);
56COND_SYSCALL_COMPAT(lookup_dcookie);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +010057
58/* fs/eventfd.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +010059COND_SYSCALL(eventfd2);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +010060
61/* fs/eventfd.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +010062COND_SYSCALL(epoll_create1);
63COND_SYSCALL(epoll_ctl);
64COND_SYSCALL(epoll_pwait);
65COND_SYSCALL_COMPAT(epoll_pwait);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +010066
67/* fs/fcntl.c */
68
69/* fs/inotify_user.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +010070COND_SYSCALL(inotify_init1);
71COND_SYSCALL(inotify_add_watch);
72COND_SYSCALL(inotify_rm_watch);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +010073
74/* fs/ioctl.c */
75
76/* fs/ioprio.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +010077COND_SYSCALL(ioprio_set);
78COND_SYSCALL(ioprio_get);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +010079
80/* fs/locks.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +010081COND_SYSCALL(flock);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +010082
83/* fs/namei.c */
84
85/* fs/namespace.c */
86
87/* fs/nfsctl.c */
88
89/* fs/open.c */
90
91/* fs/pipe.c */
92
93/* fs/quota.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +010094COND_SYSCALL(quotactl);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +010095
96/* fs/readdir.c */
97
98/* fs/read_write.c */
99
100/* fs/sendfile.c */
101
102/* fs/select.c */
103
104/* fs/signalfd.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100105COND_SYSCALL(signalfd4);
106COND_SYSCALL_COMPAT(signalfd4);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100107
108/* fs/splice.c */
109
110/* fs/stat.c */
111
112/* fs/sync.c */
113
114/* fs/timerfd.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100115COND_SYSCALL(timerfd_create);
116COND_SYSCALL(timerfd_settime);
117COND_SYSCALL_COMPAT(timerfd_settime);
118COND_SYSCALL(timerfd_gettime);
119COND_SYSCALL_COMPAT(timerfd_gettime);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100120
121/* fs/utimes.c */
122
123/* kernel/acct.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100124COND_SYSCALL(acct);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100125
126/* kernel/capability.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100127COND_SYSCALL(capget);
128COND_SYSCALL(capset);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100129
130/* kernel/exec_domain.c */
131
132/* kernel/exit.c */
133
134/* kernel/fork.c */
135
136/* kernel/futex.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100137COND_SYSCALL(futex);
138COND_SYSCALL_COMPAT(futex);
139COND_SYSCALL(set_robust_list);
140COND_SYSCALL_COMPAT(set_robust_list);
141COND_SYSCALL(get_robust_list);
142COND_SYSCALL_COMPAT(get_robust_list);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100143
144/* kernel/hrtimer.c */
145
146/* kernel/itimer.c */
147
148/* kernel/kexec.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100149COND_SYSCALL(kexec_load);
150COND_SYSCALL_COMPAT(kexec_load);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100151
152/* kernel/module.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100153COND_SYSCALL(init_module);
154COND_SYSCALL(delete_module);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100155
156/* kernel/posix-timers.c */
157
158/* kernel/printk.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100159COND_SYSCALL(syslog);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100160
161/* kernel/ptrace.c */
162
163/* kernel/sched/core.c */
164
165/* kernel/signal.c */
166
167/* kernel/sys.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100168COND_SYSCALL(setregid);
169COND_SYSCALL(setgid);
170COND_SYSCALL(setreuid);
171COND_SYSCALL(setuid);
172COND_SYSCALL(setresuid);
173COND_SYSCALL(getresuid);
174COND_SYSCALL(setresgid);
175COND_SYSCALL(getresgid);
176COND_SYSCALL(setfsuid);
177COND_SYSCALL(setfsgid);
178COND_SYSCALL(setgroups);
179COND_SYSCALL(getgroups);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100180
181/* kernel/time.c */
182
183/* kernel/timer.c */
184
185/* ipc/mqueue.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100186COND_SYSCALL(mq_open);
187COND_SYSCALL_COMPAT(mq_open);
188COND_SYSCALL(mq_unlink);
189COND_SYSCALL(mq_timedsend);
190COND_SYSCALL_COMPAT(mq_timedsend);
191COND_SYSCALL(mq_timedreceive);
192COND_SYSCALL_COMPAT(mq_timedreceive);
193COND_SYSCALL(mq_notify);
194COND_SYSCALL_COMPAT(mq_notify);
195COND_SYSCALL(mq_getsetattr);
196COND_SYSCALL_COMPAT(mq_getsetattr);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100197
198/* ipc/msg.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100199COND_SYSCALL(msgget);
200COND_SYSCALL(msgctl);
201COND_SYSCALL_COMPAT(msgctl);
202COND_SYSCALL(msgrcv);
203COND_SYSCALL_COMPAT(msgrcv);
204COND_SYSCALL(msgsnd);
205COND_SYSCALL_COMPAT(msgsnd);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100206
207/* ipc/sem.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100208COND_SYSCALL(semget);
209COND_SYSCALL(semctl);
210COND_SYSCALL_COMPAT(semctl);
211COND_SYSCALL(semtimedop);
212COND_SYSCALL_COMPAT(semtimedop);
213COND_SYSCALL(semop);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100214
215/* ipc/shm.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100216COND_SYSCALL(shmget);
217COND_SYSCALL(shmctl);
218COND_SYSCALL_COMPAT(shmctl);
219COND_SYSCALL(shmat);
220COND_SYSCALL_COMPAT(shmat);
221COND_SYSCALL(shmdt);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100222
223/* net/socket.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100224COND_SYSCALL(socket);
225COND_SYSCALL(socketpair);
226COND_SYSCALL(bind);
227COND_SYSCALL(listen);
228COND_SYSCALL(accept);
229COND_SYSCALL(connect);
230COND_SYSCALL(getsockname);
231COND_SYSCALL(getpeername);
232COND_SYSCALL(setsockopt);
233COND_SYSCALL_COMPAT(setsockopt);
234COND_SYSCALL(getsockopt);
235COND_SYSCALL_COMPAT(getsockopt);
236COND_SYSCALL(sendto);
237COND_SYSCALL(shutdown);
238COND_SYSCALL(recvfrom);
239COND_SYSCALL_COMPAT(recvfrom);
240COND_SYSCALL(sendmsg);
241COND_SYSCALL_COMPAT(sendmsg);
242COND_SYSCALL(recvmsg);
243COND_SYSCALL_COMPAT(recvmsg);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100244
245/* mm/filemap.c */
246
247/* mm/nommu.c, also with MMU */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100248COND_SYSCALL(mremap);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100249
250/* security/keys/keyctl.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100251COND_SYSCALL(add_key);
252COND_SYSCALL(request_key);
253COND_SYSCALL(keyctl);
254COND_SYSCALL_COMPAT(keyctl);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100255
256/* arch/example/kernel/sys_example.c */
257
258/* mm/fadvise.c */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100259COND_SYSCALL(fadvise64_64);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100260
261/* mm/, CONFIG_MMU only */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100262COND_SYSCALL(swapon);
263COND_SYSCALL(swapoff);
264COND_SYSCALL(mprotect);
265COND_SYSCALL(msync);
266COND_SYSCALL(mlock);
267COND_SYSCALL(munlock);
268COND_SYSCALL(mlockall);
269COND_SYSCALL(munlockall);
270COND_SYSCALL(mincore);
271COND_SYSCALL(madvise);
272COND_SYSCALL(remap_file_pages);
273COND_SYSCALL(mbind);
274COND_SYSCALL_COMPAT(mbind);
275COND_SYSCALL(get_mempolicy);
276COND_SYSCALL_COMPAT(get_mempolicy);
277COND_SYSCALL(set_mempolicy);
278COND_SYSCALL_COMPAT(set_mempolicy);
279COND_SYSCALL(migrate_pages);
280COND_SYSCALL_COMPAT(migrate_pages);
281COND_SYSCALL(move_pages);
282COND_SYSCALL_COMPAT(move_pages);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100283
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100284COND_SYSCALL(perf_event_open);
285COND_SYSCALL(accept4);
286COND_SYSCALL(recvmmsg);
Arnd Bergmanne11d4282018-04-18 13:43:52 +0200287COND_SYSCALL(recvmmsg_time32);
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100288COND_SYSCALL_COMPAT(recvmmsg);
Arnd Bergmanne11d4282018-04-18 13:43:52 +0200289COND_SYSCALL_COMPAT(recvmmsg_time64);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100290
291/*
292 * Architecture specific syscalls: see further below
293 */
294
295/* fanotify */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100296COND_SYSCALL(fanotify_init);
297COND_SYSCALL(fanotify_mark);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100298
299/* open by handle */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100300COND_SYSCALL(name_to_handle_at);
301COND_SYSCALL(open_by_handle_at);
302COND_SYSCALL_COMPAT(open_by_handle_at);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100303
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100304COND_SYSCALL(sendmmsg);
305COND_SYSCALL_COMPAT(sendmmsg);
306COND_SYSCALL(process_vm_readv);
307COND_SYSCALL_COMPAT(process_vm_readv);
308COND_SYSCALL(process_vm_writev);
309COND_SYSCALL_COMPAT(process_vm_writev);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100310
311/* compare kernel pointers */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100312COND_SYSCALL(kcmp);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100313
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100314COND_SYSCALL(finit_module);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100315
316/* operate on Secure Computing state */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100317COND_SYSCALL(seccomp);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100318
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100319COND_SYSCALL(memfd_create);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100320
321/* access BPF programs and maps */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100322COND_SYSCALL(bpf);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100323
324/* execveat */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100325COND_SYSCALL(execveat);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100326
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100327COND_SYSCALL(userfaultfd);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100328
329/* membarrier */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100330COND_SYSCALL(membarrier);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100331
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100332COND_SYSCALL(mlock2);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100333
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100334COND_SYSCALL(copy_file_range);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100335
336/* memory protection keys */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100337COND_SYSCALL(pkey_mprotect);
338COND_SYSCALL(pkey_alloc);
339COND_SYSCALL(pkey_free);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100340
341
342/*
343 * Architecture specific weak syscall entries.
344 */
345
346/* pciconfig: alpha, arm, arm64, ia64, sparc */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100347COND_SYSCALL(pciconfig_read);
348COND_SYSCALL(pciconfig_write);
349COND_SYSCALL(pciconfig_iobase);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100350
351/* sys_socketcall: arm, mips, x86, ... */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100352COND_SYSCALL(socketcall);
353COND_SYSCALL_COMPAT(socketcall);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100354
355/* compat syscalls for arm64, x86, ... */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100356COND_SYSCALL_COMPAT(sysctl);
357COND_SYSCALL_COMPAT(fanotify_mark);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100358
359/* x86 */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100360COND_SYSCALL(vm86old);
361COND_SYSCALL(modify_ldt);
362COND_SYSCALL_COMPAT(quotactl32);
363COND_SYSCALL(vm86);
364COND_SYSCALL(kexec_file_load);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100365
366/* s390 */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100367COND_SYSCALL(s390_pci_mmio_read);
368COND_SYSCALL(s390_pci_mmio_write);
369COND_SYSCALL_COMPAT(s390_ipc);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100370
371/* powerpc */
Al Viro4c392e62018-05-02 23:20:48 +1000372COND_SYSCALL(rtas);
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100373COND_SYSCALL(spu_run);
374COND_SYSCALL(spu_create);
375COND_SYSCALL(subpage_prot);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100376
377
378/*
379 * Deprecated system calls which are still defined in
380 * include/uapi/asm-generic/unistd.h and wanted by >= 1 arch
381 */
382
383/* __ARCH_WANT_SYSCALL_NO_FLAGS */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100384COND_SYSCALL(epoll_create);
385COND_SYSCALL(inotify_init);
386COND_SYSCALL(eventfd);
387COND_SYSCALL(signalfd);
388COND_SYSCALL_COMPAT(signalfd);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100389
390/* __ARCH_WANT_SYSCALL_OFF_T */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100391COND_SYSCALL(fadvise64);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100392
393/* __ARCH_WANT_SYSCALL_DEPRECATED */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100394COND_SYSCALL(epoll_wait);
395COND_SYSCALL(recv);
396COND_SYSCALL_COMPAT(recv);
397COND_SYSCALL(send);
398COND_SYSCALL(bdflush);
399COND_SYSCALL(uselib);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100400
401
402/*
403 * The syscalls below are not found in include/uapi/asm-generic/unistd.h
404 */
405
406/* obsolete: SGETMASK_SYSCALL */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100407COND_SYSCALL(sgetmask);
408COND_SYSCALL(ssetmask);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100409
410/* obsolete: SYSFS_SYSCALL */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100411COND_SYSCALL(sysfs);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100412
413/* obsolete: __ARCH_WANT_SYS_IPC */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100414COND_SYSCALL(ipc);
415COND_SYSCALL_COMPAT(ipc);
Dominik Brodowski70dd4b32018-03-06 19:53:01 +0100416
417/* obsolete: UID16 */
Dominik Brodowski67a7acd2018-03-04 19:06:35 +0100418COND_SYSCALL(chown16);
419COND_SYSCALL(fchown16);
420COND_SYSCALL(getegid16);
421COND_SYSCALL(geteuid16);
422COND_SYSCALL(getgid16);
423COND_SYSCALL(getgroups16);
424COND_SYSCALL(getresgid16);
425COND_SYSCALL(getresuid16);
426COND_SYSCALL(getuid16);
427COND_SYSCALL(lchown16);
428COND_SYSCALL(setfsgid16);
429COND_SYSCALL(setfsuid16);
430COND_SYSCALL(setgid16);
431COND_SYSCALL(setgroups16);
432COND_SYSCALL(setregid16);
433COND_SYSCALL(setresgid16);
434COND_SYSCALL(setresuid16);
435COND_SYSCALL(setreuid16);
436COND_SYSCALL(setuid16);
Mathieu Desnoyersd7822b12018-06-02 08:43:54 -0400437
438/* restartable sequence */
439COND_SYSCALL(rseq);