[kernel/f20] Fix regression in sched_setparam (rhbz 1117942)

Josh Boyer jwboyer at fedoraproject.org
Thu Jul 24 14:45:20 UTC 2014


commit 5624b406532eb5e317b2703d23cd45204142207f
Author: Josh Boyer <jwboyer at fedoraproject.org>
Date:   Thu Jul 24 10:41:57 2014 -0400

    Fix regression in sched_setparam (rhbz 1117942)

 kernel.spec                                   |    7 +++
 sched-fix-sched_setparam-policy-1-logic.patch |   68 +++++++++++++++++++++++++
 2 files changed, 75 insertions(+), 0 deletions(-)
---
diff --git a/kernel.spec b/kernel.spec
index b063c8f..f9c1469 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -753,6 +753,9 @@ Patch25116: Revert-Bluetooth-Add-a-new-PID-VID-0cf3-e005-for-AR3.patch
 #CVE-2014-3534 rhbz 1114089 1122612
 Patch25117: s390-ptrace-fix-PSW-mask-check.patch
 
+#rhbz 1117942
+Patch25118: sched-fix-sched_setparam-policy-1-logic.patch
+
 
 # END OF PATCH DEFINITIONS
 
@@ -1466,6 +1469,9 @@ ApplyPatch Revert-Bluetooth-Add-a-new-PID-VID-0cf3-e005-for-AR3.patch
 #CVE-2014-3534 rhbz 1114089 1122612
 ApplyPatch s390-ptrace-fix-PSW-mask-check.patch
 
+#rhbz 1117942
+ApplyPatch sched-fix-sched_setparam-policy-1-logic.patch
+
 # END OF PATCH APPLICATIONS
 
 %endif
@@ -2278,6 +2284,7 @@ fi
 #                 ||     ||
 %changelog
 * Thu Jul 24 2014 Josh Boyer <jwboyer at fedoraproject.org>
+- Fix regression in sched_setparam (rhbz 1117942)
 - CVE-2014-3534 s390: ptrace: insufficient sanitization with psw mask (rhbz 1114089 1122612)
 - Fix ath3k bluetooth regression (rhbz 1121785)
 
diff --git a/sched-fix-sched_setparam-policy-1-logic.patch b/sched-fix-sched_setparam-policy-1-logic.patch
new file mode 100644
index 0000000..060e0dc
--- /dev/null
+++ b/sched-fix-sched_setparam-policy-1-logic.patch
@@ -0,0 +1,68 @@
+Bugzilla: 1117942
+Upstream-status: Sent for 3.16 and seen by peterz
+
+The scheduler uses policy=-1 to preserve the current policy state to
+implement sched_setparam(). But, as (int) -1 is equals to 0xffffffff,
+it's matching the if (policy & SCHED_RESET_ON_FORK) on
+_sched_setscheduler(). This match changes the policy value to an
+invalid value, breaking the sched_setparam() syscall.
+
+This patch checks policy=-1 before check the SCHED_RESET_ON_FORK flag.
+
+The following program shows the bug:
+
+int main(void)
+{
+	struct sched_param param = {
+		.sched_priority = 5,
+	};
+
+	sched_setscheduler(0, SCHED_FIFO, &param);
+	param.sched_priority = 1;
+	sched_setparam(0, &param);
+	param.sched_priority = 0;
+	sched_getparam(0, &param);
+	if (param.sched_priority != 1)
+		printf("failed priority setting (found %d instead of 1)\n",
+			param.sched_priority);
+	else
+		printf("priority setting fine\n");
+}
+
+Cc: Peter Zijlstra <peterz at infradead.org>
+Cc: Ingo Molnar <mingo at kernel.org>
+Cc: Thomas Gleixner <tglx at linutronix.de>
+Cc: stable at vger.kernel.org # 3.14+
+Fixes: 7479f3c9cf67 "sched: Move SCHED_RESET_ON_FORK into attr::sched_flags"
+Reviewed-by: Steven Rostedt <rostedt at goodmis.org>
+Signed-off-by: Daniel Bristot de Oliveira <bristot at redhat.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 bc1638b..0acf96b 100644
+--- a/kernel/sched/core.c
++++ b/kernel/sched/core.c
+@@ -3558,9 +3558,10 @@ static int _sched_setscheduler(struct task_struct *p, int policy,
+ 	};
+ 
+ 	/*
+-	 * Fixup the legacy SCHED_RESET_ON_FORK hack
++	 * Fixup the legacy SCHED_RESET_ON_FORK hack, except if
++	 * the policy=-1 was passed by sched_setparam().
+ 	 */
+-	if (policy & SCHED_RESET_ON_FORK) {
++	if ((policy != -1) && (policy & SCHED_RESET_ON_FORK)) {
+ 		attr.sched_flags |= SCHED_FLAG_RESET_ON_FORK;
+ 		policy &= ~SCHED_RESET_ON_FORK;
+ 		attr.sched_policy = policy;
+-- 
+1.9.3
+
+--
+To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
+the body of a message to majordomo at vger.kernel.org
+More majordomo info at  http://vger.kernel.org/majordomo-info.html
+Please read the FAQ at  http://www.tux.org/lkml/


More information about the scm-commits mailing list