Skip to content

Commit 143cf23

Browse files
mkerriskIngo Molnar
authored andcommitted
sched: Make sched_setattr() correctly return -EFBIG
The documented[1] behavior of sched_attr() in the 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> Signed-off-by: Peter Zijlstra <peterz@infradead.org> Cc: <stable@vger.kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: http://lkml.kernel.org/r/536CEC17.9070903@gmail.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 2b4cfe6 commit 143cf23

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

kernel/sched/core.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3658,8 +3658,9 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr,
36583658
if (!uattr || pid < 0 || flags)
36593659
return -EINVAL;
36603660

3661-
if (sched_copy_attr(uattr, &attr))
3662-
return -EFAULT;
3661+
retval = sched_copy_attr(uattr, &attr);
3662+
if (retval)
3663+
return retval;
36633664

36643665
rcu_read_lock();
36653666
retval = -ESRCH;

0 commit comments

Comments
 (0)