aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-04-03 00:22:12 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-03 00:22:12 -0400
commit642e7fd23353e22290e3d51719fcb658dc252342 (patch)
tree93688d5ff15836d8e5b0e097748f7fabb13a303a /kernel
parent21035965f60b0502fc6537b232839389bb4ce664 (diff)
parentc9a211951c7c79cfb5de888d7d9550872868b086 (diff)
Merge branch 'syscalls-next' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux
Pull removal of in-kernel calls to syscalls from Dominik Brodowski: "System calls are interaction points between userspace and the kernel. Therefore, system call functions such as sys_xyzzy() or compat_sys_xyzzy() should only be called from userspace via the syscall table, but not from elsewhere in the kernel. At least on 64-bit x86, it will likely be a hard requirement from v4.17 onwards to not call system call functions in the kernel: It is better to use use a different calling convention for system calls there, where struct pt_regs is decoded on-the-fly in a syscall wrapper which then hands processing over to the actual syscall function. This means that only those parameters which are actually needed for a specific syscall are passed on during syscall entry, instead of filling in six CPU registers with random user space content all the time (which may cause serious trouble down the call chain). Those x86-specific patches will be pushed through the x86 tree in the near future. Moreover, rules on how data may be accessed may differ between kernel data and user data. This is another reason why calling sys_xyzzy() is generally a bad idea, and -- at most -- acceptable in arch-specific code. This patchset removes all in-kernel calls to syscall functions in the kernel with the exception of arch/. On top of this, it cleans up the three places where many syscalls are referenced or prototyped, namely kernel/sys_ni.c, include/linux/syscalls.h and include/linux/compat.h" * 'syscalls-next' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux: (109 commits) bpf: whitelist all syscalls for error injection kernel/sys_ni: remove {sys_,sys_compat} from cond_syscall definitions kernel/sys_ni: sort cond_syscall() entries syscalls/x86: auto-create compat_sys_*() prototypes syscalls: sort syscall prototypes in include/linux/compat.h net: remove compat_sys_*() prototypes from net/compat.h syscalls: sort syscall prototypes in include/linux/syscalls.h kexec: move sys_kexec_load() prototype to syscalls.h x86/sigreturn: use SYSCALL_DEFINE0 x86: fix sys_sigreturn() return type to be long, not unsigned long x86/ioport: add ksys_ioperm() helper; remove in-kernel calls to sys_ioperm() mm: add ksys_readahead() helper; remove in-kernel calls to sys_readahead() mm: add ksys_mmap_pgoff() helper; remove in-kernel calls to sys_mmap_pgoff() mm: add ksys_fadvise64_64() helper; remove in-kernel call to sys_fadvise64_64() fs: add ksys_fallocate() wrapper; remove in-kernel calls to sys_fallocate() fs: add ksys_p{read,write}64() helpers; remove in-kernel calls to syscalls fs: add ksys_truncate() wrapper; remove in-kernel calls to sys_truncate() fs: add ksys_sync_file_range helper(); remove in-kernel calls to syscall kernel: add ksys_setsid() helper; remove in-kernel call to sys_setsid() kernel: add ksys_unshare() helper; remove in-kernel calls to sys_unshare() ...
Diffstat (limited to 'kernel')
-rw-r--r--kernel/compat.c55
-rw-r--r--kernel/exit.c2
-rw-r--r--kernel/fork.c11
-rw-r--r--kernel/kexec.c52
-rw-r--r--kernel/pid_namespace.c6
-rw-r--r--kernel/power/hibernate.c2
-rw-r--r--kernel/power/suspend.c2
-rw-r--r--kernel/power/user.c2
-rw-r--r--kernel/sched/core.c8
-rw-r--r--kernel/signal.c29
-rw-r--r--kernel/sys.c74
-rw-r--r--kernel/sys_ni.c617
-rw-r--r--kernel/uid16.c25
-rw-r--r--kernel/uid16.h14
-rw-r--r--kernel/umh.c4
15 files changed, 563 insertions, 340 deletions
diff --git a/kernel/compat.c b/kernel/compat.c
index 3f5fa8902e7d..6d21894806b4 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -488,61 +488,6 @@ get_compat_sigset(sigset_t *set, const compat_sigset_t __user *compat)
488} 488}
489EXPORT_SYMBOL_GPL(get_compat_sigset); 489EXPORT_SYMBOL_GPL(get_compat_sigset);
490 490
491#ifdef CONFIG_NUMA
492COMPAT_SYSCALL_DEFINE6(move_pages, pid_t, pid, compat_ulong_t, nr_pages,
493 compat_uptr_t __user *, pages32,
494 const int __user *, nodes,
495 int __user *, status,
496 int, flags)
497{
498 const void __user * __user *pages;
499 int i;
500
501 pages = compat_alloc_user_space(nr_pages * sizeof(void *));
502 for (i = 0; i < nr_pages; i++) {
503 compat_uptr_t p;
504
505 if (get_user(p, pages32 + i) ||
506 put_user(compat_ptr(p), pages + i))
507 return -EFAULT;
508 }
509 return sys_move_pages(pid, nr_pages, pages, nodes, status, flags);
510}
511
512COMPAT_SYSCALL_DEFINE4(migrate_pages, compat_pid_t, pid,
513 compat_ulong_t, maxnode,
514 const compat_ulong_t __user *, old_nodes,
515 const compat_ulong_t __user *, new_nodes)
516{
517 unsigned long __user *old = NULL;
518 unsigned long __user *new = NULL;
519 nodemask_t tmp_mask;
520 unsigned long nr_bits;
521 unsigned long size;
522
523 nr_bits = min_t(unsigned long, maxnode - 1, MAX_NUMNODES);
524 size = ALIGN(nr_bits, BITS_PER_LONG) / 8;
525 if (old_nodes) {
526 if (compat_get_bitmap(nodes_addr(tmp_mask), old_nodes, nr_bits))
527 return -EFAULT;
528 old = compat_alloc_user_space(new_nodes ? size * 2 : size);
529 if (new_nodes)
530 new = old + size / sizeof(unsigned long);
531 if (copy_to_user(old, nodes_addr(tmp_mask), size))
532 return -EFAULT;
533 }
534 if (new_nodes) {
535 if (compat_get_bitmap(nodes_addr(tmp_mask), new_nodes, nr_bits))
536 return -EFAULT;
537 if (new == NULL)
538 new = compat_alloc_user_space(size);
539 if (copy_to_user(new, nodes_addr(tmp_mask), size))
540 return -EFAULT;
541 }
542 return sys_migrate_pages(pid, nr_bits + 1, old, new);
543}
544#endif
545
546/* 491/*
547 * Allocate user-space memory for the duration of a single system call, 492 * Allocate user-space memory for the duration of a single system call,
548 * in order to marshall parameters inside a compat thunk. 493 * in order to marshall parameters inside a compat thunk.
diff --git a/kernel/exit.c b/kernel/exit.c
index 995453d9fb55..c3c7ac560114 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1691,7 +1691,7 @@ SYSCALL_DEFINE4(wait4, pid_t, upid, int __user *, stat_addr,
1691 */ 1691 */
1692SYSCALL_DEFINE3(waitpid, pid_t, pid, int __user *, stat_addr, int, options) 1692SYSCALL_DEFINE3(waitpid, pid_t, pid, int __user *, stat_addr, int, options)
1693{ 1693{
1694 return sys_wait4(pid, stat_addr, options, NULL); 1694 return kernel_wait4(pid, stat_addr, options, NULL);
1695} 1695}
1696 1696
1697#endif 1697#endif
diff --git a/kernel/fork.c b/kernel/fork.c
index e5d9d405ae4e..f71b67dc156d 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1198,8 +1198,8 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
1198 * not set up a proper pointer then tough luck. 1198 * not set up a proper pointer then tough luck.
1199 */ 1199 */
1200 put_user(0, tsk->clear_child_tid); 1200 put_user(0, tsk->clear_child_tid);
1201 sys_futex(tsk->clear_child_tid, FUTEX_WAKE, 1201 do_futex(tsk->clear_child_tid, FUTEX_WAKE,
1202 1, NULL, NULL, 0); 1202 1, NULL, NULL, 0, 0);
1203 } 1203 }
1204 tsk->clear_child_tid = NULL; 1204 tsk->clear_child_tid = NULL;
1205 } 1205 }
@@ -2354,7 +2354,7 @@ static int unshare_fd(unsigned long unshare_flags, struct files_struct **new_fdp
2354 * constructed. Here we are modifying the current, active, 2354 * constructed. Here we are modifying the current, active,
2355 * task_struct. 2355 * task_struct.
2356 */ 2356 */
2357SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags) 2357int ksys_unshare(unsigned long unshare_flags)
2358{ 2358{
2359 struct fs_struct *fs, *new_fs = NULL; 2359 struct fs_struct *fs, *new_fs = NULL;
2360 struct files_struct *fd, *new_fd = NULL; 2360 struct files_struct *fd, *new_fd = NULL;
@@ -2470,6 +2470,11 @@ bad_unshare_out:
2470 return err; 2470 return err;
2471} 2471}
2472 2472
2473SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
2474{
2475 return ksys_unshare(unshare_flags);
2476}
2477
2473/* 2478/*
2474 * Helper to unshare the files of the current task. 2479 * Helper to unshare the files of the current task.
2475 * We don't want to expose copy_files internals to 2480 * We don't want to expose copy_files internals to
diff --git a/kernel/kexec.c b/kernel/kexec.c
index e62ec4dc6620..aed8fb2564b3 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -192,11 +192,9 @@ out:
192 * that to happen you need to do that yourself. 192 * that to happen you need to do that yourself.
193 */ 193 */
194 194
195SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments, 195static inline int kexec_load_check(unsigned long nr_segments,
196 struct kexec_segment __user *, segments, unsigned long, flags) 196 unsigned long flags)
197{ 197{
198 int result;
199
200 /* We only trust the superuser with rebooting the system. */ 198 /* We only trust the superuser with rebooting the system. */
201 if (!capable(CAP_SYS_BOOT) || kexec_load_disabled) 199 if (!capable(CAP_SYS_BOOT) || kexec_load_disabled)
202 return -EPERM; 200 return -EPERM;
@@ -208,17 +206,29 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
208 if ((flags & KEXEC_FLAGS) != (flags & ~KEXEC_ARCH_MASK)) 206 if ((flags & KEXEC_FLAGS) != (flags & ~KEXEC_ARCH_MASK))
209 return -EINVAL; 207 return -EINVAL;
210 208
211 /* Verify we are on the appropriate architecture */
212 if (((flags & KEXEC_ARCH_MASK) != KEXEC_ARCH) &&
213 ((flags & KEXEC_ARCH_MASK) != KEXEC_ARCH_DEFAULT))
214 return -EINVAL;
215
216 /* Put an artificial cap on the number 209 /* Put an artificial cap on the number
217 * of segments passed to kexec_load. 210 * of segments passed to kexec_load.
218 */ 211 */
219 if (nr_segments > KEXEC_SEGMENT_MAX) 212 if (nr_segments > KEXEC_SEGMENT_MAX)
220 return -EINVAL; 213 return -EINVAL;
221 214
215 return 0;
216}
217
218SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
219 struct kexec_segment __user *, segments, unsigned long, flags)
220{
221 int result;
222
223 result = kexec_load_check(nr_segments, flags);
224 if (result)
225 return result;
226
227 /* Verify we are on the appropriate architecture */
228 if (((flags & KEXEC_ARCH_MASK) != KEXEC_ARCH) &&
229 ((flags & KEXEC_ARCH_MASK) != KEXEC_ARCH_DEFAULT))
230 return -EINVAL;
231
222 /* Because we write directly to the reserved memory 232 /* Because we write directly to the reserved memory
223 * region when loading crash kernels we need a mutex here to 233 * region when loading crash kernels we need a mutex here to
224 * prevent multiple crash kernels from attempting to load 234 * prevent multiple crash kernels from attempting to load
@@ -247,15 +257,16 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry,
247 struct kexec_segment out, __user *ksegments; 257 struct kexec_segment out, __user *ksegments;
248 unsigned long i, result; 258 unsigned long i, result;
249 259
260 result = kexec_load_check(nr_segments, flags);
261 if (result)
262 return result;
263
250 /* Don't allow clients that don't understand the native 264 /* Don't allow clients that don't understand the native
251 * architecture to do anything. 265 * architecture to do anything.
252 */ 266 */
253 if ((flags & KEXEC_ARCH_MASK) == KEXEC_ARCH_DEFAULT) 267 if ((flags & KEXEC_ARCH_MASK) == KEXEC_ARCH_DEFAULT)
254 return -EINVAL; 268 return -EINVAL;
255 269
256 if (nr_segments > KEXEC_SEGMENT_MAX)
257 return -EINVAL;
258
259 ksegments = compat_alloc_user_space(nr_segments * sizeof(out)); 270 ksegments = compat_alloc_user_space(nr_segments * sizeof(out));
260 for (i = 0; i < nr_segments; i++) { 271 for (i = 0; i < nr_segments; i++) {
261 result = copy_from_user(&in, &segments[i], sizeof(in)); 272 result = copy_from_user(&in, &segments[i], sizeof(in));
@@ -272,6 +283,21 @@ COMPAT_SYSCALL_DEFINE4(kexec_load, compat_ulong_t, entry,
272 return -EFAULT; 283 return -EFAULT;
273 } 284 }
274 285
275 return sys_kexec_load(entry, nr_segments, ksegments, flags); 286 /* Because we write directly to the reserved memory
287 * region when loading crash kernels we need a mutex here to
288 * prevent multiple crash kernels from attempting to load
289 * simultaneously, and to prevent a crash kernel from loading
290 * over the top of a in use crash kernel.
291 *
292 * KISS: always take the mutex.
293 */
294 if (!mutex_trylock(&kexec_mutex))
295 return -EBUSY;
296
297 result = do_kexec_load(entry, nr_segments, ksegments, flags);
298
299 mutex_unlock(&kexec_mutex);
300
301 return result;
276} 302}
277#endif 303#endif
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index 0b53eef7d34b..93b57f026688 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -242,16 +242,16 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
242 242
243 /* 243 /*
244 * Reap the EXIT_ZOMBIE children we had before we ignored SIGCHLD. 244 * Reap the EXIT_ZOMBIE children we had before we ignored SIGCHLD.
245 * sys_wait4() will also block until our children traced from the 245 * kernel_wait4() will also block until our children traced from the
246 * parent namespace are detached and become EXIT_DEAD. 246 * parent namespace are detached and become EXIT_DEAD.
247 */ 247 */
248 do { 248 do {
249 clear_thread_flag(TIF_SIGPENDING); 249 clear_thread_flag(TIF_SIGPENDING);
250 rc = sys_wait4(-1, NULL, __WALL, NULL); 250 rc = kernel_wait4(-1, NULL, __WALL, NULL);
251 } while (rc != -ECHILD); 251 } while (rc != -ECHILD);
252 252
253 /* 253 /*
254 * sys_wait4() above can't reap the EXIT_DEAD children but we do not 254 * kernel_wait4() above can't reap the EXIT_DEAD children but we do not
255 * really care, we could reparent them to the global init. We could 255 * really care, we could reparent them to the global init. We could
256 * exit and reap ->child_reaper even if it is not the last thread in 256 * exit and reap ->child_reaper even if it is not the last thread in
257 * this pid_ns, free_pid(pid_allocated == 0) calls proc_cleanup_work(), 257 * this pid_ns, free_pid(pid_allocated == 0) calls proc_cleanup_work(),
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index a5c36e9c56a6..4710f1b142fc 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -701,7 +701,7 @@ int hibernate(void)
701 } 701 }
702 702
703 pr_info("Syncing filesystems ... \n"); 703 pr_info("Syncing filesystems ... \n");
704 sys_sync(); 704 ksys_sync();
705 pr_info("done.\n"); 705 pr_info("done.\n");
706 706
707 error = freeze_processes(); 707 error = freeze_processes();
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c
index 0685c4499431..4c10be0f4843 100644
--- a/kernel/power/suspend.c
+++ b/kernel/power/suspend.c
@@ -560,7 +560,7 @@ static int enter_state(suspend_state_t state)
560#ifndef CONFIG_SUSPEND_SKIP_SYNC 560#ifndef CONFIG_SUSPEND_SKIP_SYNC
561 trace_suspend_resume(TPS("sync_filesystems"), 0, true); 561 trace_suspend_resume(TPS("sync_filesystems"), 0, true);
562 pr_info("Syncing filesystems ... "); 562 pr_info("Syncing filesystems ... ");
563 sys_sync(); 563 ksys_sync();
564 pr_cont("done.\n"); 564 pr_cont("done.\n");
565 trace_suspend_resume(TPS("sync_filesystems"), 0, false); 565 trace_suspend_resume(TPS("sync_filesystems"), 0, false);
566#endif 566#endif
diff --git a/kernel/power/user.c b/kernel/power/user.c
index 22df9f7ff672..75c959de4b29 100644
--- a/kernel/power/user.c
+++ b/kernel/power/user.c
@@ -224,7 +224,7 @@ static long snapshot_ioctl(struct file *filp, unsigned int cmd,
224 break; 224 break;
225 225
226 printk("Syncing filesystems ... "); 226 printk("Syncing filesystems ... ");
227 sys_sync(); 227 ksys_sync();
228 printk("done.\n"); 228 printk("done.\n");
229 229
230 error = freeze_processes(); 230 error = freeze_processes();
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index de440456f15c..28b68995a417 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4942,7 +4942,7 @@ SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
4942 * 4942 *
4943 * Return: 0. 4943 * Return: 0.
4944 */ 4944 */
4945SYSCALL_DEFINE0(sched_yield) 4945static void do_sched_yield(void)
4946{ 4946{
4947 struct rq_flags rf; 4947 struct rq_flags rf;
4948 struct rq *rq; 4948 struct rq *rq;
@@ -4963,7 +4963,11 @@ SYSCALL_DEFINE0(sched_yield)
4963 sched_preempt_enable_no_resched(); 4963 sched_preempt_enable_no_resched();
4964 4964
4965 schedule(); 4965 schedule();
4966}
4966 4967
4968SYSCALL_DEFINE0(sched_yield)
4969{
4970 do_sched_yield();
4967 return 0; 4971 return 0;
4968} 4972}
4969 4973
@@ -5047,7 +5051,7 @@ EXPORT_SYMBOL(__cond_resched_softirq);
5047void __sched yield(void) 5051void __sched yield(void)
5048{ 5052{
5049 set_current_state(TASK_RUNNING); 5053 set_current_state(TASK_RUNNING);
5050 sys_sched_yield(); 5054 do_sched_yield();
5051} 5055}
5052EXPORT_SYMBOL(yield); 5056EXPORT_SYMBOL(yield);
5053 5057
diff --git a/kernel/signal.c b/kernel/signal.c
index c6e4c83dc090..f04466655238 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -3573,9 +3573,8 @@ int __save_altstack(stack_t __user *uss, unsigned long sp)
3573} 3573}
3574 3574
3575#ifdef CONFIG_COMPAT 3575#ifdef CONFIG_COMPAT
3576COMPAT_SYSCALL_DEFINE2(sigaltstack, 3576static int do_compat_sigaltstack(const compat_stack_t __user *uss_ptr,
3577 const compat_stack_t __user *, uss_ptr, 3577 compat_stack_t __user *uoss_ptr)
3578 compat_stack_t __user *, uoss_ptr)
3579{ 3578{
3580 stack_t uss, uoss; 3579 stack_t uss, uoss;
3581 int ret; 3580 int ret;
@@ -3602,9 +3601,16 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
3602 return ret; 3601 return ret;
3603} 3602}
3604 3603
3604COMPAT_SYSCALL_DEFINE2(sigaltstack,
3605 const compat_stack_t __user *, uss_ptr,
3606 compat_stack_t __user *, uoss_ptr)
3607{
3608 return do_compat_sigaltstack(uss_ptr, uoss_ptr);
3609}
3610
3605int compat_restore_altstack(const compat_stack_t __user *uss) 3611int compat_restore_altstack(const compat_stack_t __user *uss)
3606{ 3612{
3607 int err = compat_sys_sigaltstack(uss, NULL); 3613 int err = do_compat_sigaltstack(uss, NULL);
3608 /* squash all but -EFAULT for now */ 3614 /* squash all but -EFAULT for now */
3609 return err == -EFAULT ? err : 0; 3615 return err == -EFAULT ? err : 0;
3610} 3616}
@@ -3629,11 +3635,20 @@ int __compat_save_altstack(compat_stack_t __user *uss, unsigned long sp)
3629 3635
3630/** 3636/**
3631 * sys_sigpending - examine pending signals 3637 * sys_sigpending - examine pending signals
3632 * @set: where mask of pending signal is returned 3638 * @uset: where mask of pending signal is returned
3633 */ 3639 */
3634SYSCALL_DEFINE1(sigpending, old_sigset_t __user *, set) 3640SYSCALL_DEFINE1(sigpending, old_sigset_t __user *, uset)
3635{ 3641{
3636 return sys_rt_sigpending((sigset_t __user *)set, sizeof(old_sigset_t)); 3642 sigset_t set;
3643 int err;
3644
3645 if (sizeof(old_sigset_t) > sizeof(*uset))
3646 return -EINVAL;
3647
3648 err = do_sigpending(&set);
3649 if (!err && copy_to_user(uset, &set, sizeof(old_sigset_t)))
3650 err = -EFAULT;
3651 return err;
3637} 3652}
3638 3653
3639#ifdef CONFIG_COMPAT 3654#ifdef CONFIG_COMPAT
diff --git a/kernel/sys.c b/kernel/sys.c
index f2289de20e19..ad692183dfe9 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -69,6 +69,8 @@
69#include <asm/io.h> 69#include <asm/io.h>
70#include <asm/unistd.h> 70#include <asm/unistd.h>
71 71
72#include "uid16.h"
73
72#ifndef SET_UNALIGN_CTL 74#ifndef SET_UNALIGN_CTL
73# define SET_UNALIGN_CTL(a, b) (-EINVAL) 75# define SET_UNALIGN_CTL(a, b) (-EINVAL)
74#endif 76#endif
@@ -340,7 +342,7 @@ out_unlock:
340 * operations (as far as semantic preservation is concerned). 342 * operations (as far as semantic preservation is concerned).
341 */ 343 */
342#ifdef CONFIG_MULTIUSER 344#ifdef CONFIG_MULTIUSER
343SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid) 345long __sys_setregid(gid_t rgid, gid_t egid)
344{ 346{
345 struct user_namespace *ns = current_user_ns(); 347 struct user_namespace *ns = current_user_ns();
346 const struct cred *old; 348 const struct cred *old;
@@ -392,12 +394,17 @@ error:
392 return retval; 394 return retval;
393} 395}
394 396
397SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
398{
399 return __sys_setregid(rgid, egid);
400}
401
395/* 402/*
396 * setgid() is implemented like SysV w/ SAVED_IDS 403 * setgid() is implemented like SysV w/ SAVED_IDS
397 * 404 *
398 * SMP: Same implicit races as above. 405 * SMP: Same implicit races as above.
399 */ 406 */
400SYSCALL_DEFINE1(setgid, gid_t, gid) 407long __sys_setgid(gid_t gid)
401{ 408{
402 struct user_namespace *ns = current_user_ns(); 409 struct user_namespace *ns = current_user_ns();
403 const struct cred *old; 410 const struct cred *old;
@@ -429,6 +436,11 @@ error:
429 return retval; 436 return retval;
430} 437}
431 438
439SYSCALL_DEFINE1(setgid, gid_t, gid)
440{
441 return __sys_setgid(gid);
442}
443
432/* 444/*
433 * change the user struct in a credentials set to match the new UID 445 * change the user struct in a credentials set to match the new UID
434 */ 446 */
@@ -473,7 +485,7 @@ static int set_user(struct cred *new)
473 * 100% compatible with BSD. A program which uses just setuid() will be 485 * 100% compatible with BSD. A program which uses just setuid() will be
474 * 100% compatible with POSIX with saved IDs. 486 * 100% compatible with POSIX with saved IDs.
475 */ 487 */
476SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid) 488long __sys_setreuid(uid_t ruid, uid_t euid)
477{ 489{
478 struct user_namespace *ns = current_user_ns(); 490 struct user_namespace *ns = current_user_ns();
479 const struct cred *old; 491 const struct cred *old;
@@ -533,6 +545,11 @@ error:
533 return retval; 545 return retval;
534} 546}
535 547
548SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
549{
550 return __sys_setreuid(ruid, euid);
551}
552
536/* 553/*
537 * setuid() is implemented like SysV with SAVED_IDS 554 * setuid() is implemented like SysV with SAVED_IDS
538 * 555 *
@@ -544,7 +561,7 @@ error:
544 * will allow a root program to temporarily drop privileges and be able to 561 * will allow a root program to temporarily drop privileges and be able to
545 * regain them by swapping the real and effective uid. 562 * regain them by swapping the real and effective uid.
546 */ 563 */
547SYSCALL_DEFINE1(setuid, uid_t, uid) 564long __sys_setuid(uid_t uid)
548{ 565{
549 struct user_namespace *ns = current_user_ns(); 566 struct user_namespace *ns = current_user_ns();
550 const struct cred *old; 567 const struct cred *old;
@@ -586,12 +603,17 @@ error:
586 return retval; 603 return retval;
587} 604}
588 605
606SYSCALL_DEFINE1(setuid, uid_t, uid)
607{
608 return __sys_setuid(uid);
609}
610
589 611
590/* 612/*
591 * This function implements a generic ability to update ruid, euid, 613 * This function implements a generic ability to update ruid, euid,
592 * and suid. This allows you to implement the 4.4 compatible seteuid(). 614 * and suid. This allows you to implement the 4.4 compatible seteuid().
593 */ 615 */
594SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid) 616long __sys_setresuid(uid_t ruid, uid_t euid, uid_t suid)
595{ 617{
596 struct user_namespace *ns = current_user_ns(); 618 struct user_namespace *ns = current_user_ns();
597 const struct cred *old; 619 const struct cred *old;
@@ -656,6 +678,11 @@ error:
656 return retval; 678 return retval;
657} 679}
658 680
681SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
682{
683 return __sys_setresuid(ruid, euid, suid);
684}
685
659SYSCALL_DEFINE3(getresuid, uid_t __user *, ruidp, uid_t __user *, euidp, uid_t __user *, suidp) 686SYSCALL_DEFINE3(getresuid, uid_t __user *, ruidp, uid_t __user *, euidp, uid_t __user *, suidp)
660{ 687{
661 const struct cred *cred = current_cred(); 688 const struct cred *cred = current_cred();
@@ -678,7 +705,7 @@ SYSCALL_DEFINE3(getresuid, uid_t __user *, ruidp, uid_t __user *, euidp, uid_t _
678/* 705/*
679 * Same as above, but for rgid, egid, sgid. 706 * Same as above, but for rgid, egid, sgid.
680 */ 707 */
681SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid) 708long __sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid)
682{ 709{
683 struct user_namespace *ns = current_user_ns(); 710 struct user_namespace *ns = current_user_ns();
684 const struct cred *old; 711 const struct cred *old;
@@ -730,6 +757,11 @@ error:
730 return retval; 757 return retval;
731} 758}
732 759
760SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
761{
762 return __sys_setresgid(rgid, egid, sgid);
763}
764
733SYSCALL_DEFINE3(getresgid, gid_t __user *, rgidp, gid_t __user *, egidp, gid_t __user *, sgidp) 765SYSCALL_DEFINE3(getresgid, gid_t __user *, rgidp, gid_t __user *, egidp, gid_t __user *, sgidp)
734{ 766{
735 const struct cred *cred = current_cred(); 767 const struct cred *cred = current_cred();
@@ -757,7 +789,7 @@ SYSCALL_DEFINE3(getresgid, gid_t __user *, rgidp, gid_t __user *, egidp, gid_t _
757 * whatever uid it wants to). It normally shadows "euid", except when 789 * whatever uid it wants to). It normally shadows "euid", except when
758 * explicitly set by setfsuid() or for access.. 790 * explicitly set by setfsuid() or for access..
759 */ 791 */
760SYSCALL_DEFINE1(setfsuid, uid_t, uid) 792long __sys_setfsuid(uid_t uid)
761{ 793{
762 const struct cred *old; 794 const struct cred *old;
763 struct cred *new; 795 struct cred *new;
@@ -793,10 +825,15 @@ change_okay:
793 return old_fsuid; 825 return old_fsuid;
794} 826}
795 827
828SYSCALL_DEFINE1(setfsuid, uid_t, uid)
829{
830 return __sys_setfsuid(uid);
831}
832
796/* 833/*
797 * Samma på svenska.. 834 * Samma på svenska..
798 */ 835 */
799SYSCALL_DEFINE1(setfsgid, gid_t, gid) 836long __sys_setfsgid(gid_t gid)
800{ 837{
801 const struct cred *old; 838 const struct cred *old;
802 struct cred *new; 839 struct cred *new;
@@ -830,6 +867,11 @@ change_okay:
830 commit_creds(new); 867 commit_creds(new);
831 return old_fsgid; 868 return old_fsgid;
832} 869}
870
871SYSCALL_DEFINE1(setfsgid, gid_t, gid)
872{
873 return __sys_setfsgid(gid);
874}
833#endif /* CONFIG_MULTIUSER */ 875#endif /* CONFIG_MULTIUSER */
834 876
835/** 877/**
@@ -1027,7 +1069,7 @@ out:
1027 return err; 1069 return err;
1028} 1070}
1029 1071
1030SYSCALL_DEFINE1(getpgid, pid_t, pid) 1072static int do_getpgid(pid_t pid)
1031{ 1073{
1032 struct task_struct *p; 1074 struct task_struct *p;
1033 struct pid *grp; 1075 struct pid *grp;
@@ -1055,11 +1097,16 @@ out:
1055 return retval; 1097 return retval;
1056} 1098}
1057 1099
1100SYSCALL_DEFINE1(getpgid, pid_t, pid)
1101{
1102 return do_getpgid(pid);
1103}
1104
1058#ifdef __ARCH_WANT_SYS_GETPGRP 1105#ifdef __ARCH_WANT_SYS_GETPGRP
1059 1106
1060SYSCALL_DEFINE0(getpgrp) 1107SYSCALL_DEFINE0(getpgrp)
1061{ 1108{
1062 return sys_getpgid(0); 1109 return do_getpgid(0);
1063} 1110}
1064 1111
1065#endif 1112#endif
@@ -1103,7 +1150,7 @@ static void set_special_pids(struct pid *pid)
1103 change_pid(curr, PIDTYPE_PGID, pid); 1150 change_pid(curr, PIDTYPE_PGID, pid);
1104} 1151}
1105 1152
1106SYSCALL_DEFINE0(setsid) 1153int ksys_setsid(void)
1107{ 1154{
1108 struct task_struct *group_leader = current->group_leader; 1155 struct task_struct *group_leader = current->group_leader;
1109 struct pid *sid = task_pid(group_leader); 1156 struct pid *sid = task_pid(group_leader);
@@ -1136,6 +1183,11 @@ out:
1136 return err; 1183 return err;
1137} 1184}
1138 1185
1186SYSCALL_DEFINE0(setsid)
1187{
1188 return ksys_setsid();
1189}
1190
1139DECLARE_RWSEM(uts_sem); 1191DECLARE_RWSEM(uts_sem);
1140 1192
1141#ifdef COMPAT_UTS_MACHINE 1193#ifdef COMPAT_UTS_MACHINE
diff --git a/kernel/sys_ni.c b/kernel/sys_ni.c
index b5189762d275..6cafc008f6db 100644
--- a/kernel/sys_ni.c
+++ b/kernel/sys_ni.c
@@ -17,245 +17,406 @@ asmlinkage long sys_ni_syscall(void)
17 return -ENOSYS; 17 return -ENOSYS;
18} 18}
19 19
20cond_syscall(sys_quotactl); 20#define COND_SYSCALL(name) cond_syscall(sys_##name)
21cond_syscall(sys32_quotactl); 21#define COND_SYSCALL_COMPAT(name) cond_syscall(compat_sys_##name)
22cond_syscall(sys_acct); 22
23cond_syscall(sys_lookup_dcookie); 23/*
24cond_syscall(compat_sys_lookup_dcookie); 24 * This list is kept in the same order as include/uapi/asm-generic/unistd.h.
25cond_syscall(sys_swapon); 25 * Architecture specific entries go below, followed by deprecated or obsolete
26cond_syscall(sys_swapoff); 26 * system calls.
27cond_syscall(sys_kexec_load); 27 */
28cond_syscall(compat_sys_kexec_load); 28
29cond_syscall(sys_kexec_file_load); 29COND_SYSCALL(io_setup);
30cond_syscall(sys_init_module); 30COND_SYSCALL_COMPAT(io_setup);
31cond_syscall(sys_finit_module); 31COND_SYSCALL(io_destroy);
32cond_syscall(sys_delete_module); 32COND_SYSCALL(io_submit);
33cond_syscall(sys_socketpair); 33COND_SYSCALL_COMPAT(io_submit);
34cond_syscall(sys_bind); 34COND_SYSCALL(io_cancel);
35cond_syscall(sys_listen); 35COND_SYSCALL(io_getevents);
36cond_syscall(sys_accept); 36COND_SYSCALL_COMPAT(io_getevents);
37cond_syscall(sys_accept4); 37
38cond_syscall(sys_connect); 38/* fs/xattr.c */
39cond_syscall(sys_getsockname); 39
40cond_syscall(sys_getpeername); 40/* fs/dcache.c */
41cond_syscall(sys_sendto); 41
42cond_syscall(sys_send); 42/* fs/cookies.c */
43cond_syscall(sys_recvfrom); 43COND_SYSCALL(lookup_dcookie);
44cond_syscall(sys_recv); 44COND_SYSCALL_COMPAT(lookup_dcookie);
45cond_syscall(sys_socket); 45
46cond_syscall(sys_setsockopt); 46/* fs/eventfd.c */
47cond_syscall(compat_sys_setsockopt); 47COND_SYSCALL(eventfd2);
48cond_syscall(sys_getsockopt); 48
49cond_syscall(compat_sys_getsockopt); 49/* fs/eventfd.c */
50cond_syscall(sys_shutdown); 50COND_SYSCALL(epoll_create1);
51cond_syscall(sys_sendmsg); 51COND_SYSCALL(epoll_ctl);
52cond_syscall(sys_sendmmsg); 52COND_SYSCALL(epoll_pwait);
53cond_syscall(compat_sys_sendmsg); 53COND_SYSCALL_COMPAT(epoll_pwait);
54cond_syscall(compat_sys_sendmmsg); 54
55cond_syscall(sys_recvmsg); 55/* fs/fcntl.c */
56cond_syscall(sys_recvmmsg); 56
57cond_syscall(compat_sys_recvmsg); 57/* fs/inotify_user.c */
58cond_syscall(compat_sys_recv); 58COND_SYSCALL(inotify_init1);
59cond_syscall(compat_sys_recvfrom); 59COND_SYSCALL(inotify_add_watch);
60cond_syscall(compat_sys_recvmmsg); 60COND_SYSCALL(inotify_rm_watch);
61cond_syscall(sys_socketcall); 61
62cond_syscall(sys_futex); 62/* fs/ioctl.c */
63cond_syscall(compat_sys_futex); 63
64cond_syscall(sys_set_robust_list); 64/* fs/ioprio.c */
65cond_syscall(compat_sys_set_robust_list); 65COND_SYSCALL(ioprio_set);
66cond_syscall(sys_get_robust_list); 66COND_SYSCALL(ioprio_get);
67cond_syscall(compat_sys_get_robust_list); 67
68cond_syscall(sys_epoll_create); 68/* fs/locks.c */
69cond_syscall(sys_epoll_create1); 69COND_SYSCALL(flock);
70cond_syscall(sys_epoll_ctl); 70
71cond_syscall(sys_epoll_wait); 71/* fs/namei.c */
72cond_syscall(sys_epoll_pwait); 72
73cond_syscall(compat_sys_epoll_pwait); 73/* fs/namespace.c */
74cond_syscall(sys_semget); 74
75cond_syscall(sys_semop); 75/* fs/nfsctl.c */
76cond_syscall(sys_semtimedop); 76
77cond_syscall(compat_sys_semtimedop); 77/* fs/open.c */
78cond_syscall(sys_semctl); 78
79cond_syscall(compat_sys_semctl); 79/* fs/pipe.c */
80cond_syscall(sys_msgget); 80
81cond_syscall(sys_msgsnd); 81/* fs/quota.c */
82cond_syscall(compat_sys_msgsnd); 82COND_SYSCALL(quotactl);
83cond_syscall(sys_msgrcv); 83
84cond_syscall(compat_sys_msgrcv); 84/* fs/readdir.c */
85cond_syscall(sys_msgctl); 85
86cond_syscall(compat_sys_msgctl); 86/* fs/read_write.c */
87cond_syscall(sys_shmget); 87
88cond_syscall(sys_shmat); 88/* fs/sendfile.c */
89cond_syscall(compat_sys_shmat); 89
90cond_syscall(sys_shmdt); 90/* fs/select.c */
91cond_syscall(sys_shmctl); 91
92cond_syscall(compat_sys_shmctl); 92/* fs/signalfd.c */
93cond_syscall(sys_mq_open); 93COND_SYSCALL(signalfd4);
94cond_syscall(sys_mq_unlink); 94COND_SYSCALL_COMPAT(signalfd4);
95cond_syscall(sys_mq_timedsend); 95
96cond_syscall(sys_mq_timedreceive); 96/* fs/splice.c */
97cond_syscall(sys_mq_notify); 97
98cond_syscall(sys_mq_getsetattr); 98/* fs/stat.c */
99cond_syscall(compat_sys_mq_open); 99
100cond_syscall(compat_sys_mq_timedsend); 100/* fs/sync.c */
101cond_syscall(compat_sys_mq_timedreceive); 101
102cond_syscall(compat_sys_mq_notify); 102/* fs/timerfd.c */
103cond_syscall(compat_sys_mq_getsetattr); 103COND_SYSCALL(timerfd_create);
104cond_syscall(sys_mbind); 104COND_SYSCALL(timerfd_settime);
105cond_syscall(sys_get_mempolicy); 105COND_SYSCALL_COMPAT(timerfd_settime);
106cond_syscall(sys_set_mempolicy); 106COND_SYSCALL(timerfd_gettime);
107cond_syscall(compat_sys_mbind); 107COND_SYSCALL_COMPAT(timerfd_gettime);
108cond_syscall(compat_sys_get_mempolicy); 108
109cond_syscall(compat_sys_set_mempolicy); 109/* fs/utimes.c */
110cond_syscall(sys_add_key); 110
111cond_syscall(sys_request_key); 111/* kernel/acct.c */
112cond_syscall(sys_keyctl); 112COND_SYSCALL(acct);
113cond_syscall(compat_sys_keyctl); 113
114cond_syscall(compat_sys_socketcall); 114/* kernel/capability.c */
115cond_syscall(sys_inotify_init); 115COND_SYSCALL(capget);
116cond_syscall(sys_inotify_init1); 116COND_SYSCALL(capset);
117cond_syscall(sys_inotify_add_watch); 117
118cond_syscall(sys_inotify_rm_watch); 118/* kernel/exec_domain.c */
119cond_syscall(sys_migrate_pages); 119
120cond_syscall(sys_move_pages); 120/* kernel/exit.c */
121cond_syscall(sys_chown16); 121
122cond_syscall(sys_fchown16); 122/* kernel/fork.c */
123cond_syscall(sys_getegid16); 123
124cond_syscall(sys_geteuid16); 124/* kernel/futex.c */
125cond_syscall(sys_getgid16); 125COND_SYSCALL(futex);
126cond_syscall(sys_getgroups16); 126COND_SYSCALL_COMPAT(futex);
127cond_syscall(sys_getresgid16); 127COND_SYSCALL(set_robust_list);
128cond_syscall(sys_getresuid16); 128COND_SYSCALL_COMPAT(set_robust_list);
129cond_syscall(sys_getuid16); 129COND_SYSCALL(get_robust_list);
130cond_syscall(sys_lchown16); 130COND_SYSCALL_COMPAT(get_robust_list);
131cond_syscall(sys_setfsgid16); 131
132cond_syscall(sys_setfsuid16); 132/* kernel/hrtimer.c */
133cond_syscall(sys_setgid16); 133
134cond_syscall(sys_setgroups16); 134/* kernel/itimer.c */
135cond_syscall(sys_setregid16); 135
136cond_syscall(sys_setresgid16); 136/* kernel/kexec.c */
137cond_syscall(sys_setresuid16); 137COND_SYSCALL(kexec_load);
138cond_syscall(sys_setreuid16); 138COND_SYSCALL_COMPAT(kexec_load);
139cond_syscall(sys_setuid16); 139
140cond_syscall(sys_sgetmask); 140/* kernel/module.c */
141cond_syscall(sys_ssetmask); 141COND_SYSCALL(init_module);
142cond_syscall(sys_vm86old); 142COND_SYSCALL(delete_module);
143cond_syscall(sys_vm86); 143
144cond_syscall(sys_modify_ldt); 144/* kernel/posix-timers.c */
145cond_syscall(sys_ipc); 145
146cond_syscall(compat_sys_ipc); 146/* kernel/printk.c */
147cond_syscall(compat_sys_sysctl); 147COND_SYSCALL(syslog);
148cond_syscall(sys_flock); 148
149cond_syscall(sys_io_setup); 149/* kernel/ptrace.c */
150cond_syscall(sys_io_destroy); 150
151cond_syscall(sys_io_submit); 151/* kernel/sched/core.c */
152cond_syscall(sys_io_cancel); 152
153cond_syscall(sys_io_getevents); 153/* kernel/signal.c */
154cond_syscall(compat_sys_io_setup); 154
155cond_syscall(compat_sys_io_submit); 155/* kernel/sys.c */
156cond_syscall(compat_sys_io_getevents); 156COND_SYSCALL(setregid);
157cond_syscall(sys_sysfs); 157COND_SYSCALL(setgid);
158cond_syscall(sys_syslog); 158COND_SYSCALL(setreuid);
159cond_syscall(sys_process_vm_readv); 159COND_SYSCALL(setuid);
160cond_syscall(sys_process_vm_writev); 160COND_SYSCALL(setresuid);
161cond_syscall(compat_sys_process_vm_readv); 161COND_SYSCALL(getresuid);
162cond_syscall(compat_sys_process_vm_writev); 162COND_SYSCALL(setresgid);
163cond_syscall(sys_uselib); 163COND_SYSCALL(getresgid);
164cond_syscall(sys_fadvise64); 164COND_SYSCALL(setfsuid);
165cond_syscall(sys_fadvise64_64); 165COND_SYSCALL(setfsgid);
166cond_syscall(sys_madvise); 166COND_SYSCALL(setgroups);
167cond_syscall(sys_setuid); 167COND_SYSCALL(getgroups);
168cond_syscall(sys_setregid); 168
169cond_syscall(sys_setgid); 169/* kernel/time.c */
170cond_syscall(sys_setreuid); 170
171cond_syscall(sys_setresuid); 171/* kernel/timer.c */
172cond_syscall(sys_getresuid); 172
173cond_syscall(sys_setresgid); 173/* ipc/mqueue.c */
174cond_syscall(sys_getresgid); 174COND_SYSCALL(mq_open);
175cond_syscall(sys_setgroups); 175COND_SYSCALL_COMPAT(mq_open);
176cond_syscall(sys_getgroups); 176COND_SYSCALL(mq_unlink);
177cond_syscall(sys_setfsuid); 177COND_SYSCALL(mq_timedsend);
178cond_syscall(sys_setfsgid); 178COND_SYSCALL_COMPAT(mq_timedsend);
179cond_syscall(sys_capget); 179COND_SYSCALL(mq_timedreceive);
180cond_syscall(sys_capset); 180COND_SYSCALL_COMPAT(mq_timedreceive);
181cond_syscall(sys_copy_file_range); 181COND_SYSCALL(mq_notify);
182 182COND_SYSCALL_COMPAT(mq_notify);
183/* arch-specific weak syscall entries */ 183COND_SYSCALL(mq_getsetattr);
184cond_syscall(sys_pciconfig_read); 184COND_SYSCALL_COMPAT(mq_getsetattr);
185cond_syscall(sys_pciconfig_write); 185
186cond_syscall(sys_pciconfig_iobase); 186/* ipc/msg.c */
187cond_syscall(compat_sys_s390_ipc); 187COND_SYSCALL(msgget);
188cond_syscall(ppc_rtas); 188COND_SYSCALL(msgctl);
189cond_syscall(sys_spu_run); 189COND_SYSCALL_COMPAT(msgctl);
190cond_syscall(sys_spu_create); 190COND_SYSCALL(msgrcv);
191cond_syscall(sys_subpage_prot); 191COND_SYSCALL_COMPAT(msgrcv);
192cond_syscall(sys_s390_pci_mmio_read); 192COND_SYSCALL(msgsnd);
193cond_syscall(sys_s390_pci_mmio_write); 193COND_SYSCALL_COMPAT(msgsnd);
194 194
195/* mmu depending weak syscall entries */ 195/* ipc/sem.c */
196cond_syscall(sys_mprotect); 196COND_SYSCALL(semget);
197cond_syscall(sys_msync); 197COND_SYSCALL(semctl);
198cond_syscall(sys_mlock); 198COND_SYSCALL_COMPAT(semctl);
199cond_syscall(sys_munlock); 199COND_SYSCALL(semtimedop);
200cond_syscall(sys_mlockall); 200COND_SYSCALL_COMPAT(semtimedop);
201cond_syscall(sys_munlockall); 201COND_SYSCALL(semop);
202cond_syscall(sys_mlock2); 202
203cond_syscall(sys_mincore); 203/* ipc/shm.c */
204cond_syscall(sys_madvise); 204COND_SYSCALL(shmget);
205cond_syscall(sys_mremap); 205COND_SYSCALL(shmctl);
206cond_syscall(sys_remap_file_pages); 206COND_SYSCALL_COMPAT(shmctl);
207cond_syscall(compat_sys_move_pages); 207COND_SYSCALL(shmat);
208cond_syscall(compat_sys_migrate_pages); 208COND_SYSCALL_COMPAT(shmat);
209 209COND_SYSCALL(shmdt);
210/* block-layer dependent */ 210
211cond_syscall(sys_bdflush); 211/* net/socket.c */
212cond_syscall(sys_ioprio_set); 212COND_SYSCALL(socket);
213cond_syscall(sys_ioprio_get); 213COND_SYSCALL(socketpair);
214 214COND_SYSCALL(bind);
215/* New file descriptors */ 215COND_SYSCALL(listen);
216cond_syscall(sys_signalfd); 216COND_SYSCALL(accept);
217cond_syscall(sys_signalfd4); 217COND_SYSCALL(connect);
218cond_syscall(compat_sys_signalfd); 218COND_SYSCALL(getsockname);
219cond_syscall(compat_sys_signalfd4); 219COND_SYSCALL(getpeername);
220cond_syscall(sys_timerfd_create); 220COND_SYSCALL(setsockopt);
221cond_syscall(sys_timerfd_settime); 221COND_SYSCALL_COMPAT(setsockopt);
222cond_syscall(sys_timerfd_gettime); 222COND_SYSCALL(getsockopt);
223cond_syscall(compat_sys_timerfd_settime); 223COND_SYSCALL_COMPAT(getsockopt);
224cond_syscall(compat_sys_timerfd_gettime); 224COND_SYSCALL(sendto);
225cond_syscall(sys_eventfd); 225COND_SYSCALL(shutdown);
226cond_syscall(sys_eventfd2); 226COND_SYSCALL(recvfrom);
227cond_syscall(sys_memfd_create); 227COND_SYSCALL_COMPAT(recvfrom);
228cond_syscall(sys_userfaultfd); 228COND_SYSCALL(sendmsg);
229 229COND_SYSCALL_COMPAT(sendmsg);
230/* performance counters: */ 230COND_SYSCALL(recvmsg);
231cond_syscall(sys_perf_event_open); 231COND_SYSCALL_COMPAT(recvmsg);
232 232
233/* fanotify! */ 233/* mm/filemap.c */
234cond_syscall(sys_fanotify_init); 234
235cond_syscall(sys_fanotify_mark); 235/* mm/nommu.c, also with MMU */
236cond_syscall(compat_sys_fanotify_mark); 236COND_SYSCALL(mremap);
237
238/* security/keys/keyctl.c */
239COND_SYSCALL(add_key);
240COND_SYSCALL(request_key);
241COND_SYSCALL(keyctl);
242COND_SYSCALL_COMPAT(keyctl);
243
244/* arch/example/kernel/sys_example.c */
245
246/* mm/fadvise.c */
247COND_SYSCALL(fadvise64_64);
248
249/* mm/, CONFIG_MMU only */
250COND_SYSCALL(swapon);
251COND_SYSCALL(swapoff);
252COND_SYSCALL(mprotect);
253COND_SYSCALL(msync);
254COND_SYSCALL(mlock);
255COND_SYSCALL(munlock);
256COND_SYSCALL(mlockall);
257COND_SYSCALL(munlockall);
258COND_SYSCALL(mincore);
259COND_SYSCALL(madvise);
260COND_SYSCALL(remap_file_pages);
261COND_SYSCALL(mbind);
262COND_SYSCALL_COMPAT(mbind);
263COND_SYSCALL(get_mempolicy);
264COND_SYSCALL_COMPAT(get_mempolicy);
265COND_SYSCALL(set_mempolicy);
266COND_SYSCALL_COMPAT(set_mempolicy);
267COND_SYSCALL(migrate_pages);
268COND_SYSCALL_COMPAT(migrate_pages);
269COND_SYSCALL(move_pages);
270COND_SYSCALL_COMPAT(move_pages);
271
272COND_SYSCALL(perf_event_open);
273COND_SYSCALL(accept4);
274COND_SYSCALL(recvmmsg);
275COND_SYSCALL_COMPAT(recvmmsg);
276
277/*
278 * Architecture specific syscalls: see further below
279 */
280
281/* fanotify */
282COND_SYSCALL(fanotify_init);
283COND_SYSCALL(fanotify_mark);
237 284
238/* open by handle */ 285/* open by handle */
239cond_syscall(sys_name_to_handle_at); 286COND_SYSCALL(name_to_handle_at);
240cond_syscall(sys_open_by_handle_at); 287COND_SYSCALL(open_by_handle_at);
241cond_syscall(compat_sys_open_by_handle_at); 288COND_SYSCALL_COMPAT(open_by_handle_at);
289
290COND_SYSCALL(sendmmsg);
291COND_SYSCALL_COMPAT(sendmmsg);
292COND_SYSCALL(process_vm_readv);
293COND_SYSCALL_COMPAT(process_vm_readv);
294COND_SYSCALL(process_vm_writev);
295COND_SYSCALL_COMPAT(process_vm_writev);
242 296
243/* compare kernel pointers */ 297/* compare kernel pointers */
244cond_syscall(sys_kcmp); 298COND_SYSCALL(kcmp);
299
300COND_SYSCALL(finit_module);
245 301
246/* operate on Secure Computing state */ 302/* operate on Secure Computing state */
247cond_syscall(sys_seccomp); 303COND_SYSCALL(seccomp);
304
305COND_SYSCALL(memfd_create);
248 306
249/* access BPF programs and maps */ 307/* access BPF programs and maps */
250cond_syscall(sys_bpf); 308COND_SYSCALL(bpf);
251 309
252/* execveat */ 310/* execveat */
253cond_syscall(sys_execveat); 311COND_SYSCALL(execveat);
312
313COND_SYSCALL(userfaultfd);
254 314
255/* membarrier */ 315/* membarrier */
256cond_syscall(sys_membarrier); 316COND_SYSCALL(membarrier);
317
318COND_SYSCALL(mlock2);
319
320COND_SYSCALL(copy_file_range);
257 321
258/* memory protection keys */ 322/* memory protection keys */
259cond_syscall(sys_pkey_mprotect); 323COND_SYSCALL(pkey_mprotect);
260cond_syscall(sys_pkey_alloc); 324COND_SYSCALL(pkey_alloc);
261cond_syscall(sys_pkey_free); 325COND_SYSCALL(pkey_free);
326
327
328/*
329 * Architecture specific weak syscall entries.
330 */
331
332/* pciconfig: alpha, arm, arm64, ia64, sparc */
333COND_SYSCALL(pciconfig_read);
334COND_SYSCALL(pciconfig_write);
335COND_SYSCALL(pciconfig_iobase);
336
337/* sys_socketcall: arm, mips, x86, ... */
338COND_SYSCALL(socketcall);
339COND_SYSCALL_COMPAT(socketcall);
340
341/* compat syscalls for arm64, x86, ... */
342COND_SYSCALL_COMPAT(sysctl);
343COND_SYSCALL_COMPAT(fanotify_mark);
344
345/* x86 */
346COND_SYSCALL(vm86old);
347COND_SYSCALL(modify_ldt);
348COND_SYSCALL_COMPAT(quotactl32);
349COND_SYSCALL(vm86);
350COND_SYSCALL(kexec_file_load);
351
352/* s390 */
353COND_SYSCALL(s390_pci_mmio_read);
354COND_SYSCALL(s390_pci_mmio_write);
355COND_SYSCALL_COMPAT(s390_ipc);
356
357/* powerpc */
358cond_syscall(ppc_rtas);
359COND_SYSCALL(spu_run);
360COND_SYSCALL(spu_create);
361COND_SYSCALL(subpage_prot);
362
363
364/*
365 * Deprecated system calls which are still defined in
366 * include/uapi/asm-generic/unistd.h and wanted by >= 1 arch
367 */
368
369/* __ARCH_WANT_SYSCALL_NO_FLAGS */
370COND_SYSCALL(epoll_create);
371COND_SYSCALL(inotify_init);
372COND_SYSCALL(eventfd);
373COND_SYSCALL(signalfd);
374COND_SYSCALL_COMPAT(signalfd);
375
376/* __ARCH_WANT_SYSCALL_OFF_T */
377COND_SYSCALL(fadvise64);
378
379/* __ARCH_WANT_SYSCALL_DEPRECATED */
380COND_SYSCALL(epoll_wait);
381COND_SYSCALL(recv);
382COND_SYSCALL_COMPAT(recv);
383COND_SYSCALL(send);
384COND_SYSCALL(bdflush);
385COND_SYSCALL(uselib);
386
387
388/*
389 * The syscalls below are not found in include/uapi/asm-generic/unistd.h
390 */
391
392/* obsolete: SGETMASK_SYSCALL */
393COND_SYSCALL(sgetmask);
394COND_SYSCALL(ssetmask);
395
396/* obsolete: SYSFS_SYSCALL */
397COND_SYSCALL(sysfs);
398
399/* obsolete: __ARCH_WANT_SYS_IPC */
400COND_SYSCALL(ipc);
401COND_SYSCALL_COMPAT(ipc);
402
403/* obsolete: UID16 */
404COND_SYSCALL(chown16);
405COND_SYSCALL(fchown16);
406COND_SYSCALL(getegid16);
407COND_SYSCALL(geteuid16);
408COND_SYSCALL(getgid16);
409COND_SYSCALL(getgroups16);
410COND_SYSCALL(getresgid16);
411COND_SYSCALL(getresuid16);
412COND_SYSCALL(getuid16);
413COND_SYSCALL(lchown16);
414COND_SYSCALL(setfsgid16);
415COND_SYSCALL(setfsuid16);
416COND_SYSCALL(setgid16);
417COND_SYSCALL(setgroups16);
418COND_SYSCALL(setregid16);
419COND_SYSCALL(setresgid16);
420COND_SYSCALL(setresuid16);
421COND_SYSCALL(setreuid16);
422COND_SYSCALL(setuid16);
diff --git a/kernel/uid16.c b/kernel/uid16.c
index ef1da2a5f9bd..af6925d8599b 100644
--- a/kernel/uid16.c
+++ b/kernel/uid16.c
@@ -18,44 +18,46 @@
18 18
19#include <linux/uaccess.h> 19#include <linux/uaccess.h>
20 20
21#include "uid16.h"
22
21SYSCALL_DEFINE3(chown16, const char __user *, filename, old_uid_t, user, old_gid_t, group) 23SYSCALL_DEFINE3(chown16, const char __user *, filename, old_uid_t, user, old_gid_t, group)
22{ 24{
23 return sys_chown(filename, low2highuid(user), low2highgid(group)); 25 return ksys_chown(filename, low2highuid(user), low2highgid(group));
24} 26}
25 27
26SYSCALL_DEFINE3(lchown16, const char __user *, filename, old_uid_t, user, old_gid_t, group) 28SYSCALL_DEFINE3(lchown16, const char __user *, filename, old_uid_t, user, old_gid_t, group)
27{ 29{
28 return sys_lchown(filename, low2highuid(user), low2highgid(group)); 30 return ksys_lchown(filename, low2highuid(user), low2highgid(group));
29} 31}
30 32
31SYSCALL_DEFINE3(fchown16, unsigned int, fd, old_uid_t, user, old_gid_t, group) 33SYSCALL_DEFINE3(fchown16, unsigned int, fd, old_uid_t, user, old_gid_t, group)
32{ 34{
33 return sys_fchown(fd, low2highuid(user), low2highgid(group)); 35 return ksys_fchown(fd, low2highuid(user), low2highgid(group));
34} 36}
35 37
36SYSCALL_DEFINE2(setregid16, old_gid_t, rgid, old_gid_t, egid) 38SYSCALL_DEFINE2(setregid16, old_gid_t, rgid, old_gid_t, egid)
37{ 39{
38 return sys_setregid(low2highgid(rgid), low2highgid(egid)); 40 return __sys_setregid(low2highgid(rgid), low2highgid(egid));
39} 41}
40 42
41SYSCALL_DEFINE1(setgid16, old_gid_t, gid) 43SYSCALL_DEFINE1(setgid16, old_gid_t, gid)
42{ 44{
43 return sys_setgid(low2highgid(gid)); 45 return __sys_setgid(low2highgid(gid));
44} 46}
45 47
46SYSCALL_DEFINE2(setreuid16, old_uid_t, ruid, old_uid_t, euid) 48SYSCALL_DEFINE2(setreuid16, old_uid_t, ruid, old_uid_t, euid)
47{ 49{
48 return sys_setreuid(low2highuid(ruid), low2highuid(euid)); 50 return __sys_setreuid(low2highuid(ruid), low2highuid(euid));
49} 51}
50 52
51SYSCALL_DEFINE1(setuid16, old_uid_t, uid) 53SYSCALL_DEFINE1(setuid16, old_uid_t, uid)
52{ 54{
53 return sys_setuid(low2highuid(uid)); 55 return __sys_setuid(low2highuid(uid));
54} 56}
55 57
56SYSCALL_DEFINE3(setresuid16, old_uid_t, ruid, old_uid_t, euid, old_uid_t, suid) 58SYSCALL_DEFINE3(setresuid16, old_uid_t, ruid, old_uid_t, euid, old_uid_t, suid)
57{ 59{
58 return sys_setresuid(low2highuid(ruid), low2highuid(euid), 60 return __sys_setresuid(low2highuid(ruid), low2highuid(euid),
59 low2highuid(suid)); 61 low2highuid(suid));
60} 62}
61 63
@@ -78,11 +80,10 @@ SYSCALL_DEFINE3(getresuid16, old_uid_t __user *, ruidp, old_uid_t __user *, euid
78 80
79SYSCALL_DEFINE3(setresgid16, old_gid_t, rgid, old_gid_t, egid, old_gid_t, sgid) 81SYSCALL_DEFINE3(setresgid16, old_gid_t, rgid, old_gid_t, egid, old_gid_t, sgid)
80{ 82{
81 return sys_setresgid(low2highgid(rgid), low2highgid(egid), 83 return __sys_setresgid(low2highgid(rgid), low2highgid(egid),
82 low2highgid(sgid)); 84 low2highgid(sgid));
83} 85}
84 86
85
86SYSCALL_DEFINE3(getresgid16, old_gid_t __user *, rgidp, old_gid_t __user *, egidp, old_gid_t __user *, sgidp) 87SYSCALL_DEFINE3(getresgid16, old_gid_t __user *, rgidp, old_gid_t __user *, egidp, old_gid_t __user *, sgidp)
87{ 88{
88 const struct cred *cred = current_cred(); 89 const struct cred *cred = current_cred();
@@ -102,12 +103,12 @@ SYSCALL_DEFINE3(getresgid16, old_gid_t __user *, rgidp, old_gid_t __user *, egid
102 103
103SYSCALL_DEFINE1(setfsuid16, old_uid_t, uid) 104SYSCALL_DEFINE1(setfsuid16, old_uid_t, uid)
104{ 105{
105 return sys_setfsuid(low2highuid(uid)); 106 return __sys_setfsuid(low2highuid(uid));
106} 107}
107 108
108SYSCALL_DEFINE1(setfsgid16, old_gid_t, gid) 109SYSCALL_DEFINE1(setfsgid16, old_gid_t, gid)
109{ 110{
110 return sys_setfsgid(low2highgid(gid)); 111 return __sys_setfsgid(low2highgid(gid));
111} 112}
112 113
113static int groups16_to_user(old_gid_t __user *grouplist, 114static int groups16_to_user(old_gid_t __user *grouplist,
diff --git a/kernel/uid16.h b/kernel/uid16.h
new file mode 100644
index 000000000000..cdca040f7602
--- /dev/null
+++ b/kernel/uid16.h
@@ -0,0 +1,14 @@
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef LINUX_UID16_H
3#define LINUX_UID16_H
4
5long __sys_setuid(uid_t uid);
6long __sys_setgid(gid_t gid);
7long __sys_setreuid(uid_t ruid, uid_t euid);
8long __sys_setregid(gid_t rgid, gid_t egid);
9long __sys_setresuid(uid_t ruid, uid_t euid, uid_t suid);
10long __sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid);
11long __sys_setfsuid(uid_t uid);
12long __sys_setfsgid(gid_t gid);
13
14#endif /* LINUX_UID16_H */
diff --git a/kernel/umh.c b/kernel/umh.c
index 18e5fa4b0e71..f76b3ff876cf 100644
--- a/kernel/umh.c
+++ b/kernel/umh.c
@@ -118,7 +118,7 @@ static void call_usermodehelper_exec_sync(struct subprocess_info *sub_info)
118{ 118{
119 pid_t pid; 119 pid_t pid;
120 120
121 /* If SIGCLD is ignored sys_wait4 won't populate the status. */ 121 /* If SIGCLD is ignored kernel_wait4 won't populate the status. */
122 kernel_sigaction(SIGCHLD, SIG_DFL); 122 kernel_sigaction(SIGCHLD, SIG_DFL);
123 pid = kernel_thread(call_usermodehelper_exec_async, sub_info, SIGCHLD); 123 pid = kernel_thread(call_usermodehelper_exec_async, sub_info, SIGCHLD);
124 if (pid < 0) { 124 if (pid < 0) {
@@ -135,7 +135,7 @@ static void call_usermodehelper_exec_sync(struct subprocess_info *sub_info)
135 * 135 *
136 * Thus the __user pointer cast is valid here. 136 * Thus the __user pointer cast is valid here.
137 */ 137 */
138 sys_wait4(pid, (int __user *)&ret, 0, NULL); 138 kernel_wait4(pid, (int __user *)&ret, 0, NULL);
139 139
140 /* 140 /*
141 * If ret is 0, either call_usermodehelper_exec_async failed and 141 * If ret is 0, either call_usermodehelper_exec_async failed and