new helper: signal_delivered()
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 28 Apr 2012 06:04:15 +0000 (02:04 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Fri, 1 Jun 2012 16:58:52 +0000 (12:58 -0400)
Does block_sigmask() + tracehook_signal_handler();  called when
sigframe has been successfully built.  All architectures converted
to it; block_sigmask() itself is gone now (merged into this one).

I'm still not too happy with the signature, but that's a separate
story (IMO we need a structure that would contain signal number +
siginfo + k_sigaction, so that get_signal_to_deliver() would fill one,
signal_delivered(), handle_signal() and probably setup...frame() -
take one).

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
34 files changed:
arch/alpha/kernel/signal.c
arch/arm/kernel/signal.c
arch/avr32/kernel/signal.c
arch/blackfin/kernel/signal.c
arch/c6x/kernel/signal.c
arch/cris/arch-v10/kernel/signal.c
arch/cris/arch-v32/kernel/signal.c
arch/frv/kernel/signal.c
arch/h8300/kernel/signal.c
arch/hexagon/kernel/signal.c
arch/ia64/kernel/signal.c
arch/m32r/kernel/signal.c
arch/m68k/kernel/signal.c
arch/microblaze/kernel/signal.c
arch/mips/kernel/signal.c
arch/mn10300/kernel/signal.c
arch/openrisc/kernel/signal.c
arch/parisc/kernel/signal.c
arch/powerpc/kernel/signal.c
arch/s390/kernel/compat_signal.c
arch/s390/kernel/signal.c
arch/score/kernel/signal.c
arch/sh/kernel/signal_32.c
arch/sh/kernel/signal_64.c
arch/sparc/kernel/signal32.c
arch/sparc/kernel/signal_32.c
arch/sparc/kernel/signal_64.c
arch/tile/kernel/signal.c
arch/um/kernel/signal.c
arch/unicore32/kernel/signal.c
arch/x86/kernel/signal.c
arch/xtensa/kernel/signal.c
include/linux/signal.h
kernel/signal.c

index 48c4df2389ac04ffb9d98fd0255824ae6f51c5e1..a8c97d42ec8eaef9215c32a40f743bd94505bc55 100644 (file)
@@ -478,7 +478,7 @@ handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
                force_sigsegv(sig, current);
                return;
        }
-       block_sigmask(ka, sig);
+       signal_delivered(sig, info, ka, regs, 0);
 }
 
 static inline void
index c126eba8411d06dce594ebffe7a68c57827c435f..fd2392a17ac1befb3464b5a0e77960a0f862b4ca 100644 (file)
@@ -557,12 +557,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,
                force_sigsegv(sig, tsk);
                return;
        }
-
-       /*
-        * Block the signal if we were successful.
-        */
-       block_sigmask(ka, sig);
-       tracehook_signal_handler(sig, info, ka, regs, 0);
+       signal_delivered(sig, info, ka, regs, 0);
 }
 
 /*
index e883fa5eb8451148dfc95a589e26f42677dcc6a2..c140f9b41dce48fed05240ff531dc22e42f29095 100644 (file)
@@ -241,7 +241,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
        if (ret != 0)
                force_sigsegv(sig, current);
        else
-               block_sigmask(ka, sig);
+               signal_delivered(sig, info, ka, regs, 0);
 }
 
 /*
index 46361264382144e52758c46046fdf08860556f32..35459e6814834bc3b05f9477935f131082388737 100644 (file)
@@ -260,8 +260,7 @@ handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
        if (ret)
                return;
 
-       block_sigmask(ka, sig);
-       tracehook_signal_handler(sig, info, ka, regs,
+       signal_delivered(sig, info, ka, regs,
                        test_thread_flag(TIF_SINGLESTEP));
 }
 
index eb1b3086ae006e137a701aa302bd01075a797e34..3d8f3c22a94fa0adf7e66fe2a793a65326759990 100644 (file)
@@ -276,8 +276,7 @@ static void handle_signal(int sig,
        /* Set up the stack frame */
        if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs) < 0)
                return;
-       block_sigmask(ka, sig);
-       tracehook_signal_handler(sig, info, ka, regs, 0);
+       signal_delivered(sig, info, ka, regs, 0);
 }
 
 /*
index cf6380cb9a57a011355be4484ae6b8e1b800ed68..0bb477c13a4e08b6bd09ceee6e22e9a11ac2a6b0 100644 (file)
@@ -453,7 +453,7 @@ static inline void handle_signal(int canrestart, unsigned long sig,
                ret = setup_frame(sig, ka, oldset, regs);
 
        if (ret == 0)
-               block_sigmask(ka, sig);
+               signal_delivered(sig, info, ka, regs, 0);
 }
 
 /*
index 07b81ee09f65cce07c61eab979dde81abee114b5..b60d1b65a4267ef5cbdb14758058b5c9ca6707a0 100644 (file)
@@ -485,7 +485,7 @@ handle_signal(int canrestart, unsigned long sig,
                ret = setup_frame(sig, ka, oldset, regs);
 
        if (ret == 0)
-               block_sigmask(ka, sig);
+               signal_delivered(sig, info, ka, regs, 0);
 }
 
 /*
index 511285fa246132383c755e08b8f3292c5b618bc1..4e134c7eceea30e01267753be60f37ccc8b8093f 100644 (file)
@@ -460,8 +460,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info,
        if (ret)
                return;
 
-       block_sigmask(ka, sig);
-       tracehook_signal_handler(sig, info, ka, __frame,
+       signal_delivered(sig, info, ka, __frame,
                                 test_thread_flag(TIF_SINGLESTEP));
 } /* end handle_signal() */
 
index aa6f096669154731a5bd80392def2a77a195d3b9..fca10378701bb9c818b8c123fb4d3c05522cd0c6 100644 (file)
@@ -439,7 +439,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
                ret = setup_frame(sig, ka, oldset, regs);
 
        if (!ret)
-               block_sigmask(ka, sig);
+               signal_delivered(sig, info, ka, regs, 0);
 }
 
 /*
index 439f11a3a8ef9c98ce324c63b1cbd491c8ee2c92..304b0808d07213f0853ee256d781a114f561a947 100644 (file)
@@ -186,8 +186,7 @@ static void handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
        if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs) < 0)
                return;
 
-       block_sigmask(ka, sig);
-       tracehook_signal_handler(sig, info, ka, regs,
+       signal_delivered(sig, info, ka, regs,
                        test_thread_flag(TIF_SINGLESTEP));
 }
 
index c4041c76c07d61c2aeca1bfacc8bd46fa7359d89..a199be1fe619bc12d00a9e87198b6f919a9f2c74 100644 (file)
@@ -419,12 +419,7 @@ handle_signal (unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
        if (!setup_frame(sig, ka, info, sigmask_to_save(), scr))
                return 0;
 
-       block_sigmask(ka, sig);
-
-       /*
-        * Let tracing know that we've done the handler setup.
-        */
-       tracehook_signal_handler(sig, info, ka, &scr->pt,
+       signal_delivered(sig, info, ka, &scr->pt,
                                 test_thread_flag(TIF_SINGLESTEP));
 
        return 1;
index 07f9032576c0873893f458c632912ebd841e449e..f3fb2c029cfcab061fbbfb5697273067e57c38e8 100644 (file)
@@ -294,7 +294,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
        if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs))
                return;
 
