public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: "Américo Wang" <xiyou.wangcong@gmail.com>
Cc: LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@osdl.org>
Subject: Re: [Patch] signal: let valid_signal() check more
Date: Thu, 25 Dec 2008 19:00:54 +0100	[thread overview]
Message-ID: <20081225180054.GA24116@redhat.com> (raw)
In-Reply-To: <20081226012612.GI3130@hack.private>

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.


  reply	other threads:[~2008-12-25 18:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-26  1:26 [Patch] signal: let valid_signal() check more Américo Wang
2008-12-25 18:00 ` Oleg Nesterov [this message]
2008-12-26 14:49   ` Américo Wang
2008-12-26  8:56     ` Ingo Molnar
2008-12-26 17:16       ` Américo Wang
2008-12-26 16:06         ` Oleg Nesterov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081225180054.GA24116@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox