2828
2929#define DEBUG_SIG 0
3030
31- #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
32-
33- int do_signal (struct pt_regs * , sigset_t * );
34-
35- asmlinkage int
36- sys_rt_sigsuspend (sigset_t __user * unewset , size_t sigsetsize ,
37- unsigned long r2 , unsigned long r3 , unsigned long r4 ,
38- unsigned long r5 , unsigned long r6 , struct pt_regs * regs )
39- {
40- sigset_t newset ;
41-
42- /* XXX: Don't preclude handling different sized sigset_t's. */
43- if (sigsetsize != sizeof (sigset_t ))
44- return - EINVAL ;
45-
46- if (copy_from_user (& newset , unewset , sizeof (newset )))
47- return - EFAULT ;
48- sigdelsetmask (& newset , sigmask (SIGKILL )|sigmask (SIGSTOP ));
49-
50- spin_lock_irq (& current -> sighand -> siglock );
51- current -> saved_sigmask = current -> blocked ;
52- current -> blocked = newset ;
53- recalc_sigpending ();
54- spin_unlock_irq (& current -> sighand -> siglock );
55-
56- current -> state = TASK_INTERRUPTIBLE ;
57- schedule ();
58- set_thread_flag (TIF_RESTORE_SIGMASK );
59- return - ERESTARTNOHAND ;
60- }
61-
6231asmlinkage int
6332sys_sigaltstack (const stack_t __user * uss , stack_t __user * uoss ,
6433 unsigned long r2 , unsigned long r3 , unsigned long r4 ,
@@ -332,12 +301,13 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
332301 * want to handle. Thus you cannot kill init even with a SIGKILL even by
333302 * mistake.
334303 */
335- int do_signal (struct pt_regs * regs , sigset_t * oldset )
304+ static int do_signal (struct pt_regs * regs )
336305{
337306 siginfo_t info ;
338307 int signr ;
339308 struct k_sigaction ka ;
340309 unsigned short inst ;
310+ sigset_t * oldset ;
341311
342312 /*
343313 * We want the common case to go fast, which
@@ -351,7 +321,9 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
351321 if (try_to_freeze ())
352322 goto no_signal ;
353323
354- if (!oldset )
324+ if (test_thread_flag (TIF_RESTORE_SIGMASK ))
325+ oldset = & current -> saved_sigmask ;
326+ else
355327 oldset = & current -> blocked ;
356328
357329 signr = get_signal_to_deliver (& info , & ka , regs , NULL );
@@ -364,6 +336,7 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
364336
365337 /* Whee! Actually deliver the signal. */
366338 handle_signal (signr , & ka , & info , oldset , regs );
339+ clear_thread_flag (TIF_RESTORE_SIGMASK );
367340 return 1 ;
368341 }
369342
@@ -391,23 +364,26 @@ int do_signal(struct pt_regs *regs, sigset_t *oldset)
391364 regs -> bpc -= 4 ;
392365 }
393366 }
367+ if (test_thread_flag (TIF_RESTORE_SIGMASK )) {
368+ clear_thread_flag (TIF_RESTORE_SIGMASK );
369+ sigprocmask (SIG_SETMASK , & current -> saved_sigmask , NULL );
370+ }
394371 return 0 ;
395372}
396373
397374/*
398375 * notification of userspace execution resumption
399376 * - triggered by current->work.notify_resume
400377 */
401- void do_notify_resume (struct pt_regs * regs , sigset_t * oldset ,
402- __u32 thread_info_flags )
378+ void do_notify_resume (struct pt_regs * regs , __u32 thread_info_flags )
403379{
404380 /* Pending single-step? */
405381 if (thread_info_flags & _TIF_SINGLESTEP )
406382 clear_thread_flag (TIF_SINGLESTEP );
407383
408384 /* deal with pending signal delivery */
409385 if (thread_info_flags & _TIF_SIGPENDING )
410- do_signal (regs , oldset );
386+ do_signal (regs );
411387
412388 if (thread_info_flags & _TIF_NOTIFY_RESUME ) {
413389 clear_thread_flag (TIF_NOTIFY_RESUME );
0 commit comments