aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kerrisk <mtk.manpages@gmail.com>2014-05-09 10:54:15 -0400
committerIngo Molnar <mingo@kernel.org>2014-05-22 04:21:25 -0400
commit143cf23df25b7082cd706c3c53188e741e7881c3 (patch)
tree6b0172d834371ac49279a96e1e1f53766009988d
parent2b4cfe64dee0d84506b951d81bf55d9891744d25 (diff)
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>
-rw-r--r--kernel/sched/core.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 13584f1cccfc..f2205f02eb70 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3658,8 +3658,9 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pid, struct sched_attr __user *, uattr,
3658 if (!uattr || pid < 0 || flags) 3658 if (!uattr || pid < 0 || flags)
3659 return -EINVAL; 3659 return -EINVAL;
3660 3660
3661 if (sched_copy_attr(uattr, &attr)) 3661 retval = sched_copy_attr(uattr, &attr);
3662 return -EFAULT; 3662 if (retval)
3663 return retval;
3663 3664
3664 rcu_read_lock(); 3665 rcu_read_lock();
3665 retval = -ESRCH; 3666 retval = -ESRCH;