aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2014-05-09 10:49:03 +0200
committerShow Liu <show.liu@linaro.org>2014-06-18 12:05:23 +0800
commit1086a7c8498c4f420ea8838350c402d4a1fc1db4 (patch)
tree7978e1dc540411b99266eb58901d25a002b35c78
parent2dc8888707c94fc10551a6f8029315be0c1eb3ba (diff)
downloadlinaro-lsk-1086a7c8498c4f420ea8838350c402d4a1fc1db4.tar.gz
sched: Disallow sched_attr::sched_policy < 0
commit dbdb22754fde671dc93d2fae06f8be113d47f2fb upstream. 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@gmail.com> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Acked-by: Michael Kerrisk <mtk.manpages@gmail.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: http://lkml.kernel.org/r/20140509085311.GJ30445@twins.programming.kicks-ass.net Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--kernel/sched/core.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index a55b70c9830..c87074ae554 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3683,6 +3683,9 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr,
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);