* [PATCH 1/3] sched: Make sched_setattr() correctly return -EFBIG [not found] <536CEAEE.4010609@gmail.com> @ 2014-05-09 14:54 ` Michael Kerrisk (man-pages) [not found] ` <536CEC17.9070903-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 2+ messages in thread From: Michael Kerrisk (man-pages) @ 2014-05-09 14:54 UTC (permalink / raw) To: Peter Zijlstra Cc: mtk.manpages, lkml, Juri Lelli, Dario Faggioli, Ingo Molnar, linux-man@vger.kernel.org From: Michael Kerrisk <mtk.manpages@gmail.com> The documented[1] behavior of sched_attr() in your proposed man page text is: sched_attr::size must be set to the size of the structure, as in sizeof(struct sched_attr), if the provided structure is smaller than the kernel structure, any additional fields are assumed '0'. If the provided structure is larger than the kernel structure, the kernel verifies all additional fields are '0' if not the syscall will fail with -E2BIG. As currently implemented, sched_copy_attr() returns -EFBIG for for this case, but the logic in sys_sched_setattr() converts that error to -EFAULT. This patch fixes the behavior. [1] http://thread.gmane.org/gmane.linux.kernel/1615615/focus=1697760 Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com> --- kernel/sched/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 268a45e..6c9ce28 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3650,8 +3650,9 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr, if (!uattr || pid < 0 || flags) return -EINVAL; - if (sched_copy_attr(uattr, &attr)) - return -EFAULT; + retval = sched_copy_attr(uattr, &attr); + if (retval) + return retval; rcu_read_lock(); retval = -ESRCH; -- 1.9.0 ^ permalink raw reply related [flat|nested] 2+ messages in thread
[parent not found: <536CEC17.9070903-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH 1/3] sched: Make sched_setattr() correctly return -EFBIG [not found] ` <536CEC17.9070903-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2014-05-14 3:23 ` Michael Kerrisk (man-pages) 0 siblings, 0 replies; 2+ messages in thread From: Michael Kerrisk (man-pages) @ 2014-05-14 3:23 UTC (permalink / raw) To: Peter Zijlstra Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w, lkml, Juri Lelli, Dario Faggioli, Ingo Molnar, linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Peter, In the title of this patch, EFBIG should have been E2BIG. Shall I resubmit a corrected version? Cheers, Michael On 05/09/2014 04:54 PM, Michael Kerrisk (man-pages) wrote: > From: Michael Kerrisk <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > The documented[1] behavior of sched_attr() in your proposed man page text is: > > sched_attr::size must be set to the size of the structure, as in > sizeof(struct sched_attr), if the provided structure is smaller > than the kernel structure, any additional fields are assumed > '0'. If the provided structure is larger than the kernel structure, > the kernel verifies all additional fields are '0' if not the > syscall will fail with -E2BIG. > > As currently implemented, sched_copy_attr() returns -EFBIG for > for this case, but the logic in sys_sched_setattr() converts that > error to -EFAULT. This patch fixes the behavior. > > [1] http://thread.gmane.org/gmane.linux.kernel/1615615/focus=1697760 > > Signed-off-by: Michael Kerrisk <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > kernel/sched/core.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index 268a45e..6c9ce28 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -3650,8 +3650,9 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr, > if (!uattr || pid < 0 || flags) > return -EINVAL; > > - if (sched_copy_attr(uattr, &attr)) > - return -EFAULT; > + retval = sched_copy_attr(uattr, &attr); > + if (retval) > + return retval; > > rcu_read_lock(); > retval = -ESRCH; > -- 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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-14 3:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <536CEAEE.4010609@gmail.com>
2014-05-09 14:54 ` [PATCH 1/3] sched: Make sched_setattr() correctly return -EFBIG Michael Kerrisk (man-pages)
[not found] ` <536CEC17.9070903-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-14 3:23 ` Michael Kerrisk (man-pages)
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).