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