[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20081225180054.GA24116@redhat.com>
Date: Thu, 25 Dec 2008 19:00:54 +0100
From: Oleg Nesterov <oleg@...hat.com>
To: Américo Wang <xiyou.wangcong@...il.com>
Cc: LKML <linux-kernel@...r.kernel.org>, Ingo Molnar <mingo@...e.hu>,
Andrew Morton <akpm@...l.org>
Subject: Re: [Patch] signal: let valid_signal() check more
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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists