mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Dave Jones <davej@redhat.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	mtk.manpages@gmail.com, torvalds@linux-foundation.org,
	mingo@kernel.org
Subject: Re: sched: Disallow sched_attr::sched_policy < 0
Date: Tue, 3 Jun 2014 10:08:26 +0200	[thread overview]
Message-ID: <20140603080826.GK11096@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20140602202204.GA26649@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1431 bytes --]

On Mon, Jun 02, 2014 at 04:22:04PM -0400, Dave Jones wrote:
> On Mon, Jun 02, 2014 at 02:13:19AM +0000, Linux Kernel wrote:
>  
>  >     sched: Disallow sched_attr::sched_policy < 0
>  >     
>  >     The scheduler uses policy=-1 to preserve the current policy state to
>  >     implement sys_sched_setparam(), this got exposed to userspace by
>  >     accident through sys_sched_setattr(), cure this.
>  >     
>  > ---
>  >  kernel/sched/core.c |    3 +++
>  >  1 files changed, 3 insertions(+), 0 deletions(-)
>  > 
>  > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
>  > index f2205f0..cdefcf7 100644
>  > --- a/kernel/sched/core.c
>  > +++ b/kernel/sched/core.c
>  > @@ -3662,6 +3662,9 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr,
>  >  	if (retval)
>  >  		return retval;
>  >  
>  > +	if (attr.sched_policy < 0)
>  > +		return -EINVAL;
>  > +
>  >  	rcu_read_lock();
>  >  	retval = -ESRCH;
>  >  	p = find_process_by_pid(pid);
>  
> Todays coverity run picked up..
> 
> 3687
> >>>     CID 1219934:  Unsigned compared against 0  (NO_EFFECT)
> >>>     This less-than-zero comparison of an unsigned value is never true. "attr.sched_policy < 0U".
> 3688            if (attr.sched_policy < 0)
> 3689                    return -EINVAL;
> 

Once upon a time GCC also did warns like that, but my compiler is silent
:-(

Yes, that needs fixing..

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2014-06-03  8:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20140602021319.9A5F9660C19@gitolite.kernel.org>
2014-06-02 20:22 ` Dave Jones
2014-06-03  8:08   ` Peter Zijlstra [this message]
2014-06-03  8:15     ` Richard Weinberger
2014-06-03  8:32       ` Peter Zijlstra
2014-06-03  8:47         ` Richard Weinberger
2014-06-03 13:16           ` Dave Jones
2014-06-03 16:30     ` Linus Torvalds

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=20140603080826.GK11096@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=davej@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=torvalds@linux-foundation.org \
    /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

Powered by JetHome