-       block_sigmask(ka, sig);
+       signal_delivered(sig, info, ka, regs, 0);
 }
 
 /*
index c00caad215a6f0b00ab9a34f4275ff5052337a10..710a528b928b8580ac4281449586ee4507966db9 100644 (file)
@@ -1137,7 +1137,7 @@ handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
        if (err)
                return;
 
-       block_sigmask(ka, sig);
+       signal_delivered(sig, info, ka, regs, 0);
 
        if (test_thread_flag(TIF_DELAYED_TRACE)) {
                regs->sr &= ~0x8000;
index c662e68671a2053f6cb98427706f8b1b109f8188..76b9722557db77e99a3500154a34b8ed6556d958 100644 (file)
@@ -323,7 +323,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,
        if (ret)
                return;
 
-       block_sigmask(ka, sig);
+       signal_delivered(sig, info, ka, regs, 0);
 }
 
 /*
index 02e0cba24f82fc9ddb40e0a54a32b4c6b54cd5ff..f2c09cfc60ac338dc9300f3487bae83e48a8cbd1 100644 (file)
@@ -551,7 +551,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info,
        if (ret)
                return;
 
-       block_sigmask(ka, sig);
+       signal_delivered(sig, info, ka, regs, 0);
 }
 
 static void do_signal(struct pt_regs *regs)
index 4f6d20763061ff505228d8af9d6113290a826dba..6ab0bee2a54fd38efeccbaa683b4437f26406a34 100644 (file)
@@ -461,8 +461,7 @@ static int handle_signal(int sig,
        if (ret)
                return;
 
-       block_sigmask(ka, sig);
-       tracehook_signal_handler(sig, info, ka, regs,
+       signal_delivered(sig, info, ka, regs,
                                 test_thread_flag(TIF_SINGLESTEP));
 }
 
index 53972b7260b793a46de2fe697816c33ffe6f4e54..30110297f4f9509d6437c8f5c3e80220add6e2a9 100644 (file)
@@ -259,8 +259,7 @@ handle_signal(unsigned long sig,
        if (ret)
                return;
 
-       block_sigmask(ka, sig);
-       tracehook_signal_handler(sig, info, ka, regs,
+       signal_delivered(sig, info, ka, regs,
                                 test_thread_flag(TIF_SINGLESTEP));
 }
 
index 25161eaf720da0b30a8ef077bb33330e85e46184..594459bde14ed3c927b7dddce88e1d9cf9863e74 100644 (file)
@@ -449,9 +449,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
        if (!setup_rt_frame(sig, ka, info, oldset, regs, in_syscall))
                return 0;
 
-       block_sigmask(ka, sig);
-
-       tracehook_signal_handler(sig, info, ka, regs, 
+       signal_delivered(sig, info, ka, regs, 
                test_thread_flag(TIF_SINGLESTEP) ||
                test_thread_flag(TIF_BLOCKSTEP));
 
index 129bdffc6daf1b018932742948d36221c774b648..5c023c9cf16ee70a7a3b281af2ad9807028c3b13 100644 (file)
@@ -148,11 +148,7 @@ static int do_signal(struct pt_regs *regs)
 
        regs->trap = 0;
        if (ret) {
-               block_sigmask(&ka, signr);
-               /*
-                * Let tracing know that we've done the handler setup.
-                */
-               tracehook_signal_handler(signr, &info, &ka, regs,
+               signal_delivered(signr, &info, &ka, regs,
                                         test_thread_flag(TIF_SINGLESTEP));
        }
 
index 923baa96c0b025259bcfd01dd6cc9223c020d046..3c0c19830c37f5a0f7896d0a292762b794b30a74 100644 (file)
@@ -580,11 +580,7 @@ void handle_signal32(unsigned long sig, struct k_sigaction *ka,
                ret = setup_frame32(sig, ka, oldset, regs);
        if (ret)
                return;
-       block_sigmask(ka, sig);
-       /*
-        * Let tracing know that we've done the handler setup.
-        */
-       tracehook_signal_handler(sig, info, ka, regs,
+       signal_delivered(sig, info, ka, regs,
                                 test_thread_flag(TIF_SINGLE_STEP));
 }
 
index 8332a6943384b2990bfee229d8021f59a70565ed..ac565b44aabbf76c23da00540f8f2884e06f07a6 100644 (file)
@@ -375,11 +375,7 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka,
                ret = setup_frame(sig, ka, oldset, regs);
        if (ret)
                return;
-       block_sigmask(ka, sig);
-       /*
-        * Let tracing know that we've done the handler setup.
-        */
-       tracehook_signal_handler(sig, info, ka, regs,
+       signal_delivered(sig, info, ka, regs,
                                 test_thread_flag(TIF_SINGLE_STEP));
 }
 
index f1b3fef0907b44da3d87d911a622067c90f597f4..e382c52ca0d90b455d9bee68f7587f4278d36bc8 100644 (file)
@@ -267,7 +267,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info,
        if (setup_rt_frame(ka, regs, sig, sigmask_to_save(), info) < 0)
                return;
 
-       block_sigmask(ka, sig);
+       signal_delivered(sig, info, ka, regs, 0);
 }
 
 static void do_signal(struct pt_regs *regs)
