Commit eaad4513 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

sched: Fix __sched_setscheduler() nice test

With the introduction of sched_attr::sched_nice we need to check
if we've got permission to actually change the nice value.

Daniel found that can_nice() would always fail; and upon
inspection it turns out that can_nice() only tests to see if we
can lower the nice value, but it doesn't validate if we're
lowering or not.

Therefore amend the test to only call can_nice() when we lower
the nice value.
Reported-and-Tested-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: default avatarPeter Zijlstra <peterz@infradead.org>
Cc: raistlin@linux.it
Cc: juri.lelli@gmail.com
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Fixes: d50dde5a ("sched: Add new scheduler syscalls to support an extended scheduling parameters ABI")
Link: http://lkml.kernel.org/r/20140116165425.GA9481@laptop.programming.kicks-ass.netSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 7479f3c9
...@@ -3296,7 +3296,8 @@ static int __sched_setscheduler(struct task_struct *p, ...@@ -3296,7 +3296,8 @@ static int __sched_setscheduler(struct task_struct *p,
*/ */
if (user && !capable(CAP_SYS_NICE)) { if (user && !capable(CAP_SYS_NICE)) {
if (fair_policy(policy)) { if (fair_policy(policy)) {
if (!can_nice(p, attr->sched_nice)) if (attr->sched_nice < TASK_NICE(p) &&
!can_nice(p, attr->sched_nice))
return -EPERM; return -EPERM;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment