fix copy_sighand() vs do_sigaction() race
Subsystems (3)
PATCH 1/1 fix copy_sighand() vs do_sigaction() race
copy_sighand() should hold ->sighand->siglock while copying ->sighand->action, another thread may be doing sigaction().
Signed-off-by Oleg Nesterov <[email protected]>
kernel/fork.c renamed from kernel/fork.c~ +2 -0
@@ -766,7 +766,9 @@ static inline int copy_sighand(unsignedreturn -ENOMEM ;spin_lock_init (&sig->siglock);atomic_set (&sig->count,1 ); +spin_lock_irq (¤t->sighand->siglock);memcpy (sig->action, current->sighand->action,sizeof (sig->action)); +spin_unlock_irq (¤t->sighand->siglock);return 0 ; }
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 sys_signal: initialize ->sa_mask
Pointed out by Linus Torvalds.
sys_signal() forgets to initialize ->sa_mask.
( I suspect arch/ia64/ia32/ia32_signal.c:sys32_signal()
also needs this fix )
Signed-off-by Oleg Nesterov <[email protected]>
kernel/signal.c renamed from kernel/signal.c~ +1 -0
@@ -2702,6 +2702,7 @@ sys_signal(int sig, __sighandler_t handl new_sa.sa.sa_handler = handler; new_sa.sa.sa_flags =SA_ONESHOT |SA_NOMASK ; +sigemptyset (&new_sa.sa.sa_mask); ret =do_sigaction (sig, &new_sa, &old_sa);
PATCH 1/1 do_sigaction: cleanup ->sa_mask manipulation
In reply to a message not in the archiveClear unblockable signals beforehand.
Signed-off-by Oleg Nesterov <[email protected]>
include/linux/sched.h renamed from include/linux/sched.h~SAKILL +1 -1
@@ -1097,7 +1097,7 @@ extern struct sigqueue *sigqueue_alloc(vextern void sigqueue_free (struct sigqueue *);extern int send_sigqueue (int ,struct sigqueue *,struct task_struct *);extern int send_group_sigqueue (int ,struct sigqueue *,struct task_struct *); -extern int do_sigaction (int ,const struct k_sigaction *,struct k_sigaction *); +extern int do_sigaction (int ,struct k_sigaction *,struct k_sigaction *);extern int do_sigaltstack (const stack_t __user *,stack_t __user *,unsigned long );/* These can be the second arg to send_sig_info/send_group_sig_info. */
kernel/signal.c renamed from kernel/signal.c~SAKILL +3 -5
@@ -2430,7 +2430,7 @@ sys_rt_sigqueueinfo(int pid, int sig, si }int -do_sigaction (int sig,const struct k_sigaction *act,struct k_sigaction *oact) +do_sigaction (int sig,struct k_sigaction *act,struct k_sigaction *oact) {struct k_sigaction *k;sigset_t mask;
@@ -2454,6 +2454,8 @@ do_sigaction(int sig, const struct k_sig *oact = *k;if (act) { +sigdelsetmask (&act->sa.sa_mask, +sigmask (SIGKILL ) |sigmask (SIGSTOP ));/* * POSIX 3.3.1.3: * "Setting a signal action to SIG_IGN for a signal that is
@@ -2479,8 +2481,6 @@ do_sigaction(int sig, const struct k_sigread_lock (&tasklist_lock);spin_lock_irq (&t->sighand->siglock); *k = *act; -sigdelsetmask (&k->sa.sa_mask, -sigmask (SIGKILL ) |sigmask (SIGSTOP ));sigemptyset (&mask);sigaddset (&mask, sig);rm_from_queue_full (&mask, &t->signal->shared_pending);
@@ -2495,8 +2495,6 @@ do_sigaction(int sig, const struct k_sig } *k = *act; -sigdelsetmask (&k->sa.sa_mask, -sigmask (SIGKILL ) |sigmask (SIGSTOP )); }spin_unlock_irq (¤t->sighand->siglock);