From e7ceb798bffccd14d6405080767048aa24706dc9 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 9 Jun 2014 12:07:06 -0700 Subject: [PATCH] 3.14-stable patches added patches: sched-disallow-sched_attr-sched_policy-0.patch sched-make-sched_setattr-correctly-return-efbig.patch --- ...d-disallow-sched_attr-sched_policy-0.patch | 37 ++++++++++++++ ...sched_setattr-correctly-return-efbig.patch | 49 +++++++++++++++++++ queue-3.14/series | 2 + 3 files changed, 88 insertions(+) create mode 100644 queue-3.14/sched-disallow-sched_attr-sched_policy-0.patch create mode 100644 queue-3.14/sched-make-sched_setattr-correctly-return-efbig.patch diff --git a/queue-3.14/sched-disallow-sched_attr-sched_policy-0.patch b/queue-3.14/sched-disallow-sched_attr-sched_policy-0.patch new file mode 100644 index 00000000000..699873f728d --- /dev/null +++ b/queue-3.14/sched-disallow-sched_attr-sched_policy-0.patch @@ -0,0 +1,37 @@ +From dbdb22754fde671dc93d2fae06f8be113d47f2fb Mon Sep 17 00:00:00 2001 +From: Peter Zijlstra +Date: Fri, 9 May 2014 10:49:03 +0200 +Subject: sched: Disallow sched_attr::sched_policy < 0 + +From: Peter Zijlstra + +commit dbdb22754fde671dc93d2fae06f8be113d47f2fb upstream. + +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 +Signed-off-by: Peter Zijlstra +Acked-by: Michael Kerrisk +Cc: Linus Torvalds +Link: http://lkml.kernel.org/r/20140509085311.GJ30445@twins.programming.kicks-ass.net +Signed-off-by: Ingo Molnar +Signed-off-by: Greg Kroah-Hartman + +--- + kernel/sched/core.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/kernel/sched/core.c ++++ b/kernel/sched/core.c +@@ -3683,6 +3683,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); diff --git a/queue-3.14/sched-make-sched_setattr-correctly-return-efbig.patch b/queue-3.14/sched-make-sched_setattr-correctly-return-efbig.patch new file mode 100644 index 00000000000..84c1f7b78b9 --- /dev/null +++ b/queue-3.14/sched-make-sched_setattr-correctly-return-efbig.patch @@ -0,0 +1,49 @@ +From 143cf23df25b7082cd706c3c53188e741e7881c3 Mon Sep 17 00:00:00 2001 +From: Michael Kerrisk +Date: Fri, 9 May 2014 16:54:15 +0200 +Subject: sched: Make sched_setattr() correctly return -EFBIG + +From: Michael Kerrisk + +commit 143cf23df25b7082cd706c3c53188e741e7881c3 upstream. + +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 +Signed-off-by: Peter Zijlstra +Cc: Linus Torvalds +Link: http://lkml.kernel.org/r/536CEC17.9070903@gmail.com +Signed-off-by: Ingo Molnar +Signed-off-by: Greg Kroah-Hartman + +--- + kernel/sched/core.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +--- a/kernel/sched/core.c ++++ b/kernel/sched/core.c +@@ -3680,8 +3680,9 @@ SYSCALL_DEFINE3(sched_setattr, pid_t, pi + 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; + + if (attr.sched_policy < 0) + return -EINVAL; diff --git a/queue-3.14/series b/queue-3.14/series index 6fd10e9e29b..f97a5fd8c9f 100644 --- a/queue-3.14/series +++ b/queue-3.14/series @@ -29,3 +29,5 @@ dm-thin-add-no_space_timeout-dm-thin-pool-module-param.patch dm-cache-always-split-discards-on-cache-block-boundaries.patch revert-revert-mm-vmscan-do-not-swap-anon-pages-just.patch virtio_blk-fix-race-between-start-and-stop-queue.patch +sched-disallow-sched_attr-sched_policy-0.patch +sched-make-sched_setattr-correctly-return-efbig.patch -- 2.47.3