public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Jones <davej@redhat.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: mtk.manpages@gmail.com, peterz@infradead.org,
	torvalds@linux-foundation.org, mingo@kernel.org
Subject: Re: sched: Disallow sched_attr::sched_policy < 0
Date: Mon, 2 Jun 2014 16:22:04 -0400	[thread overview]
Message-ID: <20140602202204.GA26649@redhat.com> (raw)
In-Reply-To: <20140602021319.9A5F9660C19@gitolite.kernel.org>

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;



       reply	other threads:[~2014-06-02 20:22 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 [this message]
2014-06-03  8:08   ` sched: Disallow sched_attr::sched_policy < 0 Peter Zijlstra
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=20140602202204.GA26649@redhat.com \
    --to=davej@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=peterz@infradead.org \
    --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