xref: /linux/kernel/sys_ni.c (revision 2d7f3d1a5866705be2393150e1ffdf67030ab88d)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <linux/linkage.h>
4 #include <linux/errno.h>
5 
6 #include <asm/unistd.h>
7 
8 #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 
13 /*  we can't #include <linux/syscalls.h> here,
14     but tell gcc to not warn with -Wmissing-prototypes  */
15 asmlinkage long sys_ni_syscall(void);
16 
17 /*
18  * Non-implemented system calls get redirected here.
19  */
20 asmlinkage long sys_ni_syscall(void)
21 {
22 	return -ENOSYS;
23 }
24 
25 #ifndef COND_SYSCALL
26 #define COND_SYSCALL(name) cond_syscall(sys_##name)
27 #endif /* COND_SYSCALL */
28 
29 #ifndef COND_SYSCALL_COMPAT
30 #define COND_SYSCALL_COMPAT(name) cond_syscall(compat_sys_##name)
31 #endif /* COND_SYSCALL_COMPAT */
32 
33 /*
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 
39 COND_SYSCALL(io_setup);
40 COND_SYSCALL_COMPAT(io_setup);
41 COND_SYSCALL(io_destroy);
42 COND_SYSCALL(io_submit);
43 COND_SYSCALL_COMPAT(io_submit);
44 COND_SYSCALL(io_cancel);
45 COND_SYSCALL(io_getevents_time32);
46 COND_SYSCALL(io_getevents);
47 COND_SYSCALL(io_pgetevents_time32);
48 COND_SYSCALL(io_pgetevents);
49 COND_SYSCALL_COMPAT(io_pgetevents_time32);
50 COND_SYSCALL_COMPAT(io_pgetevents);
51 COND_SYSCALL(io_uring_setup);
52 COND_SYSCALL(io_uring_enter);
53 COND_SYSCALL(io_uring_register);
54 COND_SYSCALL(eventfd2);
55 COND_SYSCALL(epoll_create1);
56 COND_SYSCALL(epoll_ctl);
57 COND_SYSCALL(epoll_pwait);
58 COND_SYSCALL_COMPAT(epoll_pwait);
59 COND_SYSCALL(epoll_pwait2);
60 COND_SYSCALL_COMPAT(epoll_pwait2);
61 COND_SYSCALL(inotify_init1);
62 COND_SYSCALL(inotify_add_watch);
63 COND_SYSCALL(inotify_rm_watch);
64 COND_SYSCALL(ioprio_set);
65 COND_SYSCALL(ioprio_get);
66 COND_SYSCALL(flock);
67 COND_SYSCALL(quotactl);
68 COND_SYSCALL(quotactl_fd);
69 COND_SYSCALL(signalfd4);
70 COND_SYSCALL_COMPAT(signalfd4);
71 COND_SYSCALL(timerfd_create);
72 COND_SYSCALL(timerfd_settime);
73 COND_SYSCALL(timerfd_settime32);
74 COND_SYSCALL(timerfd_gettime);
75 COND_SYSCALL(timerfd_gettime32);
76 COND_SYSCALL(acct);
77 COND_SYSCALL(capget);
78 COND_SYSCALL(capset);
79 /* __ARCH_WANT_SYS_CLONE3 */
80 COND_SYSCALL(clone3);
81 COND_SYSCALL(futex);
82 COND_SYSCALL(futex_time32);
83 COND_SYSCALL(set_robust_list);
84 COND_SYSCALL_COMPAT(set_robust_list);
85 COND_SYSCALL(get_robust_list);
86 COND_SYSCALL_COMPAT(get_robust_list);
87 COND_SYSCALL(futex_waitv);
88 COND_SYSCALL(futex_wake);
89 COND_SYSCALL(futex_wait);
90 COND_SYSCALL(futex_requeue);
91 COND_SYSCALL(kexec_load);
92 COND_SYSCALL_COMPAT(kexec_load);
93 COND_SYSCALL(init_module);
94 COND_SYSCALL(delete_module);
95 COND_SYSCALL(syslog);
96 COND_SYSCALL(setregid);
97 COND_SYSCALL(setgid);
98 COND_SYSCALL(setreuid);
99 COND_SYSCALL(setuid);
100 COND_SYSCALL(setresuid);
101 COND_SYSCALL(getresuid);
102 COND_SYSCALL(setresgid);
103 COND_SYSCALL(getresgid);
104 COND_SYSCALL(setfsuid);
105 COND_SYSCALL(setfsgid);
106 COND_SYSCALL(setgroups);
107 COND_SYSCALL(getgroups);
108 COND_SYSCALL(mq_open);
109 COND_SYSCALL_COMPAT(mq_open);
110 COND_SYSCALL(mq_unlink);
111 COND_SYSCALL(mq_timedsend);
112 COND_SYSCALL(mq_timedsend_time32);
113 COND_SYSCALL(mq_timedreceive);
114 COND_SYSCALL(mq_timedreceive_time32);
115 COND_SYSCALL(mq_notify);
116 COND_SYSCALL_COMPAT(mq_notify);
117 COND_SYSCALL(mq_getsetattr);
118 COND_SYSCALL_COMPAT(mq_getsetattr);
119 COND_SYSCALL(msgget);
120 COND_SYSCALL(old_msgctl);
121 COND_SYSCALL(msgctl);
122 COND_SYSCALL_COMPAT(msgctl);
123 COND_SYSCALL_COMPAT(old_msgctl);
124 COND_SYSCALL(msgrcv);
125 COND_SYSCALL_COMPAT(msgrcv);
126 COND_SYSCALL(msgsnd);
127 COND_SYSCALL_COMPAT(msgsnd);
128 COND_SYSCALL(semget);
129 COND_SYSCALL(old_semctl);
130 COND_SYSCALL(semctl);
131 COND_SYSCALL_COMPAT(semctl);
132 COND_SYSCALL_COMPAT(old_semctl);
133 COND_SYSCALL(semtimedop);
134 COND_SYSCALL(semtimedop_time32);
135 COND_SYSCALL(semop);
136 COND_SYSCALL(shmget);
137 COND_SYSCALL(old_shmctl);
138 COND_SYSCALL(shmctl);
139 COND_SYSCALL_COMPAT(shmctl);
140 COND_SYSCALL_COMPAT(old_shmctl);
141 COND_SYSCALL(shmat);
142 COND_SYSCALL_COMPAT(shmat);
143 COND_SYSCALL(shmdt);
144 COND_SYSCALL(socket);
145 COND_SYSCALL(socketpair);
146 COND_SYSCALL(bind);
147 COND_SYSCALL(listen);
148 COND_SYSCALL(accept);
149 COND_SYSCALL(connect);
150 COND_SYSCALL(getsockname);
151 COND_SYSCALL(getpeername);
152 COND_SYSCALL(setsockopt);
153 COND_SYSCALL_COMPAT(setsockopt);
154 COND_SYSCALL(getsockopt);
155 COND_SYSCALL_COMPAT(getsockopt);
156 COND_SYSCALL(sendto);
157 COND_SYSCALL(shutdown);
158 COND_SYSCALL(recvfrom);
159 COND_SYSCALL_COMPAT(recvfrom);
160 COND_SYSCALL(sendmsg);
161 COND_SYSCALL_COMPAT(sendmsg);
162 COND_SYSCALL(recvmsg);
163 COND_SYSCALL_COMPAT(recvmsg);
164 COND_SYSCALL(mremap);
165 COND_SYSCALL(add_key);
166 COND_SYSCALL(request_key);
167 COND_SYSCALL(keyctl);
168 COND_SYSCALL_COMPAT(keyctl);
169 COND_SYSCALL(landlock_create_ruleset);
170 COND_SYSCALL(landlock_add_rule);
171 COND_SYSCALL(landlock_restrict_self);
172 COND_SYSCALL(fadvise64_64);
173 COND_SYSCALL_COMPAT(fadvise64_64);
174 COND_SYSCALL(lsm_get_self_attr);
175 COND_SYSCALL(lsm_set_self_attr);
176 COND_SYSCALL(lsm_list_modules);
177 
178 /* CONFIG_MMU only */
179 COND_SYSCALL(swapon);
180 COND_SYSCALL(swapoff);
181 COND_SYSCALL(mprotect);
182 COND_SYSCALL(msync);
183 COND_SYSCALL(mlock);
184 COND_SYSCALL(munlock);
185 COND_SYSCALL(mlockall);
186 COND_SYSCALL(munlockall);
187 COND_SYSCALL(mincore);
188 COND_SYSCALL(madvise);
189 COND_SYSCALL(process_madvise);
190 COND_SYSCALL(process_mrelease);
191 COND_SYSCALL(remap_file_pages);
192 COND_SYSCALL(mbind);
193 COND_SYSCALL(get_mempolicy);
194 COND_SYSCALL(set_mempolicy);
195 COND_SYSCALL(migrate_pages);
196 COND_SYSCALL(move_pages);
197 COND_SYSCALL(set_mempolicy_home_node);
198 COND_SYSCALL(cachestat);
199 
200 COND_SYSCALL(perf_event_open);
201 COND_SYSCALL(accept4);
202 COND_SYSCALL(recvmmsg);
203 COND_SYSCALL(recvmmsg_time32);
204 COND_SYSCALL_COMPAT(recvmmsg_time32);
205 COND_SYSCALL_COMPAT(recvmmsg_time64);
206 
207 /* Posix timer syscalls may be configured out */
208 COND_SYSCALL(timer_create);
209 COND_SYSCALL(timer_gettime);
210 COND_SYSCALL(timer_getoverrun);
211 COND_SYSCALL(timer_settime);
212 COND_SYSCALL(timer_delete);
213 COND_SYSCALL(clock_adjtime);
214 COND_SYSCALL(getitimer);
215 COND_SYSCALL(setitimer);
216 COND_SYSCALL(alarm);
217 COND_SYSCALL_COMPAT(timer_create);
218 COND_SYSCALL_COMPAT(getitimer);
219 COND_SYSCALL_COMPAT(setitimer);
220 
221 /*
222  * Architecture specific syscalls: see further below
223  */
224 
225 /* fanotify */
226 COND_SYSCALL(fanotify_init);
227 COND_SYSCALL(fanotify_mark);
228 
229 /* open by handle */
230 COND_SYSCALL(name_to_handle_at);
231 COND_SYSCALL(open_by_handle_at);
232 COND_SYSCALL_COMPAT(open_by_handle_at);
233 
234 COND_SYSCALL(sendmmsg);
235 COND_SYSCALL_COMPAT(sendmmsg);
236 COND_SYSCALL(process_vm_readv);
237 COND_SYSCALL_COMPAT(process_vm_readv);
238 COND_SYSCALL(process_vm_writev);
239 COND_SYSCALL_COMPAT(process_vm_writev);
240 
241 /* compare kernel pointers */
242 COND_SYSCALL(kcmp);
243 
244 COND_SYSCALL(finit_module);
245 
246 /* operate on Secure Computing state */
247 COND_SYSCALL(seccomp);
248 
249 COND_SYSCALL(memfd_create);
250 
251 /* access BPF programs and maps */
252 COND_SYSCALL(bpf);
253 
254 /* execveat */
255 COND_SYSCALL(execveat);
256 
257 COND_SYSCALL(userfaultfd);
258 
259 /* membarrier */
260 COND_SYSCALL(membarrier);
261 
262 COND_SYSCALL(mlock2);
263 
264 COND_SYSCALL(copy_file_range);
265 
266 /* memory protection keys */
267 COND_SYSCALL(pkey_mprotect);
268 COND_SYSCALL(pkey_alloc);
269 COND_SYSCALL(pkey_free);
270 
271 /* memfd_secret */
272 COND_SYSCALL(memfd_secret);
273 
274 /*
275  * Architecture specific weak syscall entries.
276  */
277 
278 /* pciconfig: alpha, arm, arm64, ia64, sparc */
279 COND_SYSCALL(pciconfig_read);
280 COND_SYSCALL(pciconfig_write);
281 COND_SYSCALL(pciconfig_iobase);
282 
283 /* sys_socketcall: arm, mips, x86, ... */
284 COND_SYSCALL(socketcall);
285 COND_SYSCALL_COMPAT(socketcall);
286 
287 /* compat syscalls for arm64, x86, ... */
288 COND_SYSCALL_COMPAT(fanotify_mark);
289 
290 /* x86 */
291 COND_SYSCALL(vm86old);
292 COND_SYSCALL(modify_ldt);
293 COND_SYSCALL(vm86);
294 COND_SYSCALL(kexec_file_load);
295 COND_SYSCALL(map_shadow_stack);
296 
297 /* s390 */
298 COND_SYSCALL(s390_pci_mmio_read);
299 COND_SYSCALL(s390_pci_mmio_write);
300 COND_SYSCALL(s390_ipc);
301 COND_SYSCALL_COMPAT(s390_ipc);
302 
303 /* powerpc */
304 COND_SYSCALL(rtas);
305 COND_SYSCALL(spu_run);
306 COND_SYSCALL(spu_create);
307 COND_SYSCALL(subpage_prot);
308 
309 
310 /*
311  * Deprecated system calls which are still defined in
312  * include/uapi/asm-generic/unistd.h and wanted by >= 1 arch
313  */
314 
315 /* __ARCH_WANT_SYSCALL_NO_FLAGS */
316 COND_SYSCALL(epoll_create);
317 COND_SYSCALL(inotify_init);
318 COND_SYSCALL(eventfd);
319 COND_SYSCALL(signalfd);
320 COND_SYSCALL_COMPAT(signalfd);
321 
322 /* __ARCH_WANT_SYSCALL_OFF_T */
323 COND_SYSCALL(fadvise64);
324 
325 /* __ARCH_WANT_SYSCALL_DEPRECATED */
326 COND_SYSCALL(epoll_wait);
327 COND_SYSCALL(recv);
328 COND_SYSCALL_COMPAT(recv);
329 COND_SYSCALL(send);
330 COND_SYSCALL(uselib);
331 
332 /* optional: time32 */
333 COND_SYSCALL(time32);
334 COND_SYSCALL(stime32);
335 COND_SYSCALL(utime32);
336 COND_SYSCALL(adjtimex_time32);
337 COND_SYSCALL(sched_rr_get_interval_time32);
338 COND_SYSCALL(nanosleep_time32);
339 COND_SYSCALL(rt_sigtimedwait_time32);
340 COND_SYSCALL_COMPAT(rt_sigtimedwait_time32);
341 COND_SYSCALL(timer_settime32);
342 COND_SYSCALL(timer_gettime32);
343 COND_SYSCALL(clock_settime32);
344 COND_SYSCALL(clock_gettime32);
345 COND_SYSCALL(clock_getres_time32);
346 COND_SYSCALL(clock_nanosleep_time32);
347 COND_SYSCALL(utimes_time32);
348 COND_SYSCALL(futimesat_time32);
349 COND_SYSCALL(pselect6_time32);
350 COND_SYSCALL_COMPAT(pselect6_time32);
351 COND_SYSCALL(ppoll_time32);
352 COND_SYSCALL_COMPAT(ppoll_time32);
353 COND_SYSCALL(utimensat_time32);
354 COND_SYSCALL(clock_adjtime32);
355 
356 /*
357  * The syscalls below are not found in include/uapi/asm-generic/unistd.h
358  */
359 
360 /* obsolete: SGETMASK_SYSCALL */
361 COND_SYSCALL(sgetmask);
362 COND_SYSCALL(ssetmask);
363 
364 /* obsolete: SYSFS_SYSCALL */
365 COND_SYSCALL(sysfs);
366 
367 /* obsolete: __ARCH_WANT_SYS_IPC */
368 COND_SYSCALL(ipc);
369 COND_SYSCALL_COMPAT(ipc);
370 
371 /* obsolete: UID16 */
372 COND_SYSCALL(chown16);
373 COND_SYSCALL(fchown16);
374 COND_SYSCALL(getegid16);
375 COND_SYSCALL(geteuid16);
376 COND_SYSCALL(getgid16);
377 COND_SYSCALL(getgroups16);
378 COND_SYSCALL(getresgid16);
379 COND_SYSCALL(getresuid16);
380 COND_SYSCALL(getuid16);
381 COND_SYSCALL(lchown16);
382 COND_SYSCALL(setfsgid16);
383 COND_SYSCALL(setfsuid16);
384 COND_SYSCALL(setgid16);
385 COND_SYSCALL(setgroups16);
386 COND_SYSCALL(setregid16);
387 COND_SYSCALL(setresgid16);
388 COND_SYSCALL(setresuid16);
389 COND_SYSCALL(setreuid16);
390 COND_SYSCALL(setuid16);
391 
392 /* restartable sequence */
393 COND_SYSCALL(rseq);
394