diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-09 12:58:12 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-09 12:58:12 -0400 |
commit | 63b12bdb0d21aca527996fb2c547387bfd3e14b8 (patch) | |
tree | 6ab83b2a1c289f30fea18b88f04138ee69c37c6f /kernel/signal.c | |
parent | ad1f5caf34390bb20fdbb4eaf71b0494e89936f0 (diff) | |
parent | 059ade650ae57cfd371af690fdba887af04aded8 (diff) |
Merge branch 'signal-cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/misc
Pull arch signal handling cleanup from Richard Weinberger:
"This patch series moves all remaining archs to the get_signal(),
signal_setup_done() and sigsp() functions.
Currently these archs use open coded variants of the said functions.
Further, unused parameters get removed from get_signal_to_deliver(),
tracehook_signal_handler() and signal_delivered().
At the end of the day we save around 500 lines of code."
* 'signal-cleanup' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/misc: (43 commits)
powerpc: Use sigsp()
openrisc: Use sigsp()
mn10300: Use sigsp()
mips: Use sigsp()
microblaze: Use sigsp()
metag: Use sigsp()
m68k: Use sigsp()
m32r: Use sigsp()
hexagon: Use sigsp()
frv: Use sigsp()
cris: Use sigsp()
c6x: Use sigsp()
blackfin: Use sigsp()
avr32: Use sigsp()
arm64: Use sigsp()
arc: Use sigsp()
sas_ss_flags: Remove nested ternary if
Rip out get_signal_to_deliver()
Clean up signal_delivered()
tracehook_signal_handler: Remove sig, info, ka and regs
...
Diffstat (limited to 'kernel/signal.c')
-rw-r--r-- | kernel/signal.c | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/kernel/signal.c b/kernel/signal.c index 40b76e351e64..8f0876f9f6dd 100644 --- a/kernel/signal.c +++ b/kernel/signal.c | |||
@@ -2170,8 +2170,7 @@ static int ptrace_signal(int signr, siginfo_t *info) | |||
2170 | return signr; | 2170 | return signr; |
2171 | } | 2171 | } |
2172 | 2172 | ||
2173 | int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, | 2173 | int get_signal(struct ksignal *ksig) |
2174 | struct pt_regs *regs, void *cookie) | ||
2175 | { | 2174 | { |
2176 | struct sighand_struct *sighand = current->sighand; | 2175 | struct sighand_struct *sighand = current->sighand; |
2177 | struct signal_struct *signal = current->signal; | 2176 | struct signal_struct *signal = current->signal; |
@@ -2241,13 +2240,13 @@ relock: | |||
2241 | goto relock; | 2240 | goto relock; |
2242 | } | 2241 | } |
2243 | 2242 | ||
2244 | signr = dequeue_signal(current, ¤t->blocked, info); | 2243 | signr = dequeue_signal(current, ¤t->blocked, &ksig->info); |
2245 | 2244 | ||
2246 | if (!signr) | 2245 | if (!signr) |
2247 | break; /* will return 0 */ | 2246 | break; /* will return 0 */ |
2248 | 2247 | ||
2249 | if (unlikely(current->ptrace) && signr != SIGKILL) { | 2248 | if (unlikely(current->ptrace) && signr != SIGKILL) { |
2250 | signr = ptrace_signal(signr, info); | 2249 | signr = ptrace_signal(signr, &ksig->info); |
2251 | if (!signr) | 2250 | if (!signr) |
2252 | continue; | 2251 | continue; |
2253 | } | 2252 | } |
@@ -2255,13 +2254,13 @@ relock: | |||
2255 | ka = &sighand->action[signr-1]; | 2254 | ka = &sighand->action[signr-1]; |
2256 | 2255 | ||
2257 | /* Trace actually delivered signals. */ | 2256 | /* Trace actually delivered signals. */ |
2258 | trace_signal_deliver(signr, info, ka); | 2257 | trace_signal_deliver(signr, &ksig->info, ka); |
2259 | 2258 | ||
2260 | if (ka->sa.sa_handler == SIG_IGN) /* Do nothing. */ | 2259 | if (ka->sa.sa_handler == SIG_IGN) /* Do nothing. */ |
2261 | continue; | 2260 | continue; |
2262 | if (ka->sa.sa_handler != SIG_DFL) { | 2261 | if (ka->sa.sa_handler != SIG_DFL) { |
2263 | /* Run the handler. */ | 2262 | /* Run the handler. */ |
2264 | *return_ka = *ka; | 2263 | ksig->ka = *ka; |
2265 | 2264 | ||
2266 | if (ka->sa.sa_flags & SA_ONESHOT) | 2265 | if (ka->sa.sa_flags & SA_ONESHOT) |
2267 | ka->sa.sa_handler = SIG_DFL; | 2266 | ka->sa.sa_handler = SIG_DFL; |
@@ -2311,7 +2310,7 @@ relock: | |||
2311 | spin_lock_irq(&sighand->siglock); | 2310 | spin_lock_irq(&sighand->siglock); |
2312 | } | 2311 | } |
2313 | 2312 | ||
2314 | if (likely(do_signal_stop(info->si_signo))) { | 2313 | if (likely(do_signal_stop(ksig->info.si_signo))) { |
2315 | /* It released the siglock. */ | 2314 | /* It released the siglock. */ |
2316 | goto relock; | 2315 | goto relock; |
2317 | } | 2316 | } |
@@ -2332,7 +2331,7 @@ relock: | |||
2332 | 2331 | ||
2333 | if (sig_kernel_coredump(signr)) { | 2332 | if (sig_kernel_coredump(signr)) { |
2334 | if (print_fatal_signals) | 2333 | if (print_fatal_signals) |
2335 | print_fatal_signal(info->si_signo); | 2334 | print_fatal_signal(ksig->info.si_signo); |
2336 | proc_coredump_connector(current); | 2335 | proc_coredump_connector(current); |
2337 | /* | 2336 | /* |
2338 | * If it was able to dump core, this kills all | 2337 | * If it was able to dump core, this kills all |
@@ -2342,34 +2341,32 @@ relock: | |||
2342 | * first and our do_group_exit call below will use | 2341 | * first and our do_group_exit call below will use |
2343 | * that value and ignore the one we pass it. | 2342 | * that value and ignore the one we pass it. |
2344 | */ | 2343 | */ |
2345 | do_coredump(info); | 2344 | do_coredump(&ksig->info); |
2346 | } | 2345 | } |
2347 | 2346 | ||
2348 | /* | 2347 | /* |
2349 | * Death signals, no core dump. | 2348 | * Death signals, no core dump. |
2350 | */ | 2349 | */ |
2351 | do_group_exit(info->si_signo); | 2350 | do_group_exit(ksig->info.si_signo); |
2352 | /* NOTREACHED */ | 2351 | /* NOTREACHED */ |
2353 | } | 2352 | } |
2354 | spin_unlock_irq(&sighand->siglock); | 2353 | spin_unlock_irq(&sighand->siglock); |
2355 | return signr; | 2354 | |
2355 | ksig->sig = signr; | ||
2356 | return ksig->sig > 0; | ||
2356 | } | 2357 | } |
2357 | 2358 | ||
2358 | /** | 2359 | /** |
2359 | * signal_delivered - | 2360 | * signal_delivered - |
2360 | * @sig: number of signal being delivered | 2361 | * @ksig: kernel signal struct |
2361 | * @info: siginfo_t of signal being delivered | ||
2362 | * @ka: sigaction setting that chose the handler | ||
2363 | * @regs: user register state | ||
2364 | * @stepping: nonzero if debugger single-step or block-step in use | 2362 | * @stepping: nonzero if debugger single-step or block-step in use |
2365 | * | 2363 | * |
2366 | * This function should be called when a signal has successfully been | 2364 | * This function should be called when a signal has successfully been |
2367 | * delivered. It updates the blocked signals accordingly (@ka->sa.sa_mask | 2365 | * delivered. It updates the blocked signals accordingly (@ksig->ka.sa.sa_mask |
2368 | * is always blocked, and the signal itself is blocked unless %SA_NODEFER | 2366 | * is always blocked, and the signal itself is blocked unless %SA_NODEFER |
2369 | * is set in @ka->sa.sa_flags. Tracing is notified. | 2367 | * is set in @ksig->ka.sa.sa_flags. Tracing is notified. |
2370 | */ | 2368 | */ |
2371 | void signal_delivered(int sig, siginfo_t *info, struct k_sigaction *ka, | 2369 | static void signal_delivered(struct ksignal *ksig, int stepping) |
2372 | struct pt_regs *regs, int stepping) | ||
2373 | { | 2370 | { |
2374 | sigset_t blocked; | 2371 | sigset_t blocked; |
2375 | 2372 | ||
@@ -2379,11 +2376,11 @@ void signal_delivered(int sig, siginfo_t *info, struct k_sigaction *ka, | |||
2379 | simply clear the restore sigmask flag. */ | 2376 | simply clear the restore sigmask flag. */ |
2380 | clear_restore_sigmask(); | 2377 | clear_restore_sigmask(); |
2381 | 2378 | ||
2382 | sigorsets(&blocked, ¤t->blocked, &ka->sa.sa_mask); | 2379 | sigorsets(&blocked, ¤t->blocked, &ksig->ka.sa.sa_mask); |
2383 | if (!(ka->sa.sa_flags & SA_NODEFER)) | 2380 | if (!(ksig->ka.sa.sa_flags & SA_NODEFER)) |
2384 | sigaddset(&blocked, sig); | 2381 | sigaddset(&blocked, ksig->sig); |
2385 | set_current_blocked(&blocked); | 2382 | set_current_blocked(&blocked); |
2386 | tracehook_signal_handler(sig, info, ka, regs, stepping); | 2383 | tracehook_signal_handler(stepping); |
2387 | } | 2384 | } |
2388 | 2385 | ||
2389 | void signal_setup_done(int failed, struct ksignal *ksig, int stepping) | 2386 | void signal_setup_done(int failed, struct ksignal *ksig, int stepping) |
@@ -2391,8 +2388,7 @@ void signal_setup_done(int failed, struct ksignal *ksig, int stepping) | |||
2391 | if (failed) | 2388 | if (failed) |
2392 | force_sigsegv(ksig->sig, current); | 2389 | force_sigsegv(ksig->sig, current); |
2393 | else | 2390 | else |
2394 | signal_delivered(ksig->sig, &ksig->info, &ksig->ka, | 2391 | signal_delivered(ksig, stepping); |
2395 | signal_pt_regs(), stepping); | ||
2396 | } | 2392 | } |
2397 | 2393 | ||
2398 | /* | 2394 | /* |