index e4a531414e1998c99fff975d3ad545500229ae7f..d6b7b6154f8764576abac916033326ba1c1e6bd2 100644 (file)
@@ -533,8 +533,7 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
 
        if (ret)
                return;
-       block_sigmask(ka, sig);
-       tracehook_signal_handler(sig, info, ka, regs,
+       signal_delivered(sig, info, ka, regs,
                        test_thread_flag(TIF_SINGLESTEP));
 }
 
index 75960ef6c1d1b95aaa865123d921486b9bae4e0c..6b5b3dfe886b2d3c15a4b08a4d4f21ab74e90da0 100644 (file)
@@ -650,8 +650,7 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
        if (ret)
                return;
 
-       block_sigmask(ka, sig);
-       tracehook_signal_handler(sig, info, ka, regs,
+       signal_delivered(sig, info, ka, regs,
                        test_thread_flag(TIF_SINGLESTEP));
 }
 
index ba3dbfcdb28e197397025cc9b906a6d880e9a8be..a53e0a5fd3a3d944a5eb42391e2862c92a23c044 100644 (file)
@@ -785,8 +785,7 @@ static inline void handle_signal32(unsigned long signr, struct k_sigaction *ka,
        if (err)
                return;
 
-       block_sigmask(ka, signr);
-       tracehook_signal_handler(signr, info, ka, regs, 0);
+       signal_delivered(signr, info, ka, regs, 0);
 }
 
 static inline void syscall_restart32(unsigned long orig_i0, struct pt_regs *regs,
index 1bfa854be602a701513664d9baf8cd101fef9fd1..68f9c8650af47b2731c622cc8ada8768b63d90cb 100644 (file)
@@ -460,8 +460,7 @@ handle_signal(unsigned long signr, struct k_sigaction *ka,
        if (err)
                return;
 
-       block_sigmask(ka, signr);
-       tracehook_signal_handler(signr, info, ka, regs, 0);
+       signal_delivered(signr, info, ka, regs, 0);
 }
 
 static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs,
index 23b60caa6c435871d43a30e39fd65782d13f25d8..867de2f8189c32acf359fe5575cd139ede6b7048 100644 (file)
@@ -473,8 +473,7 @@ static inline void handle_signal(unsigned long signr, struct k_sigaction *ka,
        if (err)
                return;
 
-       block_sigmask(ka, signr);
-       tracehook_signal_handler(signr, info, ka, regs, 0);
+       signal_delivered(signr, info, ka, regs, 0);
 }
 
 static inline void syscall_restart(unsigned long orig_i0, struct pt_regs *regs,
index e068aa0c6dfc1ba6b99879db8824bb6605b6dd1d..e29b0553211d611af9802dfe190f9d0d9d868f69 100644 (file)
@@ -278,7 +278,7 @@ static void handle_signal(unsigned long sig, siginfo_t *info,
                ret = setup_rt_frame(sig, ka, info, oldset, regs);
        if (ret)
                return;
-       block_sigmask(ka, sig);
+       signal_delivered(sig, info, ka, regs, 0);
 }
 
 /*
index 4ce6ab2d2996dcb8fcbee638549f6e916d4e5a2e..7362d58efc29612c1ffaad64558b3a986b820515 100644 (file)
@@ -61,7 +61,7 @@ static void handle_signal(struct pt_regs *regs, unsigned long signr,
        if (err)
                force_sigsegv(signr, current);
        else
-               block_sigmask(ka, signr);
+               signal_delivered(signr, info, ka, regs, 0);
 }
 
 static int kern_do_signal(struct pt_regs *regs)
index 4d9c4841989deefb3ce7a30f737cca4e7aca8638..8adedb37720a0e997dea9ea88abff76113904830 100644 (file)
@@ -362,10 +362,7 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka,
                return;
        }
 
-       /*
-        * Block the signal if we were successful.
-        */
-       block_sigmask(ka, sig);
+       signal_delivered(sig, info, ka, regs, 0);
 }
 
 /*
index 11e206f0f45aa2794500bfe6a4b9c779bb032fb6..e8a89374d3565af7b1a64189244ce39e1ea0d70c 100644 (file)
@@ -715,10 +715,8 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
         */
        regs->flags &= ~X86_EFLAGS_TF;
 
-       block_sigmask(ka, sig);
-
-       tracehook_signal_handler(sig, info, ka, regs,
-                                test_thread_flag(TIF_SINGLESTEP));
+       signal_delivered(sig, info, ka, regs,
+                        test_thread_flag(TIF_SINGLESTEP));
 }
 
 #ifdef CONFIG_X86_32
