aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorJesper Juhl <juhl-lkml@dif.dk>2005-05-01 11:59:14 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-01 11:59:14 -0400
commit7ed20e1ad521b5f5df61bf6559ae60738e393741 (patch)
tree90931724e45eaedb3445314e8b94e78253642395 /kernel
parente5bdd883a189243541e7a132385580703b049102 (diff)
[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: Jesper Juhl <juhl-lkml@dif.dk> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/exit.c5
-rw-r--r--kernel/futex.c3
-rw-r--r--kernel/ptrace.c3
-rw-r--r--kernel/signal.c9
-rw-r--r--kernel/sys.c3
5 files changed, 14 insertions, 9 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index 93851bcd9584..eb8da36e13df 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -27,6 +27,7 @@
27#include <linux/mempolicy.h> 27#include <linux/mempolicy.h>
28#include <linux/cpuset.h> 28#include <linux/cpuset.h>
29#include <linux/syscalls.h> 29#include <linux/syscalls.h>
30#include <linux/signal.h>
30 31
31#include <asm/uaccess.h> 32#include <asm/uaccess.h>
32#include <asm/unistd.h> 33#include <asm/unistd.h>
@@ -277,7 +278,7 @@ void set_special_pids(pid_t session, pid_t pgrp)
277 */ 278 */
278int allow_signal(int sig) 279int allow_signal(int sig)
279{ 280{
280 if (sig < 1 || sig > _NSIG) 281 if (!valid_signal(sig) || sig < 1)
281 return -EINVAL; 282 return -EINVAL;
282 283
283 spin_lock_irq(&current->sighand->siglock); 284 spin_lock_irq(&current->sighand->siglock);
@@ -298,7 +299,7 @@ EXPORT_SYMBOL(allow_signal);
298 299
299int disallow_signal(int sig) 300int disallow_signal(int sig)
300{ 301{
301 if (sig < 1 || sig > _NSIG) 302 if (!valid_signal(sig) || sig < 1)
302 return -EINVAL; 303 return -EINVAL;
303 304
304 spin_lock_irq(&current->sighand->siglock); 305 spin_lock_irq(&current->sighand->siglock);
diff --git a/kernel/futex.c b/kernel/futex.c
index 7b54a672d0ad..c7130f86106c 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -39,6 +39,7 @@
39#include <linux/mount.h> 39#include <linux/mount.h>
40#include <linux/pagemap.h> 40#include <linux/pagemap.h>
41#include <linux/syscalls.h> 41#include <linux/syscalls.h>
42#include <linux/signal.h>
42 43
43#define FUTEX_HASHBITS (CONFIG_BASE_SMALL ? 4 : 8) 44#define FUTEX_HASHBITS (CONFIG_BASE_SMALL ? 4 : 8)
44 45
@@ -654,7 +655,7 @@ static int futex_fd(unsigned long uaddr, int signal)
654 int ret, err; 655 int ret, err;
655 656
656 ret = -EINVAL; 657 ret = -EINVAL;
657 if (signal < 0 || signal > _NSIG) 658 if (!valid_signal(signal))
658 goto out; 659 goto out;
659 660
660 ret = get_unused_fd(); 661 ret = get_unused_fd();
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index f5cc1cec0fb4..8dcb8f6288bc 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -16,6 +16,7 @@
16#include <linux/smp_lock.h> 16#include <linux/smp_lock.h>
17#include <linux/ptrace.h> 17#include <linux/ptrace.h>
18#include <linux/security.h> 18#include <linux/security.h>
19#include <linux/signal.h>
19 20
20#include <asm/pgtable.h> 21#include <asm/pgtable.h>
21#include <asm/uaccess.h> 22#include <asm/uaccess.h>
@@ -166,7 +167,7 @@ bad:
166 167
167int ptrace_detach(struct task_struct *child, unsigned int data) 168int ptrace_detach(struct task_struct *child, unsigned int data)
168{ 169{
169 if ((unsigned long) data > _NSIG) 170 if (!valid_signal(data))
170 return -EIO; 171 return -EIO;
171 172
172 /* Architecture-specific hardware disable .. */ 173 /* Architecture-specific hardware disable .. */
diff --git a/kernel/signal.c b/kernel/signal.c
index e6567d7f2b62..8f3debc77c5b 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -23,6 +23,7 @@
23#include <linux/syscalls.h> 23#include <linux/syscalls.h>
24#include <linux/ptrace.h> 24#include <linux/ptrace.h>
25#include <linux/posix-timers.h> 25#include <linux/posix-timers.h>
26#include <linux/signal.h>
26#include <asm/param.h> 27#include <asm/param.h>
27#include <asm/uaccess.h> 28#include <asm/uaccess.h>
28#include <asm/unistd.h> 29#include <asm/unistd.h>
@@ -646,7 +647,7 @@ static int check_kill_permission(int sig, struct siginfo *info,
646 struct task_struct *t) 647 struct task_struct *t)
647{ 648{
648 int error = -EINVAL; 649 int error = -EINVAL;
649 if (sig < 0 || sig > _NSIG) 650 if (!valid_signal(sig))
650 return error; 651 return error;
651 error = -EPERM; 652 error = -EPERM;
652 if ((!info || ((unsigned long)info != 1 && 653 if ((!info || ((unsigned long)info != 1 &&
@@ -1245,7 +1246,7 @@ send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
1245 * Make sure legacy kernel users don't send in bad values 1246 * Make sure legacy kernel users don't send in bad values
1246 * (normal paths check this in check_kill_permission). 1247 * (normal paths check this in check_kill_permission).
1247 */ 1248 */
1248 if (sig < 0 || sig > _NSIG) 1249 if (!valid_signal(sig))
1249 return -EINVAL; 1250 return -EINVAL;
1250 1251
1251 /* 1252 /*
@@ -1520,7 +1521,7 @@ void do_notify_parent(struct task_struct *tsk, int sig)
1520 if (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN) 1521 if (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN)
1521 sig = 0; 1522 sig = 0;
1522 } 1523 }
1523 if (sig > 0 && sig <= _NSIG) 1524 if (valid_signal(sig) && sig > 0)
1524 __group_send_sig_info(sig, &info, tsk->parent); 1525 __group_send_sig_info(sig, &info, tsk->parent);
1525 __wake_up_parent(tsk, tsk->parent); 1526 __wake_up_parent(tsk, tsk->parent);
1526 spin_unlock_irqrestore(&psig->siglock, flags); 1527 spin_unlock_irqrestore(&psig->siglock, flags);
@@ -2364,7 +2365,7 @@ do_sigaction(int sig, const struct k_sigaction *act, struct k_sigaction *oact)
2364{ 2365{
2365 struct k_sigaction *k; 2366 struct k_sigaction *k;
2366 2367
2367 if (sig < 1 || sig > _NSIG || (act && sig_kernel_only(sig))) 2368 if (!valid_signal(sig) || sig < 1 || (act && sig_kernel_only(sig)))
2368 return -EINVAL; 2369 return -EINVAL;
2369 2370
2370 k = &current->sighand->action[sig-1]; 2371 k = &current->sighand->action[sig-1];
diff --git a/kernel/sys.c b/kernel/sys.c
index 7f43d6e62c7a..f64e97cabe25 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -25,6 +25,7 @@
25#include <linux/dcookies.h> 25#include <linux/dcookies.h>
26#include <linux/suspend.h> 26#include <linux/suspend.h>
27#include <linux/tty.h> 27#include <linux/tty.h>
28#include <linux/signal.h>
28 29
29#include <linux/compat.h> 30#include <linux/compat.h>
30#include <linux/syscalls.h> 31#include <linux/syscalls.h>
@@ -1637,7 +1638,7 @@ asmlinkage long sys_prctl(int option, unsigned long arg2, unsigned long arg3,
1637 switch (option) { 1638 switch (option) {
1638 case PR_SET_PDEATHSIG: 1639 case PR_SET_PDEATHSIG:
1639 sig = arg2; 1640 sig = arg2;
1640 if (sig < 0 || sig > _NSIG) { 1641 if (!valid_signal(sig)) {
1641 error = -EINVAL; 1642 error = -EINVAL;
1642 break; 1643 break;
1643 } 1644 }