summaryrefslogtreecommitdiffstats
path: root/kernel/signal.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-07-17 11:58:04 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-07-17 11:58:04 -0400
commit57a8ec387e1441ea5e1232bc0749fb99a8cba7e7 (patch)
treeb5fb03fc6bc5754de8b5b1f8b0e4f36d67c8315c /kernel/signal.c
parent0a8ad0ffa4d80a544f6cbff703bf6394339afcdf (diff)
parent43e11fa2d1d3b6e35629fa556eb7d571edba2010 (diff)
Merge branch 'akpm' (patches from Andrew)
Merge more updates from Andrew Morton: "VM: - z3fold fixes and enhancements by Henry Burns and Vitaly Wool - more accurate reclaimed slab caches calculations by Yafang Shao - fix MAP_UNINITIALIZED UAPI symbol to not depend on config, by Christoph Hellwig - !CONFIG_MMU fixes by Christoph Hellwig - new novmcoredd parameter to omit device dumps from vmcore, by Kairui Song - new test_meminit module for testing heap and pagealloc initialization, by Alexander Potapenko - ioremap improvements for huge mappings, by Anshuman Khandual - generalize kprobe page fault handling, by Anshuman Khandual - device-dax hotplug fixes and improvements, by Pavel Tatashin - enable synchronous DAX fault on powerpc, by Aneesh Kumar K.V - add pte_devmap() support for arm64, by Robin Murphy - unify locked_vm accounting with a helper, by Daniel Jordan - several misc fixes core/lib: - new typeof_member() macro including some users, by Alexey Dobriyan - make BIT() and GENMASK() available in asm, by Masahiro Yamada - changed LIST_POISON2 on x86_64 to 0xdead000000000122 for better code generation, by Alexey Dobriyan - rbtree code size optimizations, by Michel Lespinasse - convert struct pid count to refcount_t, by Joel Fernandes get_maintainer.pl: - add --no-moderated switch to skip moderated ML's, by Joe Perches misc: - ptrace PTRACE_GET_SYSCALL_INFO interface - coda updates - gdb scripts, various" [ Using merge message suggestion from Vlastimil Babka, with some editing - Linus ] * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (100 commits) fs/select.c: use struct_size() in kmalloc() mm: add account_locked_vm utility function arm64: mm: implement pte_devmap support mm: introduce ARCH_HAS_PTE_DEVMAP mm: clean up is_device_*_page() definitions mm/mmap: move common defines to mman-common.h mm: move MAP_SYNC to asm-generic/mman-common.h device-dax: "Hotremove" persistent memory that is used like normal RAM mm/hotplug: make remove_memory() interface usable device-dax: fix memory and resource leak if hotplug fails include/linux/lz4.h: fix spelling and copy-paste errors in documentation ipc/mqueue.c: only perform resource calculation if user valid include/asm-generic/bug.h: fix "cut here" for WARN_ON for __WARN_TAINT architectures scripts/gdb: add helpers to find and list devices scripts/gdb: add lx-genpd-summary command drivers/pps/pps.c: clear offset flags in PPS_SETPARAMS ioctl kernel/pid.c: convert struct pid count to refcount_t drivers/rapidio/devices/rio_mport_cdev.c: NUL terminate some strings select: shift restore_saved_sigmask_unless() into poll_select_copy_remaining() select: change do_poll() to return -ERESTARTNOHAND rather than -EINTR ...
Diffstat (limited to 'kernel/signal.c')
-rw-r--r--kernel/signal.c69
1 files changed, 19 insertions, 50 deletions
diff --git a/kernel/signal.c b/kernel/signal.c
index dabe100d2091..91b789dd6e72 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2951,80 +2951,49 @@ EXPORT_SYMBOL(sigprocmask);
2951 * 2951 *
2952 * This is useful for syscalls such as ppoll, pselect, io_pgetevents and 2952 * This is useful for syscalls such as ppoll, pselect, io_pgetevents and
2953 * epoll_pwait where a new sigmask is passed from userland for the syscalls. 2953 * epoll_pwait where a new sigmask is passed from userland for the syscalls.
2954 *
2955 * Note that it does set_restore_sigmask() in advance, so it must be always
2956 * paired with restore_saved_sigmask_unless() before return from syscall.
2954 */ 2957 */
2955int set_user_sigmask(const sigset_t __user *usigmask, sigset_t *set, 2958int set_user_sigmask(const sigset_t __user *umask, size_t sigsetsize)
2956 sigset_t *oldset, size_t sigsetsize)
2957{ 2959{
2958 if (!usigmask) 2960 sigset_t kmask;
2959 return 0;
2960 2961
2962 if (!umask)
2963 return 0;
2961 if (sigsetsize != sizeof(sigset_t)) 2964 if (sigsetsize != sizeof(sigset_t))
2962 return -EINVAL; 2965 return -EINVAL;
2963 if (copy_from_user(set, usigmask, sizeof(sigset_t))) 2966 if (copy_from_user(&kmask, umask, sizeof(sigset_t)))
2964 return -EFAULT; 2967 return -EFAULT;
2965 2968
2966 *oldset = current->blocked; 2969 set_restore_sigmask();
2967 set_current_blocked(set); 2970 current->saved_sigmask = current->blocked;
2971 set_current_blocked(&kmask);
2968 2972
2969 return 0; 2973 return 0;
2970} 2974}
2971EXPORT_SYMBOL(set_user_sigmask);
2972 2975
2973#ifdef CONFIG_COMPAT 2976#ifdef CONFIG_COMPAT
2974int set_compat_user_sigmask(const compat_sigset_t __user *usigmask, 2977int set_compat_user_sigmask(const compat_sigset_t __user *umask,
2975 sigset_t *set, sigset_t *oldset,
2976 size_t sigsetsize) 2978 size_t sigsetsize)
2977{ 2979{
2978 if (!usigmask) 2980 sigset_t kmask;
2979 return 0;
2980 2981
2982 if (!umask)
2983 return 0;
2981 if (sigsetsize != sizeof(compat_sigset_t)) 2984 if (sigsetsize != sizeof(compat_sigset_t))
2982 return -EINVAL; 2985 return -EINVAL;
2983 if (get_compat_sigset(set, usigmask)) 2986 if (get_compat_sigset(&kmask, umask))
2984 return -EFAULT; 2987 return -EFAULT;
2985 2988
2986 *oldset = current->blocked; 2989 set_restore_sigmask();
2987 set_current_blocked(set); 2990 current->saved_sigmask = current->blocked;
2991 set_current_blocked(&kmask);
2988 2992
2989 return 0; 2993 return 0;
2990} 2994}
2991EXPORT_SYMBOL(set_compat_user_sigmask);
2992#endif 2995#endif
2993 2996
2994/*
2995 * restore_user_sigmask:
2996 * usigmask: sigmask passed in from userland.
2997 * sigsaved: saved sigmask when the syscall started and changed the sigmask to
2998 * usigmask.
2999 *
3000 * This is useful for syscalls such as ppoll, pselect, io_pgetevents and
3001 * epoll_pwait where a new sigmask is passed in from userland for the syscalls.
3002 */
3003void restore_user_sigmask(const void __user *usigmask, sigset_t *sigsaved,
3004 bool interrupted)
3005{
3006
3007 if (!usigmask)
3008 return;
3009 /*
3010 * When signals are pending, do not restore them here.
3011 * Restoring sigmask here can lead to delivering signals that the above
3012 * syscalls are intended to block because of the sigmask passed in.
3013 */
3014 if (interrupted) {
3015 current->saved_sigmask = *sigsaved;
3016 set_restore_sigmask();
3017 return;
3018 }
3019
3020 /*
3021 * This is needed because the fast syscall return path does not restore
3022 * saved_sigmask when signals are not pending.
3023 */
3024 set_current_blocked(sigsaved);
3025}
3026EXPORT_SYMBOL(restore_user_sigmask);
3027
3028/** 2997/**
3029 * sys_rt_sigprocmask - change the list of currently blocked signals 2998 * sys_rt_sigprocmask - change the list of currently blocked signals
3030 * @how: whether to add, remove, or set signals 2999 * @how: whether to add, remove, or set signals