sched: Disallow sched_attr::sched_policy < 0

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: <stable@vger.kernel.org>
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>

authored by Peter Zijlstra and committed by Ingo Molnar dbdb2275 143cf23d

Changed files
+3
kernel
sched
+3
kernel/sched/core.c
··· 3662 if (retval) 3663 return retval; 3664 3665 rcu_read_lock(); 3666 retval = -ESRCH; 3667 p = find_process_by_pid(pid);
··· 3662 if (retval) 3663 return retval; 3664 3665 + if (attr.sched_policy < 0) 3666 + return -EINVAL; 3667 + 3668 rcu_read_lock(); 3669 retval = -ESRCH; 3670 p = find_process_by_pid(pid);