aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2014-05-09 10:49:03 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-06-11 11:54:10 -0700
commit5c246e46261532ccac530536336143171ce2d641 (patch)
treea93b944d1fb4e11fc66743dddb6a131f7c3d2486 /kernel
parentf6f465b98ae033f1f57179e2c4649b7d29d5af8e (diff)
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>
Diffstat (limited to 'kernel')
-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 f5c6635b806..dbe44b5c02f 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);