Commit 7ed20e1a authored by Jesper Juhl's avatar Jesper Juhl Committed by Linus Torvalds

[PATCH] convert that currently tests _NSIG directly to use valid_signal()

Convert most of the current code that uses _NSIG directly to instead use
valid_signal().  This avoids gcc -W warnings and off-by-one errors.
Signed-off-by: default avatarJesper Juhl <juhl-lkml@dif.dk>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent e5bdd883
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <linux/user.h> #include <linux/user.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/signal.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
...@@ -335,7 +336,7 @@ do_sys_ptrace(long request, long pid, long addr, long data, ...@@ -335,7 +336,7 @@ do_sys_ptrace(long request, long pid, long addr, long data,
/* continue and stop at next (return from) syscall */ /* continue and stop at next (return from) syscall */
case PTRACE_CONT: /* restart after signal. */ case PTRACE_CONT: /* restart after signal. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
if (request == PTRACE_SYSCALL) if (request == PTRACE_SYSCALL)
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
...@@ -365,7 +366,7 @@ do_sys_ptrace(long request, long pid, long addr, long data, ...@@ -365,7 +366,7 @@ do_sys_ptrace(long request, long pid, long addr, long data,
case PTRACE_SINGLESTEP: /* execute single instruction. */ case PTRACE_SINGLESTEP: /* execute single instruction. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
/* Mark single stepping. */ /* Mark single stepping. */
child->thread_info->bpt_nsaved = -1; child->thread_info->bpt_nsaved = -1;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/user.h> #include <linux/user.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/signal.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
...@@ -693,7 +694,7 @@ static int do_ptrace(int request, struct task_struct *child, long addr, long dat ...@@ -693,7 +694,7 @@ static int do_ptrace(int request, struct task_struct *child, long addr, long dat
case PTRACE_SYSCALL: case PTRACE_SYSCALL:
case PTRACE_CONT: case PTRACE_CONT:
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
if (request == PTRACE_SYSCALL) if (request == PTRACE_SYSCALL)
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
...@@ -728,7 +729,7 @@ static int do_ptrace(int request, struct task_struct *child, long addr, long dat ...@@ -728,7 +729,7 @@ static int do_ptrace(int request, struct task_struct *child, long addr, long dat
*/ */
case PTRACE_SINGLESTEP: case PTRACE_SINGLESTEP:
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
child->ptrace |= PT_SINGLESTEP; child->ptrace |= PT_SINGLESTEP;
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/user.h> #include <linux/user.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/signal.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
...@@ -591,7 +592,7 @@ static int do_ptrace(int request, struct task_struct *child, long addr, long dat ...@@ -591,7 +592,7 @@ static int do_ptrace(int request, struct task_struct *child, long addr, long dat
case PTRACE_SYSCALL: case PTRACE_SYSCALL:
case PTRACE_CONT: case PTRACE_CONT:
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
if (request == PTRACE_SYSCALL) if (request == PTRACE_SYSCALL)
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
...@@ -626,7 +627,7 @@ static int do_ptrace(int request, struct task_struct *child, long addr, long dat ...@@ -626,7 +627,7 @@ static int do_ptrace(int request, struct task_struct *child, long addr, long dat
*/ */
case PTRACE_SINGLESTEP: case PTRACE_SINGLESTEP:
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
child->ptrace |= PT_SINGLESTEP; child->ptrace |= PT_SINGLESTEP;
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/user.h> #include <linux/user.h>
#include <linux/signal.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -184,7 +185,7 @@ sys_ptrace(long request, long pid, long addr, long data) ...@@ -184,7 +185,7 @@ sys_ptrace(long request, long pid, long addr, long data)
case PTRACE_CONT: case PTRACE_CONT:
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
if (request == PTRACE_SYSCALL) { if (request == PTRACE_SYSCALL) {
...@@ -219,7 +220,7 @@ sys_ptrace(long request, long pid, long addr, long data) ...@@ -219,7 +220,7 @@ sys_ptrace(long request, long pid, long addr, long data)
case PTRACE_SINGLESTEP: case PTRACE_SINGLESTEP:
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/user.h> #include <linux/user.h>
#include <linux/config.h> #include <linux/config.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/signal.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -239,7 +240,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) ...@@ -239,7 +240,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
case PTRACE_CONT: /* restart after signal. */ case PTRACE_CONT: /* restart after signal. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
if (request == PTRACE_SYSCALL) if (request == PTRACE_SYSCALL)
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
...@@ -267,7 +268,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) ...@@ -267,7 +268,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
case PTRACE_SINGLESTEP: /* set the trap flag. */ case PTRACE_SINGLESTEP: /* set the trap flag. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
ptrace_enable(child); ptrace_enable(child);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/user.h> #include <linux/user.h>
#include <linux/config.h> #include <linux/config.h>
#include <linux/signal.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -171,7 +172,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) ...@@ -171,7 +172,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
case PTRACE_CONT: { /* restart after signal. */ case PTRACE_CONT: { /* restart after signal. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data >= _NSIG) if (!valid_signal(data))
break ; break ;
if (request == PTRACE_SYSCALL) if (request == PTRACE_SYSCALL)
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
...@@ -202,7 +203,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) ...@@ -202,7 +203,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
case PTRACE_SINGLESTEP: { /* set the trap flag. */ case PTRACE_SINGLESTEP: { /* set the trap flag. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
child->exit_code = data; child->exit_code = data;
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/security.h> #include <linux/security.h>
#include <linux/audit.h> #include <linux/audit.h>
#include <linux/seccomp.h> #include <linux/seccomp.h>
#include <linux/signal.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
...@@ -511,7 +512,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) ...@@ -511,7 +512,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
case PTRACE_CONT: /* restart after signal. */ case PTRACE_CONT: /* restart after signal. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
if (request == PTRACE_SYSCALL) { if (request == PTRACE_SYSCALL) {
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
...@@ -543,7 +544,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) ...@@ -543,7 +544,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
case PTRACE_SINGLESTEP: /* set the trap flag. */ case PTRACE_SINGLESTEP: /* set the trap flag. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
set_singlestep(child); set_singlestep(child);
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/user.h> #include <linux/user.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/audit.h> #include <linux/audit.h>
#include <linux/signal.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/processor.h> #include <asm/processor.h>
...@@ -1481,7 +1482,7 @@ sys_ptrace (long request, pid_t pid, unsigned long addr, unsigned long data) ...@@ -1481,7 +1482,7 @@ sys_ptrace (long request, pid_t pid, unsigned long addr, unsigned long data)
case PTRACE_CONT: case PTRACE_CONT:
/* restart after signal. */ /* restart after signal. */
ret = -EIO; ret = -EIO;
if (data > _NSIG) if (!valid_signal(data))
goto out_tsk; goto out_tsk;
if (request == PTRACE_SYSCALL) if (request == PTRACE_SYSCALL)
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
...@@ -1520,7 +1521,7 @@ sys_ptrace (long request, pid_t pid, unsigned long addr, unsigned long data) ...@@ -1520,7 +1521,7 @@ sys_ptrace (long request, pid_t pid, unsigned long addr, unsigned long data)
/* let child execute for one instruction */ /* let child execute for one instruction */
case PTRACE_SINGLEBLOCK: case PTRACE_SINGLEBLOCK:
ret = -EIO; ret = -EIO;
if (data > _NSIG) if (!valid_signal(data))
goto out_tsk; goto out_tsk;
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/user.h> #include <linux/user.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/signal.h>
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -665,7 +666,7 @@ do_ptrace(long request, struct task_struct *child, long addr, long data) ...@@ -665,7 +666,7 @@ do_ptrace(long request, struct task_struct *child, long addr, long data)
case PTRACE_SYSCALL: case PTRACE_SYSCALL:
case PTRACE_CONT: case PTRACE_CONT:
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
if (request == PTRACE_SYSCALL) if (request == PTRACE_SYSCALL)
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
...@@ -700,7 +701,7 @@ do_ptrace(long request, struct task_struct *child, long addr, long data) ...@@ -700,7 +701,7 @@ do_ptrace(long request, struct task_struct *child, long addr, long data)
unsigned long pc, insn; unsigned long pc, insn;
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
if ((child->ptrace & PT_DTRACE) == 0) { if ((child->ptrace & PT_DTRACE) == 0) {
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/user.h> #include <linux/user.h>
#include <linux/config.h> #include <linux/config.h>
#include <linux/signal.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -251,7 +252,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) ...@@ -251,7 +252,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
long tmp; long tmp;
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
if (request == PTRACE_SYSCALL) { if (request == PTRACE_SYSCALL) {
child->thread.work.syscall_trace = ~0; child->thread.work.syscall_trace = ~0;
...@@ -292,7 +293,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) ...@@ -292,7 +293,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
long tmp; long tmp;
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
child->thread.work.syscall_trace = 0; child->thread.work.syscall_trace = 0;
tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16); tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16);
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/user.h> #include <linux/user.h>
#include <linux/config.h> #include <linux/config.h>
#include <linux/signal.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -240,7 +241,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) ...@@ -240,7 +241,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
long tmp; long tmp;
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
if (request == PTRACE_SYSCALL) if (request == PTRACE_SYSCALL)
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
...@@ -278,7 +279,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) ...@@ -278,7 +279,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
long tmp; long tmp;
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16); tmp = get_reg(child, PT_SR) | (TRACE_BITS << 16);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/user.h> #include <linux/user.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/signal.h>
#include <asm/cpu.h> #include <asm/cpu.h>
#include <asm/fpu.h> #include <asm/fpu.h>
...@@ -257,7 +258,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) ...@@ -257,7 +258,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
case PTRACE_CONT: { /* restart after signal. */ case PTRACE_CONT: { /* restart after signal. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
if (request == PTRACE_SYSCALL) { if (request == PTRACE_SYSCALL) {
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/user.h> #include <linux/user.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/signal.h>
#include <asm/cpu.h> #include <asm/cpu.h>
#include <asm/fpu.h> #include <asm/fpu.h>
...@@ -241,7 +242,7 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data) ...@@ -241,7 +242,7 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
case PTRACE_CONT: { /* restart after signal. */ case PTRACE_CONT: { /* restart after signal. */
ret = -EIO; ret = -EIO;
if ((unsigned int) data > _NSIG) if (!valid_signal(data))
break; break;
if (request == PTRACE_SYSCALL) { if (request == PTRACE_SYSCALL) {
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/personality.h> #include <linux/personality.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/signal.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
...@@ -285,7 +286,7 @@ long sys_ptrace(long request, pid_t pid, long addr, long data) ...@@ -285,7 +286,7 @@ long sys_ptrace(long request, pid_t pid, long addr, long data)
ret = -EIO; ret = -EIO;
DBG("sys_ptrace(%s)\n", DBG("sys_ptrace(%s)\n",
request == PTRACE_SYSCALL ? "SYSCALL" : "CONT"); request == PTRACE_SYSCALL ? "SYSCALL" : "CONT");
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
goto out_tsk; goto out_tsk;
child->ptrace &= ~(PT_SINGLESTEP|PT_BLOCKSTEP); child->ptrace &= ~(PT_SINGLESTEP|PT_BLOCKSTEP);
if (request == PTRACE_SYSCALL) { if (request == PTRACE_SYSCALL) {
...@@ -311,7 +312,7 @@ long sys_ptrace(long request, pid_t pid, long addr, long data) ...@@ -311,7 +312,7 @@ long sys_ptrace(long request, pid_t pid, long addr, long data)
case PTRACE_SINGLEBLOCK: case PTRACE_SINGLEBLOCK:
DBG("sys_ptrace(SINGLEBLOCK)\n"); DBG("sys_ptrace(SINGLEBLOCK)\n");
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
goto out_tsk; goto out_tsk;
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
child->ptrace &= ~PT_SINGLESTEP; child->ptrace &= ~PT_SINGLESTEP;
...@@ -328,7 +329,7 @@ long sys_ptrace(long request, pid_t pid, long addr, long data) ...@@ -328,7 +329,7 @@ long sys_ptrace(long request, pid_t pid, long addr, long data)
case PTRACE_SINGLESTEP: case PTRACE_SINGLESTEP:
DBG("sys_ptrace(SINGLESTEP)\n"); DBG("sys_ptrace(SINGLESTEP)\n");
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
goto out_tsk; goto out_tsk;
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/user.h> #include <linux/user.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/signal.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -356,7 +357,7 @@ int sys_ptrace(long request, long pid, long addr, long data) ...@@ -356,7 +357,7 @@ int sys_ptrace(long request, long pid, long addr, long data)
case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
case PTRACE_CONT: { /* restart after signal. */ case PTRACE_CONT: { /* restart after signal. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
if (request == PTRACE_SYSCALL) { if (request == PTRACE_SYSCALL) {
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
...@@ -389,7 +390,7 @@ int sys_ptrace(long request, long pid, long addr, long data) ...@@ -389,7 +390,7 @@ int sys_ptrace(long request, long pid, long addr, long data)
case PTRACE_SINGLESTEP: { /* set the trap flag. */ case PTRACE_SINGLESTEP: { /* set the trap flag. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
set_single_step(child); set_single_step(child);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/security.h> #include <linux/security.h>
#include <linux/audit.h> #include <linux/audit.h>
#include <linux/seccomp.h> #include <linux/seccomp.h>
#include <linux/signal.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -162,7 +163,7 @@ int sys_ptrace(long request, long pid, long addr, long data) ...@@ -162,7 +163,7 @@ int sys_ptrace(long request, long pid, long addr, long data)
case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
case PTRACE_CONT: { /* restart after signal. */ case PTRACE_CONT: { /* restart after signal. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
if (request == PTRACE_SYSCALL) if (request == PTRACE_SYSCALL)
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
...@@ -194,7 +195,7 @@ int sys_ptrace(long request, long pid, long addr, long data) ...@@ -194,7 +195,7 @@ int sys_ptrace(long request, long pid, long addr, long data)
case PTRACE_SINGLESTEP: { /* set the trap flag. */ case PTRACE_SINGLESTEP: { /* set the trap flag. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
set_single_step(child); set_single_step(child);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/user.h> #include <linux/user.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/signal.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -293,7 +294,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data) ...@@ -293,7 +294,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
case PTRACE_CONT: { /* restart after signal. */ case PTRACE_CONT: { /* restart after signal. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
if (request == PTRACE_SYSCALL) if (request == PTRACE_SYSCALL)
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
...@@ -325,7 +326,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data) ...@@ -325,7 +326,7 @@ int sys32_ptrace(long request, long pid, unsigned long addr, unsigned long data)
case PTRACE_SINGLESTEP: { /* set the trap flag. */ case PTRACE_SINGLESTEP: { /* set the trap flag. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
set_single_step(child); set_single_step(child);
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <linux/user.h> #include <linux/user.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/audit.h> #include <linux/audit.h>
#include <linux/signal.h>
#include <asm/segment.h> #include <asm/segment.h>
#include <asm/page.h> #include <asm/page.h>
...@@ -609,7 +610,7 @@ do_ptrace(struct task_struct *child, long request, long addr, long data) ...@@ -609,7 +610,7 @@ do_ptrace(struct task_struct *child, long request, long addr, long data)
/* continue and stop at next (return from) syscall */ /* continue and stop at next (return from) syscall */
case PTRACE_CONT: case PTRACE_CONT:
/* restart after signal. */ /* restart after signal. */
if ((unsigned long) data >= _NSIG) if (!valid_signal(data))
return -EIO; return -EIO;
if (request == PTRACE_SYSCALL) if (request == PTRACE_SYSCALL)
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
...@@ -637,7 +638,7 @@ do_ptrace(struct task_struct *child, long request, long addr, long data) ...@@ -637,7 +638,7 @@ do_ptrace(struct task_struct *child, long request, long addr, long data)
case PTRACE_SINGLESTEP: case PTRACE_SINGLESTEP:
/* set the trap flag. */ /* set the trap flag. */
if ((unsigned long) data >= _NSIG) if (!valid_signal(data))
return -EIO; return -EIO;
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
child->exit_code = data; child->exit_code = data;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/user.h> #include <linux/user.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/signal.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -197,7 +198,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) ...@@ -197,7 +198,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
case PTRACE_CONT: { /* restart after signal. */ case PTRACE_CONT: { /* restart after signal. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
if (request == PTRACE_SYSCALL) if (request == PTRACE_SYSCALL)
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
...@@ -228,7 +229,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) ...@@ -228,7 +229,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
struct pt_regs *dummy = NULL; struct pt_regs *dummy = NULL;
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
if ((child->ptrace & PT_DTRACE) == 0) { if ((child->ptrace & PT_DTRACE) == 0) {
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/user.h> #include <linux/user.h>
#include <linux/signal.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -255,7 +256,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) ...@@ -255,7 +256,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
case PTRACE_CONT: { /* restart after signal. */ case PTRACE_CONT: { /* restart after signal. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
if (request == PTRACE_SYSCALL) if (request == PTRACE_SYSCALL)
set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
...@@ -285,7 +286,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data) ...@@ -285,7 +286,7 @@ asmlinkage int sys_ptrace(long request, long pid, long addr, long data)
struct pt_regs *regs; struct pt_regs *regs;
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
if ((child->ptrace & PT_DTRACE) == 0) { if ((child->ptrace & PT_DTRACE) == 0) {
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/signal.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/system.h> #include <asm/system.h>
...@@ -526,7 +527,7 @@ asmlinkage void do_ptrace(struct pt_regs *regs) ...@@ -526,7 +527,7 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
addr = 1; addr = 1;
case PTRACE_CONT: { /* restart after signal. */ case PTRACE_CONT: { /* restart after signal. */
if (data > _NSIG) { if (!valid_signal(data)) {
pt_error_return(regs, EIO); pt_error_return(regs, EIO);
goto out_tsk; goto out_tsk;
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/signal.h>
#include <asm/asi.h> #include <asm/asi.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
...@@ -559,7 +560,7 @@ asmlinkage void do_ptrace(struct pt_regs *regs) ...@@ -559,7 +560,7 @@ asmlinkage void do_ptrace(struct pt_regs *regs)
addr = 1; addr = 1;
case PTRACE_CONT: { /* restart after signal. */ case PTRACE_CONT: { /* restart after signal. */
if (data > _NSIG) { if (!valid_signal(data)) {
pt_error_return(regs, EIO); pt_error_return(regs, EIO);
goto out_tsk; goto out_tsk;
} }
......
...@@ -143,7 +143,7 @@ long sys_ptrace(long request, long pid, long addr, long data) ...@@ -143,7 +143,7 @@ long sys_ptrace(long request, long pid, long addr, long data)
case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */ case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
case PTRACE_CONT: { /* restart after signal. */ case PTRACE_CONT: { /* restart after signal. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
child->ptrace &= ~PT_DTRACE; child->ptrace &= ~PT_DTRACE;
...@@ -179,7 +179,7 @@ long sys_ptrace(long request, long pid, long addr, long data) ...@@ -179,7 +179,7 @@ long sys_ptrace(long request, long pid, long addr, long data)
case PTRACE_SINGLESTEP: { /* set the trap flag. */ case PTRACE_SINGLESTEP: { /* set the trap flag. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
child->ptrace |= PT_DTRACE; child->ptrace |= PT_DTRACE;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/signal.h>
#include <asm/errno.h> #include <asm/errno.h>
#include <asm/ptrace.h> #include <asm/ptrace.h>
...@@ -208,7 +209,7 @@ int sys_ptrace(long request, long pid, long addr, long data) ...@@ -208,7 +209,7 @@ int sys_ptrace(long request, long pid, long addr, long data)
/* Execute a single instruction. */ /* Execute a single instruction. */
case PTRACE_SINGLESTEP: case PTRACE_SINGLESTEP:
rval = -EIO; rval = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
/* Turn CHILD's single-step flag on or off. */ /* Turn CHILD's single-step flag on or off. */
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/security.h> #include <linux/security.h>
#include <linux/audit.h> #include <linux/audit.h>
#include <linux/seccomp.h> #include <linux/seccomp.h>
#include <linux/signal.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
...@@ -467,7 +468,7 @@ asmlinkage long sys_ptrace(long request, long pid, unsigned long addr, long data ...@@ -467,7 +468,7 @@ asmlinkage long sys_ptrace(long request, long pid, unsigned long addr, long data
case PTRACE_CONT: /* restart after signal. */ case PTRACE_CONT: /* restart after signal. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
if (request == PTRACE_SYSCALL) if (request == PTRACE_SYSCALL)
set_tsk_thread_flag(child,TIF_SYSCALL_TRACE); set_tsk_thread_flag(child,TIF_SYSCALL_TRACE);
...@@ -529,7 +530,7 @@ asmlinkage long sys_ptrace(long request, long pid, unsigned long addr, long data ...@@ -529,7 +530,7 @@ asmlinkage long sys_ptrace(long request, long pid, unsigned long addr, long data
case PTRACE_SINGLESTEP: /* set the trap flag. */ case PTRACE_SINGLESTEP: /* set the trap flag. */
ret = -EIO; ret = -EIO;
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
break; break;
clear_tsk_thread_flag(child,TIF_SYSCALL_TRACE); clear_tsk_thread_flag(child,TIF_SYSCALL_TRACE);
set_singlestep(child); set_singlestep(child);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/major.h> #include <linux/major.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/console.h> #include <linux/console.h>
#include <linux/signal.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -641,7 +642,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file, ...@@ -641,7 +642,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
extern int spawnpid, spawnsig; extern int spawnpid, spawnsig;
if (!perm || !capable(CAP_KILL)) if (!perm || !capable(CAP_KILL))
return -EPERM; return -EPERM;
if (arg < 1 || arg > _NSIG || arg == SIGKILL) if (!valid_signal(arg) || arg < 1 || arg == SIGKILL)
return -EINVAL; return -EINVAL;
spawnpid = current->pid; spawnpid = current->pid;
spawnsig = arg; spawnsig = arg;
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/signal.h>
#include <asm/poll.h> #include <asm/poll.h>
#include <asm/siginfo.h> #include <asm/siginfo.h>
...@@ -308,7 +309,7 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, ...@@ -308,7 +309,7 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
break; break;
case F_SETSIG: case F_SETSIG:
/* arg == 0 restores default behaviour. */ /* arg == 0 restores default behaviour. */
if (arg < 0 || arg > _NSIG) { if (!valid_signal(arg)) {
break; break;
} }
err = 0; err = 0;
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/netlink.h> #include <linux/netlink.h>
#include <linux/syscalls.h> #include <linux/syscalls.h>
#include <linux/signal.h>
#include <net/sock.h> #include <net/sock.h>
#include "util.h" #include "util.h"
...@@ -976,8 +977,7 @@ asmlinkage long sys_mq_notify(mqd_t mqdes, ...@@ -976,8 +977,7 @@ asmlinkage long sys_mq_notify(mqd_t mqdes,
notification.sigev_notify != SIGEV_THREAD)) notification.sigev_notify != SIGEV_THREAD))
return -EINVAL; return -EINVAL;
if (notification.sigev_notify == SIGEV_SIGNAL && if (notification.sigev_notify == SIGEV_SIGNAL &&
(notification.sigev_signo < 0 || !valid_signal(notification.sigev_signo)) {
notification.sigev_signo > _NSIG)) {
return -EINVAL; return -EINVAL;
} }
if (notification.sigev_notify == SIGEV_THREAD) { if (notification.sigev_notify == SIGEV_THREAD) {
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/mempolicy.h> #include <linux/mempolicy.h>
#include <linux/cpuset.h> #include <linux/cpuset.h>
#include <linux/syscalls.h> #include <linux/syscalls.h>
#include <linux/signal.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/unistd.h> #include <asm/unistd.h>
...@@ -277,7 +278,7 @@ void set_special_pids(pid_t session, pid_t pgrp) ...@@ -277,7 +278,7 @@ void set_special_pids(pid_t session, pid_t pgrp)
*/ */
int allow_signal(int sig) int allow_signal(int sig)
{ {
if (sig < 1 || sig > _NSIG) if (!valid_signal(sig) || sig < 1)
return -EINVAL; return -EINVAL;
spin_lock_irq(&current->sighand->siglock); spin_lock_irq(&current->sighand->siglock);
...@@ -298,7 +299,7 @@ EXPORT_SYMBOL(allow_signal); ...@@ -298,7 +299,7 @@ EXPORT_SYMBOL(allow_signal);
int disallow_signal(int sig) int disallow_signal(int sig)
{ {
if (sig < 1 || sig > _NSIG) if (!valid_signal(sig) || sig < 1)
return -EINVAL; return -EINVAL;
spin_lock_irq(&current->sighand->siglock); spin_lock_irq(&current->sighand->siglock);
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/syscalls.h> #include <linux/syscalls.h>
#include <linux/signal.h>
#define FUTEX_HASHBITS (CONFIG_BASE_SMALL ? 4 : 8) #define FUTEX_HASHBITS (CONFIG_BASE_SMALL ? 4 : 8)
...@@ -654,7 +655,7 @@ static int futex_fd(unsigned long uaddr, int signal) ...@@ -654,7 +655,7 @@ static int futex_fd(unsigned long uaddr, int signal)
int ret, err; int ret, err;
ret = -EINVAL; ret = -EINVAL;
if (signal < 0 || signal > _NSIG) if (!valid_signal(signal))
goto out; goto out;
ret = get_unused_fd(); ret = get_unused_fd();
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/signal.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -166,7 +167,7 @@ int ptrace_attach(struct task_struct *task) ...@@ -166,7 +167,7 @@ int ptrace_attach(struct task_struct *task)
int ptrace_detach(struct task_struct *child, unsigned int data) int ptrace_detach(struct task_struct *child, unsigned int data)
{ {
if ((unsigned long) data > _NSIG) if (!valid_signal(data))
return -EIO; return -EIO;
/* Architecture-specific hardware disable .. */ /* Architecture-specific hardware disable .. */
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/syscalls.h> #include <linux/syscalls.h>
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/posix-timers.h> #include <linux/posix-timers.h>
#include <linux/signal.h>
#include <asm/param.h> #include <asm/param.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/unistd.h> #include <asm/unistd.h>
...@@ -646,7 +647,7 @@ static int check_kill_permission(int sig, struct siginfo *info, ...@@ -646,7 +647,7 @@ static int check_kill_permission(int sig, struct siginfo *info,
struct task_struct *t) struct task_struct *t)
{ {
int error = -EINVAL; int error = -EINVAL;
if (sig < 0 || sig > _NSIG) if (!valid_signal(sig))
return error; return error;
error = -EPERM; error = -EPERM;
if ((!info || ((unsigned long)info != 1 && if ((!info || ((unsigned long)info != 1 &&
...@@ -1245,7 +1246,7 @@ send_sig_info(int sig, struct siginfo *info, struct task_struct *p) ...@@ -1245,7 +1246,7 @@ send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
* Make sure legacy kernel users don't send in bad values * Make sure legacy kernel users don't send in bad values
* (normal paths check this in check_kill_permission). * (normal paths check this in check_kill_permission).
*/ */
if (sig < 0 || sig > _NSIG) if (!valid_signal(sig))
return -EINVAL; return -EINVAL;
/* /*
...@@ -1520,7 +1521,7 @@ void do_notify_parent(struct task_struct *tsk, int sig) ...@@ -1520,7 +1521,7 @@ void do_notify_parent(struct task_struct *tsk, int sig)
if (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN) if (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN)
sig = 0; sig = 0;
} }
if (sig > 0 && sig <= _NSIG) if (valid_signal(sig) && sig > 0)
__group_send_sig_info(sig, &info, tsk->parent); __group_send_sig_info(sig, &info, tsk->parent);
__wake_up_parent(tsk, tsk->parent); __wake_up_parent(tsk, tsk->parent);
spin_unlock_irqrestore(&psig->siglock, flags); spin_unlock_irqrestore(&psig->siglock, flags);
...@@ -2364,7 +2365,7 @@ do_sigaction(int sig, const struct k_sigaction *act, struct k_sigaction *oact) ...@@ -2364,7 +2365,7 @@ do_sigaction(int sig, const struct k_sigaction *act, struct k_sigaction *oact)
{ {
struct k_sigaction *k; struct k_sigaction *k;
if (sig < 1 || sig > _NSIG || (act && sig_kernel_only(sig))) if (!valid_signal(sig) || sig < 1 || (act && sig_kernel_only(sig)))
return -EINVAL; return -EINVAL;
k = &current->sighand->action[sig-1]; k = &current->sighand->action[sig-1];
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <linux/dcookies.h> #include <linux/dcookies.h>
#include <linux/suspend.h> #include <linux/suspend.h>
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/signal.h>
#include <linux/compat.h> #include <linux/compat.h>
#include <linux/syscalls.h> #include <linux/syscalls.h>
...@@ -1637,7 +1638,7 @@ asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3, ...@@ -1637,7 +1638,7 @@ asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3,
switch (option) { switch (option) {
case PR_SET_PDEATHSIG: case PR_SET_PDEATHSIG:
sig = arg2; sig = arg2;
if (sig < 0 || sig > _NSIG) { if (!valid_signal(sig)) {
error = -EINVAL; error = -EINVAL;
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment