]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
OpenRISC: Don't mask signals if we fail to setup signal stack
authorMatt Fleming <matt.fleming@intel.com>
Fri, 19 Aug 2011 16:46:38 +0000 (17:46 +0100)
committerOleg Nesterov <oleg@redhat.com>
Wed, 24 Aug 2011 18:13:09 +0000 (20:13 +0200)
setup_rt_frame() needs to return an indication of whether it succeeded
or failed in setting up the signal stack frame. If setup_rt_frame()
fails then we must not modify current->blocked.

Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
arch/openrisc/kernel/signal.c

index 2f75e74f4df73d3e7d9db4f69d6ad6e22618e502..b0bdfda049e5f42857f829d8dfa02c50b2c7745d 100644 (file)
@@ -196,8 +196,8 @@ static inline void __user *get_sigframe(struct k_sigaction *ka,
  * trampoline which performs the syscall sigreturn, or a provided
  * user-mode trampoline.
  */
-static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
-                          sigset_t *set, struct pt_regs *regs)
+static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
+                         sigset_t *set, struct pt_regs *regs)
 {
        struct rt_sigframe *frame;
        unsigned long return_ip;
@@ -254,18 +254,23 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
        /* actually move the usp to reflect the stacked frame */
        regs->sp = (unsigned long)frame;
 
-       return;
+       return 0;
 
 give_sigsegv:
        force_sigsegv(sig, current);
+       return -EFAULT;
 }
 
-static inline void
+static inline int
 handle_signal(unsigned long sig,
              siginfo_t *info, struct k_sigaction *ka,
              sigset_t *oldset, struct pt_regs *regs)
 {
-       setup_rt_frame(sig, ka, info, oldset, regs);
+       int ret;
+
+       ret = setup_rt_frame(sig, ka, info, oldset, regs);
+       if (ret)
+               return ret;
 
        spin_lock_irq(&current->sighand->siglock);
        sigorsets(&current->blocked, &current->blocked, &ka->sa.sa_mask);
@@ -274,6 +279,8 @@ handle_signal(unsigned long sig,
        recalc_sigpending();
 
        spin_unlock_irq(&current->sighand->siglock);
+
+       return 0;
 }
 
 /*
@@ -362,13 +369,13 @@ void do_signal(struct pt_regs *regs)
                        oldset = &current->blocked;
 
                /* Whee!  Actually deliver the signal.  */
-               handle_signal(signr, &info, &ka, oldset, regs);
-               /* a signal was successfully delivered; the saved
-                * sigmask will have been stored in the signal frame,
-                * and will be restored by sigreturn, so we can simply
-                * clear the TIF_RESTORE_SIGMASK flag */
-               if (test_thread_flag(TIF_RESTORE_SIGMASK))
+               if (!handle_signal(signr, &info, &ka, oldset, regs)) {
+                       /* a signal was successfully delivered; the saved
+                        * sigmask will have been stored in the signal frame,
+                        * and will be restored by sigreturn, so we can simply
+                        * clear the TIF_RESTORE_SIGMASK flag */
                        clear_thread_flag(TIF_RESTORE_SIGMASK);
+               }
 
                tracehook_signal_handler(signr, &info, &ka, regs,
                                         test_thread_flag(TIF_SINGLESTEP));