From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756882AbaEIOy3 (ORCPT ); Fri, 9 May 2014 10:54:29 -0400 Received: from mail-ee0-f42.google.com ([74.125.83.42]:41120 "EHLO mail-ee0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756789AbaEIOy0 (ORCPT ); Fri, 9 May 2014 10:54:26 -0400 Message-ID: <536CEC17.9070903@gmail.com> Date: Fri, 09 May 2014 16:54:15 +0200 From: "Michael Kerrisk (man-pages)" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: Peter Zijlstra CC: mtk.manpages@gmail.com, lkml , Juri Lelli , Dario Faggioli , Ingo Molnar , "linux-man@vger.kernel.org" Subject: [PATCH 1/3] sched: Make sched_setattr() correctly return -EFBIG References: <536CEAEE.4010609@gmail.com> In-Reply-To: <536CEAEE.4010609@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Kerrisk 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 --- 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