lkml.org 
[lkml]   [2008]   [Dec]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [Patch] signal: let valid_signal() check more
On Thu, Dec 25, 2008 at 07:00:54PM +0100, Oleg Nesterov wrote:
>On 12/26, Américo Wang wrote:
>>
>> Teach valid_signal() to check sig > 0 case.
>
>Why?

Just to simplify the checking.

>
>> @@ -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.


because it's inline?

>
>> -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;
>
>?


Yes, this one is better.

>
>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().


Oh, thanks for pointing this out. I didn't know this. Sorry.

>
>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?

I think this is a good idea. I will do it.

Thanks.

--
"Against stupidity, the gods themselves, contend in vain."

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2008-12-26 07:53    [W:0.350 / U:1.700 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site