[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140509085311.GJ30445@twins.programming.kicks-ass.net>
Date: Fri, 9 May 2014 10:53:11 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: "Michael Kerrisk (man-pages)" <mtk.manpages@...il.com>
Cc: Juri Lelli <juri.lelli@...il.com>,
Dario Faggioli <raistlin@...ux.it>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, rostedt@...dmis.org,
Oleg Nesterov <oleg@...hat.com>, fweisbec@...il.com,
darren@...art.com, johan.eker@...csson.com, p.faure@...tech.ch,
Linux Kernel <linux-kernel@...r.kernel.org>,
claudio@...dence.eu.com, michael@...rulasolutions.com,
fchecconi@...il.com, tommaso.cucinotta@...up.it,
nicola.manica@...i.unitn.it, luca.abeni@...tn.it,
dhaval.giani@...il.com, hgu1972@...il.com,
Paul McKenney <paulmck@...ux.vnet.ibm.com>,
insop.song@...il.com, liming.wang@...driver.com, jkacur@...hat.com,
linux-man@...r.kernel.org
Subject: Re: sched_{set,get}attr() manpage
On Fri, May 09, 2014 at 10:23:22AM +0200, Michael Kerrisk (man-pages) wrote:
> Hi Peter,
>
> I'm working on this text. I see the following in kernel/sched/core.c:
>
> [[
> static int __sched_setscheduler(struct task_struct *p,
> const struct sched_attr *attr,
> bool user)
> {
> ...
>
> int policy = attr->sched_policy;
> ...
> if (policy < 0) {
> reset_on_fork = p->sched_reset_on_fork;
> policy = oldpolicy = p->policy;
> ]]
>
> What's a negative policy about? Is this something that should
> be documented?
That's for sched_setparam(), which internally passes policy = -1, it
wasn't meant to be user visible, lemme double check that.
sys_sched_setscheduler() -- explicit check for policy < 0
sys_sched_setparam() -- explicitly passes policy=-1, not user visible
sys_sched_setattr() -- hmm, it looks like fail
---
Subject: sched: Disallow sched_attr::sched_policy < 0
From: Peter Zijlstra <peterz@...radead.org>
Date: Fri May 9 10:49:03 CEST 2014
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.
Reported-by: Michael Kerrisk <mtk.manpages@...il.com>
Signed-off-by: Peter Zijlstra <peterz@...radead.org>
Link: http://lkml.kernel.org/n/tip-b4kbwz2qh21xlngdzje00t55@git.kernel.org
---
kernel/sched/core.c | 3 +++
1 file changed, 3 insertions(+)
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3711,6 +3711,9 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pi
if (sched_copy_attr(uattr, &attr))
return -EFAULT;
+ if (attr.sched_policy < 0)
+ return -EINVAL;
+
rcu_read_lock();
retval = -ESRCH;
p = find_process_by_pid(pid);
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists