Skip to content

Commit eaad451

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
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: Daniel Lezcano <daniel.lezcano@linaro.org> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Cc: raistlin@linux.it Cc: juri.lelli@gmail.com Cc: Daniel Lezcano <daniel.lezcano@linaro.org> Fixes: d50dde5 ("sched: Add new scheduler syscalls to support an extended scheduling parameters ABI") Link: http://lkml.kernel.org/r/20140116165425.GA9481@laptop.programming.kicks-ass.net Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 7479f3c commit eaad451

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

kernel/sched/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3296,7 +3296,8 @@ static int __sched_setscheduler(struct task_struct *p,
32963296
*/
32973297
if (user && !capable(CAP_SYS_NICE)) {
32983298
if (fair_policy(policy)) {
3299-
if (!can_nice(p, attr->sched_nice))
3299+
if (attr->sched_nice < TASK_NICE(p) &&
3300+
!can_nice(p, attr->sched_nice))
33003301
return -EPERM;
33013302
}
33023303

0 commit comments

Comments
 (0)