Re: [Patch] signal: let valid_signal() check more
From: Oleg Nesterov
Date: Thu Dec 25 2008 - 13:03:25 EST
On 12/26, Américo Wang wrote:
>
> Teach valid_signal() to check sig > 0 case.
Why?
> @@ -727,7 +727,7 @@ int vt_ioctl(struct tty_struct *tty, struct file * file,
> {
> if (!perm || !capable(CAP_KILL))
> goto eperm;
> - if (!valid_signal(arg) || arg < 1 || arg == SIGKILL)
> + if (!valid_signal((int)arg) || arg == SIGKILL)
^^^^^
The patch adds a lot of unnecessary typecasts like this.
> -static inline int valid_signal(unsigned long sig)
> +static inline int valid_signal(int sig)
> {
> - return sig <= _NSIG ? 1 : 0;
> + return sig <= _NSIG ? (sig > 0) : 0;
> }
This looks a bit strange, why not
return sig > 0 && sig <= _NSIG;
?
But, more importantly, I don't think the patch is correct.
Unless I misread the patch, now kill(pid, 0) returns -EINVAL, no?
And we have other users of valid_signal() which assume that sig == 0
is OK, for example arch_ptrace().
Imho, the patch has a point, but perhaps it is better to add the
new helper and then convert the users which do something like
if (valid_signal(sig) && sig)
...
What do you think?
Oleg.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/