lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-aee38ea95419c818dfdde52b115aeffe9cbb259b@git.kernel.org>
Date:	Tue, 28 Oct 2014 04:02:07 -0700
From:	tip-bot for Juri Lelli <tipbot@...or.com>
To:	linux-tip-commits@...r.kernel.org
Cc:	juri.lelli@....com, hpa@...or.com, peterz@...radead.org,
	tglx@...utronix.de, michael@...rulasolutions.com,
	daniel.wagner@...-carit.de, mingo@...nel.org,
	linux-kernel@...r.kernel.org, torvalds@...ux-foundation.org,
	raistlin@...ux.it, fchecconi@...il.com
Subject: [tip:sched/core] sched/deadline:
  Fix races between rt_mutex_setprio() and dl_task_timer()

Commit-ID:  aee38ea95419c818dfdde52b115aeffe9cbb259b
Gitweb:     http://git.kernel.org/tip/aee38ea95419c818dfdde52b115aeffe9cbb259b
Author:     Juri Lelli <juri.lelli@....com>
AuthorDate: Fri, 24 Oct 2014 10:16:38 +0100
Committer:  Ingo Molnar <mingo@...nel.org>
CommitDate: Tue, 28 Oct 2014 10:46:01 +0100

sched/deadline: Fix races between rt_mutex_setprio() and dl_task_timer()

dl_task_timer() is racy against several paths. Daniel noticed that
the replenishment timer may experience a race condition against an
enqueue_dl_entity() called from rt_mutex_setprio(). With his own
words:

 rt_mutex_setprio() resets p->dl.dl_throttled. So the pattern is:
 start_dl_timer() throttled = 1, rt_mutex_setprio() throlled = 0,
 sched_switch() -> enqueue_task(), dl_task_timer-> enqueue_task()
 throttled is 0

=> BUG_ON(on_dl_rq(dl_se)) fires as the scheduling entity is already
enqueued on the -deadline runqueue.

As we do for the other races, we just bail out in the replenishment
timer code.

Reported-by: Daniel Wagner <daniel.wagner@...-carit.de>
Tested-by: Daniel Wagner <daniel.wagner@...-carit.de>
Signed-off-by: Juri Lelli <juri.lelli@....com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Cc: vincent@...out.info
Cc: Dario Faggioli <raistlin@...ux.it>
Cc: Michael Trimarchi <michael@...rulasolutions.com>
Cc: Fabio Checconi <fchecconi@...il.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Link: http://lkml.kernel.org/r/1414142198-18552-5-git-send-email-juri.lelli@arm.com
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
 kernel/sched/deadline.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 92279ea..4616789 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -518,12 +518,20 @@ again:
 	}
 
 	/*
-	 * We need to take care of a possible races here. In fact, the
-	 * task might have changed its scheduling policy to something
-	 * different from SCHED_DEADLINE or changed its reservation
-	 * parameters (through sched_setattr()).
+	 * We need to take care of several possible races here:
+	 *
+	 *   - the task might have changed its scheduling policy
+	 *     to something different than SCHED_DEADLINE
+	 *   - the task might have changed its reservation parameters
+	 *     (through sched_setattr())
+	 *   - the task might have been boosted by someone else and
+	 *     might be in the boosting/deboosting path
+	 *
+	 * In all this cases we bail out, as the task is already
+	 * in the runqueue or is going to be enqueued back anyway.
 	 */
-	if (!dl_task(p) || dl_se->dl_new)
+	if (!dl_task(p) || dl_se->dl_new ||
+	    dl_se->dl_boosted || !dl_se->dl_throttled)
 		goto unlock;
 
 	sched_clock_tick();
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