Skip to content

Commit a610d6e

Browse files
author
Al Viro
committed
pull clearing RESTORE_SIGMASK into block_sigmask()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 5754f41 commit a610d6e

34 files changed

Lines changed: 130 additions & 387 deletions

File tree

‎arch/alpha/kernel/signal.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,6 @@ handle_signal(int sig, struct k_sigaction *ka, siginfo_t *info,
481481
return;
482482
}
483483
block_sigmask(ka, sig);
484-
/* A signal was successfully delivered, and the
485-
saved sigmask was stored on the signal frame,
486-
and will be restored by sigreturn. So we can
487-
simply clear the restore sigmask flag. */
488-
clear_thread_flag(TIF_RESTORE_SIGMASK);
489484
}
490485

491486
static inline void

‎arch/arm/kernel/signal.c‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
528528
/*
529529
* OK, we're invoking a handler
530530
*/
531-
static int
531+
static void
532532
handle_signal(unsigned long sig, struct k_sigaction *ka,
533533
siginfo_t *info, struct pt_regs *regs)
534534
{
@@ -559,17 +559,14 @@ handle_signal(unsigned long sig, struct k_sigaction *ka,
559559

560560
if (ret != 0) {
561561
force_sigsegv(sig, tsk);
562-
return ret;
562+
return;
563563
}
564564

565565
/*
566566
* Block the signal if we were successful.
567567
*/
568568
block_sigmask(ka, sig);
569-
570569
tracehook_signal_handler(sig, info, ka, regs, 0);
571-
572-
return 0;
573570
}
574571

575572
/*
@@ -633,16 +630,7 @@ static void do_signal(struct pt_regs *regs, int syscall)
633630
clear_thread_flag(TIF_SYSCALL_RESTARTSYS);
634631
}
635632

636-
if (handle_signal(signr, &ka, &info, regs) == 0) {
637-
/*
638-
* A signal was successfully delivered; the saved
639-
* sigmask will have been stored in the signal frame,
640-
* and will be restored by sigreturn, so we can simply
641-
* clear the TIF_RESTORE_SIGMASK flag.
642-
*/
643-
if (test_thread_flag(TIF_RESTORE_SIGMASK))
644-
clear_thread_flag(TIF_RESTORE_SIGMASK);
645-
}
633+
handle_signal(signr, &ka, &info, regs);
646634
return;
647635
}
648636

‎arch/avr32/kernel/signal.c‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,16 +238,13 @@ handle_signal(unsigned long sig, struct k_sigaction *ka, siginfo_t *info,
238238
*/
239239
ret |= !valid_user_regs(regs);
240240

241-
if (ret != 0) {
242-
force_sigsegv(sig, current);
243-
return;
244-
}
245-
246241
/*
247242
* Block the signal if we were successful.
248243
*/
249-
block_sigmask(ka, sig);
250-
clear_thread_flag(TIF_RESTORE_SIGMASK);
244+
if (ret != 0)
245+
force_sigsegv(sig, current);
246+
else
247+
block_sigmask(ka, sig);
251248
}
252249

253250
/*

‎arch/blackfin/kernel/signal.c‎

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
247247
/*
248248
* OK, we're invoking a handler
249249
*/
250-
static int
250+
static void
251251
handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
252252
struct pt_regs *regs)
253253
{
@@ -260,11 +260,12 @@ handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
260260

261261
/* set up the stack frame */
262262
ret = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);
263+
if (ret)
264+
return;
263265

264-
if (ret == 0)
265-
block_sigmask(ka, sig);
266-
267-
return ret;
266+
block_sigmask(ka, sig);
267+
tracehook_signal_handler(sig, info, ka, regs,
268+
test_thread_flag(TIF_SINGLESTEP));
268269
}
269270

270271
/*
@@ -290,18 +291,7 @@ asmlinkage void do_signal(struct pt_regs *regs)
290291
signr = get_signal_to_deliver(&info, &ka, regs, NULL);
291292
if (signr > 0) {
292293
/* Whee! Actually deliver the signal. */
293-
if (handle_signal(signr, &info, &ka, regs) == 0) {
294-
/* a signal was successfully delivered; the saved
295-
* sigmask will have been stored in the signal frame,
296-
* and will be restored by sigreturn, so we can simply
297-
* clear the TIF_RESTORE_SIGMASK flag */
298-
if (test_thread_flag(TIF_RESTORE_SIGMASK))
299-
clear_thread_flag(TIF_RESTORE_SIGMASK);
300-
301-
tracehook_signal_handler(signr, &info, &ka, regs,
302-
test_thread_flag(TIF_SINGLESTEP));
303-
}
304-
294+
handle_signal(signr, &info, &ka, regs);
305295
return;
306296
}
307297

