Skip to content

Commit a7f8388

Browse files
Al Virotorvalds
authored andcommitted
m32r: fix rt_sigsuspend()
do_signal() should know about saved_mask for it to work... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent a850ea3 commit a7f8388

File tree

4 files changed

+14
-39
lines changed

4 files changed

+14
-39
lines changed

arch/m32r/include/asm/signal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ typedef struct sigaltstack {
157157
#undef __HAVE_ARCH_SIG_BITOPS
158158

159159
struct pt_regs;
160-
extern int do_signal(struct pt_regs *regs, sigset_t *oldset);
161160

162161
#define ptrace_signal_deliver(regs, cookie) do { } while (0)
163162

arch/m32r/include/asm/unistd.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@
351351
#define __ARCH_WANT_SYS_OLD_GETRLIMIT /*will be unused*/
352352
#define __ARCH_WANT_SYS_OLDUMOUNT
353353
#define __ARCH_WANT_SYS_RT_SIGACTION
354+
#define __ARCH_WANT_SYS_RT_SIGSUSPEND
354355

355356
#define __IGNORE_lchown
356357
#define __IGNORE_setuid

arch/m32r/kernel/entry.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,7 @@ work_resched:
235235
work_notifysig: ; deal with pending signals and
236236
; notify-resume requests
237237
mv r0, sp ; arg1 : struct pt_regs *regs
238-
ldi r1, #0 ; arg2 : sigset_t *oldset
239-
mv r2, r9 ; arg3 : __u32 thread_info_flags
238+
ldi r1, r9 ; arg2 : __u32 thread_info_flags
240239
bl do_notify_resume
241240
bra restore_all
242241

arch/m32r/kernel/signal.c

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,6 @@
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-
6231
asmlinkage int
6332
sys_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

Comments
 (0)