summaryrefslogtreecommitdiffstats
path: root/kernel/signal.c
diff options
context:
space:
mode:
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