‎arch/c6x/kernel/signal.c‎

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ handle_restart(struct pt_regs *regs, struct k_sigaction *ka, int has_handler)
248248
/*
249249
* handle the actual delivery of a signal to userspace
250250
*/
251-
static int handle_signal(int sig,
251+
static void handle_signal(int sig,
252252
siginfo_t *info, struct k_sigaction *ka,
253253
struct pt_regs *regs, int syscall)
254254
{
@@ -277,11 +277,10 @@ static int handle_signal(int sig,
277277
}
278278

279279
/* Set up the stack frame */
280-
ret = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);
281-
if (ret == 0)
282-
block_sigmask(ka, sig);
283-
284-
return ret;
280+
if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs) < 0)
281+
return;
282+
block_sigmask(ka, sig);
283+
tracehook_signal_handler(sig, info, ka, regs, 0);
285284
}
286285

287286
/*
@@ -300,17 +299,7 @@ static void do_signal(struct pt_regs *regs, int syscall)
300299

301300
signr = get_signal_to_deliver(&info, &ka, regs, NULL);
302301
if (signr > 0) {
303-
if (handle_signal(signr, &info, &ka, regs, syscall) == 0) {
304-
/* a signal was successfully delivered; the saved
305-
* sigmask will have been stored in the signal frame,
306-
* and will be restored by sigreturn, so we can simply
307-
* clear the TIF_RESTORE_SIGMASK flag */
308-
if (test_thread_flag(TIF_RESTORE_SIGMASK))
309-
clear_thread_flag(TIF_RESTORE_SIGMASK);
310-
311-
tracehook_signal_handler(signr, &info, &ka, regs, 0);
312-
}
313-
302+
handle_signal(signr, &info, &ka, regs, syscall);
314303
return;
315304
}
316305

‎arch/cris/arch-v10/kernel/signal.c‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
415415
* OK, we're invoking a handler
416416
*/
417417

418-
static inline int handle_signal(int canrestart, unsigned long sig,
418+
static inline void handle_signal(int canrestart, unsigned long sig,
419419
siginfo_t *info, struct k_sigaction *ka,
420420
struct pt_regs *regs)
421421
{
@@ -458,8 +458,6 @@ static inline int handle_signal(int canrestart, unsigned long sig,
458458

459459
if (ret == 0)
460460
block_sigmask(ka, sig);
461-
462-
return ret;
463461
}
464462

465463
/*
@@ -492,15 +490,7 @@ void do_signal(int canrestart, struct pt_regs *regs)
492490
signr = get_signal_to_deliver(&info, &ka, regs, NULL);
493491
if (signr > 0) {
494492
/* Whee! Actually deliver the signal. */
495-
if (handle_signal(canrestart, signr, &info, &ka,
496-
regs)) {
497-
/* a signal was successfully delivered; the saved
498-
* sigmask will have been stored in the signal frame,
499-
* and will be restored by sigreturn, so we can simply
500-
* clear the TIF_RESTORE_SIGMASK flag */
501-
if (test_thread_flag(TIF_RESTORE_SIGMASK))
502-
clear_thread_flag(TIF_RESTORE_SIGMASK);
503-
}
493+
handle_signal(canrestart, signr, &info, &ka, regs);
504494
return;
505495
}
506496

‎arch/cris/arch-v32/kernel/signal.c‎

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
434434
}
435435

436436
/* Invoke a signal handler to, well, handle the signal. */
437-
static inline int
437+
static inline void
438438
handle_signal(int canrestart, unsigned long sig,
439439
siginfo_t *info, struct k_sigaction *ka,
440440
struct pt_regs * regs)
@@ -491,8 +491,6 @@ handle_signal(int canrestart, unsigned long sig,
491491

492492
if (ret == 0)
493493
block_sigmask(ka, sig);
494-
495-
return ret;
496494
}
497495

498496
/*
@@ -525,16 +523,7 @@ do_signal(int canrestart, struct pt_regs *regs)
525523

526524
if (signr > 0) {
527525
/* Whee! Actually deliver the signal. */
528-
if (handle_signal(canrestart, signr, &info, &ka,
529-
regs)) {
530-
/* a signal was successfully delivered; the saved
531-
* sigmask will have been stored in the signal frame,
532-
* and will be restored by sigreturn, so we can simply
533-
* clear the TIF_RESTORE_SIGMASK flag */
534-
if (test_thread_flag(TIF_RESTORE_SIGMASK))
535-
clear_thread_flag(TIF_RESTORE_SIGMASK);
536-
}
537-
526+
handle_signal(canrestart, signr, &info, &ka, regs);
538527
return;
539528
}
540529