index 4da3c6f6d92943e4f989ae73a21a0f470bfd95c9..b9f8e5850d3a4e1c9bc1dbe3ff6ee0b7dbc47cc9 100644 (file)
@@ -493,7 +493,7 @@ static void do_signal(struct pt_regs *regs)
                if (ret)
                        return;
 
-               block_sigmask(&ka, signr);
+               signal_delivered(signr, info, ka, regs, 0);
                if (current->ptrace & PT_SINGLESTEP)
                        task_pt_regs(current)->icountlevel = 1;
 
index 065e76330398ebe780ff8f08b8c92add4d918640..26b424adc84299b6a53c9ad986e4d9350d16b68a 100644 (file)
@@ -256,7 +256,7 @@ extern int show_unhandled_signals;
 extern int sigsuspend(sigset_t *);
 
 extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
-extern void block_sigmask(struct k_sigaction *ka, int signr);
+extern void signal_delivered(int sig, siginfo_t *info, struct k_sigaction *ka, struct pt_regs *regs, int stepping);
 extern void exit_signals(struct task_struct *tsk);
 
 extern struct kmem_cache *sighand_cachep;
index df8d721a9e6fa88420dd688fb3be00c83b7c3e8d..677102789cf22d4847936782f6c6f67085421927 100644 (file)
@@ -2368,17 +2368,20 @@ relock:
 }
 
 /**
- * block_sigmask - add @ka's signal mask to current->blocked
- * @ka: action for @signr
- * @signr: signal that has been successfully delivered
+ * signal_delivered - 
+ * @sig:               number of signal being delivered
+ * @info:              siginfo_t of signal being delivered
+ * @ka:                        sigaction setting that chose the handler
+ * @regs:              user register state
+ * @stepping:          nonzero if debugger single-step or block-step in use
  *
  * This function should be called when a signal has succesfully been
- * delivered. It adds the mask of signals for @ka to current->blocked
- * so that they are blocked during the execution of the signal
- * handler. In addition, @signr will be blocked unless %SA_NODEFER is
- * set in @ka->sa.sa_flags.
+ * delivered. It updates the blocked signals accordingly (@ka->sa.sa_mask
+ * is always blocked, and the signal itself is blocked unless %SA_NODEFER
+ * is set in @ka->sa.sa_flags.  Tracing is notified.
  */
-void block_sigmask(struct k_sigaction *ka, int signr)
+void signal_delivered(int sig, siginfo_t *info, struct k_sigaction *ka,
+                       struct pt_regs *regs, int stepping)
 {
        sigset_t blocked;
 
@@ -2390,8 +2393,9 @@ void block_sigmask(struct k_sigaction *ka, int signr)
 
        sigorsets(&blocked, &current->blocked, &ka->sa.sa_mask);
        if (!(ka->sa.sa_flags & SA_NODEFER))
-               sigaddset(&blocked, signr);
+               sigaddset(&blocked, sig);
        set_current_blocked(&blocked);
+       tracehook_signal_handler(sig, info, ka, regs, stepping);
 }
 
 /*