Skip to content

Commit

Permalink
most of set_current_blocked() callers want SIGKILL/SIGSTOP removed fr…
Browse files Browse the repository at this point in the history
…om set

Only 3 out of 63 do not.  Renamed the current variant to __set_current_blocked(),
added set_current_blocked() that will exclude unblockable signals, switched
open-coded instances to it.

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Jun 1, 2012
1 parent edd63a2 commit 77097ae
Show file tree
Hide file tree
Showing 45 changed files with 17 additions and 141 deletions.
2 changes: 0 additions & 2 deletions arch/alpha/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ do_sigreturn(struct sigcontext __user *sc, struct pt_regs *regs,
if (__get_user(set.sig[0], &sc->sc_mask))
goto give_sigsegv;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(sc, regs, sw))
Expand Down Expand Up @@ -261,7 +260,6 @@ do_rt_sigreturn(struct rt_sigframe __user *frame, struct pt_regs *regs,
if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
goto give_sigsegv;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(&frame->uc.uc_mcontext, regs, sw))
Expand Down
6 changes: 1 addition & 5 deletions arch/arm/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

#include "signal.h"

#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))

/*
* For ARM syscalls, we encode the syscall number into the instruction.
*/
Expand Down Expand Up @@ -210,10 +208,8 @@ static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
int err;

err = __copy_from_user(&set, &sf->uc.uc_sigmask, sizeof(set));
if (err == 0) {
sigdelsetmask(&set, ~_BLOCKABLE);
if (err == 0)
set_current_blocked(&set);
}

__get_user_error(regs->ARM_r0, &sf->uc.uc_mcontext.arm_r0, err);
__get_user_error(regs->ARM_r1, &sf->uc.uc_mcontext.arm_r1, err);
Expand Down
3 changes: 0 additions & 3 deletions arch/avr32/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#include <asm/ucontext.h>
#include <asm/syscalls.h>

#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))

asmlinkage int sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
struct pt_regs *regs)
{
Expand Down Expand Up @@ -89,7 +87,6 @@ asmlinkage int sys_rt_sigreturn(struct pt_regs *regs)
if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
Expand Down
3 changes: 0 additions & 3 deletions arch/blackfin/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#include <asm/fixed_code.h>
#include <asm/syscall.h>

#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))

/* Location of the trace bit in SYSCFG. */
#define TRACE_BITS 0x0001

Expand Down Expand Up @@ -98,7 +96,6 @@ asmlinkage int do_rt_sigreturn(unsigned long __unused)
if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (rt_restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0))
Expand Down
3 changes: 0 additions & 3 deletions arch/c6x/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include <asm/cacheflush.h>


#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))

/*
* Do a signal return, undo the signal stack.
*/
Expand Down Expand Up @@ -87,7 +85,6 @@ asmlinkage int do_rt_sigreturn(struct pt_regs *regs)
if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
Expand Down
4 changes: 0 additions & 4 deletions arch/cris/arch-v10/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@

#define DEBUG_SIG 0

#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))

/* a syscall in Linux/CRIS is a break 13 instruction which is 2 bytes */
/* manipulate regs so that upon return, it will be re-executed */