‎arch/frv/kernel/signal.c‎

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ static int setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
426426
/*
427427
* OK, we're invoking a handler
428428
*/
429-
static int handle_signal(unsigned long sig, siginfo_t *info,
429+
static void handle_signal(unsigned long sig, siginfo_t *info,
430430
struct k_sigaction *ka)
431431
{
432432
sigset_t *oldset = sigmask_to_save();
@@ -461,11 +461,12 @@ static int handle_signal(unsigned long sig, siginfo_t *info,
461461
else
462462
ret = setup_frame(sig, ka, oldset);
463463

464-
if (ret == 0)
465-
block_sigmask(ka, sig);
466-
467-
return ret;
464+
if (ret)
465+
return;
468466

467+
block_sigmask(ka, sig);
468+
tracehook_signal_handler(sig, info, ka, __frame,
469+
test_thread_flag(TIF_SINGLESTEP));
469470
} /* end handle_signal() */
470471

471472
/*****************************************************************************/
@@ -495,18 +496,7 @@ static void do_signal(void)
495496

496497
signr = get_signal_to_deliver(&info, &ka, __frame, NULL);
497498
if (signr > 0) {
498-
if (handle_signal(signr, &info, &ka) == 0) {
499-
/* a signal was successfully delivered; the saved
500-
* sigmask will have been stored in the signal frame,
501-
* and will be restored by sigreturn, so we can simply
502-
* clear the TIF_RESTORE_SIGMASK flag */
503-
if (test_thread_flag(TIF_RESTORE_SIGMASK))
504-
clear_thread_flag(TIF_RESTORE_SIGMASK);
505-
506-
tracehook_signal_handler(signr, &info, &ka, __frame,
507-
test_thread_flag(TIF_SINGLESTEP));
508-
}
509-
499+
handle_signal(signr, &info, &ka);
510500
return;
511501
}
512502

‎arch/h8300/kernel/signal.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,8 @@ handle_signal(unsigned long sig, siginfo_t *info, struct k_sigaction *ka,
442442
else
443443
ret = setup_frame(sig, ka, oldset, regs);
444444

445-
if (!ret) {
445+
if (!ret)
446446
block_sigmask(ka, sig);
447-
clear_thread_flag(TIF_RESTORE_SIGMASK);
448-
}
449447
}
450448

451449
/*

‎arch/hexagon/kernel/signal.c‎

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,9 @@ static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info,
149149
/*
150150
* Setup invocation of signal handler
151151
*/
152-
static int handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
152+
static void handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
153153
struct pt_regs *regs)
154154
{
155-
int rc;
156-
157155
/*
158156
* If we're handling a signal that aborted a system call,
159157
* set up the error return value before adding the signal
@@ -186,15 +184,13 @@ static int handle_signal(int sig, siginfo_t *info, struct k_sigaction *ka,
186184
* Set up the stack frame; not doing the SA_SIGINFO thing. We
187185
* only set up the rt_frame flavor.
188186
*/
189-
rc = setup_rt_frame(sig, ka, info, sigmask_to_save(), regs);
190-
191187
/* If there was an error on setup, no signal was delivered. */
192-
if (rc)
193-
return rc;
188+
if (setup_rt_frame(sig, ka, info, sigmask_to_save(), regs) < 0)
189+
return;
194190

195191
block_sigmask(ka, sig);
196-
197-
return 0;
192+
tracehook_signal_handler(sig, info, ka, regs,
193+
test_thread_flag(TIF_SINGLESTEP));
198194
}
199195

200196
/*
@@ -215,17 +211,7 @@ static void do_signal(struct pt_regs *regs)
215211
signo = get_signal_to_deliver(&info, &sigact, regs, NULL);
216212

217213
if (signo > 0) {
218-
if (handle_signal(signo, &info, &sigact, regs) == 0) {
219-
/*
220-
* Successful delivery case. The saved sigmask is
221-
* stored in the signal frame, and will be restored
222-
* by sigreturn. We can clear the TIF flag.
223-
*/
224-
clear_thread_flag(TIF_RESTORE_SIGMASK);
225-
226-
tracehook_signal_handler(signo, &info, &sigact, regs,
227-
test_thread_flag(TIF_SINGLESTEP));
228-
}
214+
handle_signal(signo, &info, &sigact, regs);
229215
return;
230216
}
231217

0 commit comments

Comments
 (0)