Hi Peter, On Fri, May 9, 2014 at 10:53 AM, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote: > On Fri, May 09, 2014 at 10:23:22AM +0200, Michael Kerrisk (man-pages) wrote: >> Hi Peter, >> >> I'm working on this text. I see the following in kernel/sched/core.c: >> >> [[ >> static int __sched_setscheduler(struct task_struct *p, >> const struct sched_attr *attr, >> bool user) >> { >> ... >> >> int policy = attr->sched_policy; >> ... >> if (policy < 0) { >> reset_on_fork = p->sched_reset_on_fork; >> policy = oldpolicy = p->policy; >> ]] >> >> What's a negative policy about? Is this something that should >> be documented? > > That's for sched_setparam(), which internally passes policy = -1, it > wasn't meant to be user visible, lemme double check that. > > sys_sched_setscheduler() -- explicit check for policy < 0 > sys_sched_setparam() -- explicitly passes policy=-1, not user visible (Ahh -- I missed that piece in sys_sched_setparam()) > sys_sched_setattr() -- hmm, it looks like fail Yep, I was seeing that there was no check in sched_setatr(). As I recently said, when it comes to writing a man page, show me a new interface, and I'll show you a bug ;-). Thanks for the clarification. Acked-by: Michael Kerrisk <mtk.manpages@xxxxxxxxx> Cheers, Michael > --- > Subject: sched: Disallow sched_attr::sched_policy < 0 > From: Peter Zijlstra <peterz@xxxxxxxxxxxxx> > Date: Fri May 9 10:49:03 CEST 2014 > > 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@xxxxxxxxx> > Signed-off-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx> > Link: http://lkml.kernel.org/n/tip-b4kbwz2qh21xlngdzje00t55@xxxxxxxxxxxxxx > --- > kernel/sched/core.c | 3 +++ > 1 file changed, 3 insertions(+) > > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -3711,6 +3711,9 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pi > 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); -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html