Expand Down Expand Up @@ -176,7 +174,6 @@ asmlinkage int sys_sigreturn(long r10, long r11, long r12, long r13, long mof,
sizeof(frame->extramask))))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(regs, &frame->sc))
Expand Down Expand Up @@ -212,7 +209,6 @@ asmlinkage int sys_rt_sigreturn(long r10, long r11, long r12, long r13,
if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
Expand Down
5 changes: 0 additions & 5 deletions arch/cris/arch-v32/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@

extern unsigned long cris_signal_return_page;

/* Flag to check if a signal is blockable. */
#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))

/*
* A syscall in CRIS is really a "break 13" instruction, which is 2
* bytes. The registers is manipulated so upon return the instruction
Expand Down Expand Up @@ -167,7 +164,6 @@ sys_sigreturn(long r10, long r11, long r12, long r13, long mof, long srp,
sizeof(frame->extramask))))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(regs, &frame->sc))
Expand Down Expand Up @@ -208,7 +204,6 @@ sys_rt_sigreturn(long r10, long r11, long r12, long r13, long mof, long srp,
if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
Expand Down
4 changes: 0 additions & 4 deletions arch/frv/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

#define DEBUG_SIG 0

#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))

struct fdpic_func_descriptor {
unsigned long text;
unsigned long GOT;
Expand Down Expand Up @@ -149,7 +147,6 @@ asmlinkage int sys_sigreturn(void)
__copy_from_user(&set.sig[1], &frame->extramask, sizeof(frame->extramask)))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(&frame->sc, &gr8))
Expand All @@ -172,7 +169,6 @@ asmlinkage int sys_rt_sigreturn(void)
if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(&frame->uc.uc_mcontext, &gr8))
Expand Down
4 changes: 0 additions & 4 deletions arch/h8300/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
#include <asm/traps.h>
#include <asm/ucontext.h>

#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))

/*
* Atomically swap in the new signal mask, and wait for a signal.
*/
Expand Down Expand Up @@ -186,7 +184,6 @@ asmlinkage int do_sigreturn(unsigned long __unused,...)
sizeof(frame->extramask))))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(regs, &frame->sc, &er0))
Expand All @@ -211,7 +208,6 @@ asmlinkage int do_rt_sigreturn(unsigned long __unused,...)
if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &er0))
Expand Down
3 changes: 0 additions & 3 deletions arch/hexagon/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
#include <asm/signal.h>
#include <asm/vdso.h>

#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))

struct rt_sigframe {
unsigned long tramp[2];
struct siginfo info;
Expand Down Expand Up @@ -273,7 +271,6 @@ asmlinkage int sys_rt_sigreturn(void)
if (__copy_from_user(&blocked, &frame->uc.uc_sigmask, sizeof(blocked)))
goto badframe;

sigdelsetmask(&blocked, ~_BLOCKABLE);
set_current_blocked(&blocked);

if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
Expand Down
2 changes: 0 additions & 2 deletions arch/ia64/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#define DEBUG_SIG 0
#define STACK_ALIGN 16 /* minimal alignment for stack pointer */
#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))

#if _NSIG_WORDS > 1
# define PUT_SIGSET(k,u) __copy_to_user((u)->sig, (k)->sig, sizeof(sigset_t))
Expand Down Expand Up @@ -200,7 +199,6 @@ ia64_rt_sigreturn (struct sigscratch *scr)
if (GET_SIGSET(&set, &sc->sc_mask))
goto give_sigsegv;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(sc, scr))
Expand Down
3 changes: 0 additions & 3 deletions arch/m32r/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

#define DEBUG_SIG 0

#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))

asmlinkage int
sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
unsigned long r2, unsigned long r3, unsigned long r4,
Expand Down Expand Up @@ -111,7 +109,6 @@ sys_rt_sigreturn(unsigned long r0, unsigned long r1,
if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &result))
Expand Down
4 changes: 0 additions & 4 deletions arch/m68k/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
#include <asm/traps.h>
#include <asm/ucontext.h>

#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))

#ifdef CONFIG_MMU

/*
Expand Down Expand Up @@ -795,7 +793,6 @@ asmlinkage int do_sigreturn(unsigned long __unused)
sizeof(frame->extramask))))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(regs, &frame->sc, frame + 1))
Expand All @@ -820,7 +817,6 @@ asmlinkage int do_rt_sigreturn(unsigned long __unused)
if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (rt_restore_ucontext(regs, sw, &frame->uc))
Expand Down
3 changes: 0 additions & 3 deletions arch/microblaze/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
#include <asm/cacheflush.h>
#include <asm/syscalls.h>

#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))

asmlinkage long
sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
struct pt_regs *regs)
Expand Down Expand Up @@ -106,7 +104,6 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)
if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &rval))
Expand Down
2 changes: 0 additions & 2 deletions arch/mips/kernel/signal-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
# define DEBUGP(fmt, args...)
#endif

#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))

/*
* Determine which stack to use..
*/
Expand Down
2 changes: 0 additions & 2 deletions arch/mips/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ asmlinkage void sys_sigreturn(nabi_no_regargs struct pt_regs regs)
if (__copy_from_user(&blocked, &frame->sf_mask, sizeof(blocked)))
goto badframe;

