From: Peter Zijlstra Date: Fri, 9 May 2014 08:49:03 +0000 (+0200) Subject: sched: Disallow sched_attr::sched_policy < 0 X-Git-Tag: v3.14.7~47 X-Git-Url: https://git.fsl.cs.sunysb.edu/?a=commitdiff_plain;h=5c246e46261532ccac530536336143171ce2d641;p=unionfs-2.6.22.y.git 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 Signed-off-by: Peter Zijlstra Acked-by: Michael Kerrisk Cc: Linus Torvalds Link: http://lkml.kernel.org/r/20140509085311.GJ30445@twins.programming.kicks-ass.net Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- 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);