sigdelsetmask(&blocked, ~_BLOCKABLE);
set_current_blocked(&blocked);

sig = restore_sigcontext(&regs, &frame->sf_sc);
Expand Down Expand Up @@ -375,7 +374,6 @@ asmlinkage void sys_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
if (__copy_from_user(&set, &frame->rs_uc.uc_sigmask, sizeof(set)))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

sig = restore_sigcontext(&regs, &frame->rs_uc.uc_mcontext);
Expand Down
2 changes: 0 additions & 2 deletions arch/mips/kernel/signal32.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,6 @@ asmlinkage void sys32_sigreturn(nabi_no_regargs struct pt_regs regs)
if (__copy_conv_sigset_from_user(&blocked, &frame->sf_mask))
goto badframe;

sigdelsetmask(&blocked, ~_BLOCKABLE);
set_current_blocked(&blocked);

sig = restore_sigcontext32(&regs, &frame->sf_sc);
Expand Down Expand Up @@ -503,7 +502,6 @@ asmlinkage void sys32_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
if (__copy_conv_sigset_from_user(&set, &frame->rs_uc.uc_sigmask))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

sig = restore_sigcontext32(&regs, &frame->rs_uc.uc_mcontext);
Expand Down
1 change: 0 additions & 1 deletion arch/mips/kernel/signal_n32.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ asmlinkage void sysn32_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
if (__copy_conv_sigset_from_user(&set, &frame->rs_uc.uc_sigmask))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

sig = restore_sigcontext(&regs, &frame->rs_uc.uc_mcontext);
Expand Down
4 changes: 0 additions & 4 deletions arch/mn10300/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@

#define DEBUG_SIG 0

#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))

/*
* atomically swap in the new signal mask, and wait for a signal.
*/
Expand Down Expand Up @@ -163,7 +161,6 @@ asmlinkage long sys_sigreturn(void)
sizeof(frame->extramask)))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(current_frame(), &frame->sc, &d0))
Expand Down Expand Up @@ -191,7 +188,6 @@ asmlinkage long sys_rt_sigreturn(void)
if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(current_frame(), &frame->uc.uc_mcontext, &d0))
Expand Down
3 changes: 0 additions & 3 deletions arch/openrisc/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@

#define DEBUG_SIG 0

#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))

asmlinkage long
_sys_sigaltstack(const stack_t *uss, stack_t *uoss, struct pt_regs *regs)
{
Expand Down Expand Up @@ -101,7 +99,6 @@ asmlinkage long _sys_rt_sigreturn(struct pt_regs *regs)
if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
goto badframe;

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

if (restore_sigcontext(regs, &frame->uc.uc_mcontext))
Expand Down
4 changes: 0 additions & 4 deletions arch/parisc/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@
#define DBG(LEVEL, ...)
#endif


#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))

/* gcc will complain if a pointer is cast to an integer of different
* size. If you really need to do this (and we do for an ELF32 user
* application in an ELF64 kernel) then you have to do a cast to an
Expand Down Expand Up @@ -131,7 +128,6 @@ sys_rt_sigreturn(struct pt_regs *regs, int in_syscall)
goto give_sigsegv;
}

sigdelsetmask(&set, ~_BLOCKABLE);
set_current_blocked(&set);

/* Good thing we saved the old gr[30], eh? */
Expand Down
2 changes: 0 additions & 2 deletions arch/parisc/kernel/signal32.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
#define DBG(LEVEL, ...)
#endif

#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))

inline void
sigset_32to64(sigset_t *s64, compat_sigset_t *s32)
{
Expand Down
Loading

0 comments on commit 77097ae

Please sign in to comment.