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-next>] [day] [month] [year] [list]
Date:	Thu, 26 May 2011 19:01:37 +0300
From:	Sergey Senozhatsky <sergey.senozhatsky@...il.com>
To:	Ingo Molnar <mingo@...e.hu>
Cc:	Peter Zijlstra <peterz@...radead.org>,
	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org
Subject: [PATCH] sched_rt: RCU-protect for_each_domain() within
 find_lowest_rq()

Protect for_each_domain() within find_lowest_rq() with RCU read-side critical 
section, suppressing suspicious rcu_dereference_check():

[ 2752.503488] ===================================================
[ 2752.503494] [ INFO: suspicious rcu_dereference_check() usage. ]
[ 2752.503497] ---------------------------------------------------
[ 2752.503501] kernel/sched_rt.c:1266 invoked rcu_dereference_check() without protection!
[ 2752.503504] 
[ 2752.503505] other info that might help us debug this:
[ 2752.503506] 
[ 2752.503510] rcu_scheduler_active = 1, debug_locks = 0
[ 2752.503514] 3 locks held by rcub0/9:
[ 2752.503517]  #0:  (&lock->wait_lock){+.+...}, at: [<ffffffff81479294>] rt_mutex_slowlock+0x34/0x154
[ 2752.503534]  #1:  (&p->pi_lock){-.-.-.}, at: [<ffffffff810768ab>] task_blocks_on_rt_mutex+0x124/0x1d1
[ 2752.503547]  #2:  (&rq->lock){-.-.-.}, at: [<ffffffff8103844b>] rt_mutex_setprio+0x5f/0x252
[ 2752.503559] 
[ 2752.503569] Call Trace:
[ 2752.503579]  [<ffffffff8106e5ab>] lockdep_rcu_dereference+0xa7/0xaf
[ 2752.503587]  [<ffffffff8102b089>] find_lowest_rq+0x131/0x1ad
[ 2752.503593]  [<ffffffff810370d4>] push_rt_task.part.133+0x89/0x247
[ 2752.503599]  [<ffffffff810372bc>] switched_to_rt+0x2a/0x65
[ 2752.503605]  [<ffffffff810385b4>] rt_mutex_setprio+0x1c8/0x252
[ 2752.503610]  [<ffffffff81076398>] __rt_mutex_adjust_prio+0x1d/0x21
[ 2752.503616]  [<ffffffff810768e7>] task_blocks_on_rt_mutex+0x160/0x1d1
[ 2752.503622]  [<ffffffff8147931c>] rt_mutex_slowlock+0xbc/0x154
[ 2752.503629]  [<ffffffff814793c6>] rt_mutex_lock+0x12/0x14
[ 2752.503637]  [<ffffffff810a4402>] rcu_boost+0xad/0xe1
[ 2752.503644]  [<ffffffff81479fe2>] ? _raw_spin_unlock_irqrestore+0x56/0x74
[ 2752.503652]  [<ffffffff8105d883>] ? finish_wait+0x5e/0x67
[ 2752.503657]  [<ffffffff810a4509>] rcu_boost_kthread+0xd3/0xfc
[ 2752.503663]  [<ffffffff8105d7c6>] ? __init_waitqueue_head+0x46/0x46
[ 2752.503669]  [<ffffffff810a4436>] ? rcu_boost+0xe1/0xe1
[ 2752.503675]  [<ffffffff8105cf6e>] kthread+0x9a/0xa2
[ 2752.503683]  [<ffffffff814810e4>] kernel_thread_helper+0x4/0x10
[ 2752.503689]  [<ffffffff8102d80c>] ? finish_task_switch+0x76/0xf0
[ 2752.503695]  [<ffffffff8147a4d8>] ? retint_restore_args+0x13/0x13
[ 2752.503701]  [<ffffffff8105ced4>] ? __init_kthread_worker+0x53/0x53
[ 2752.503707]  [<ffffffff814810e0>] ? gs_change+0x13/0x13


Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@...il.com>

---

 kernel/sched_rt.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/kernel/sched_rt.c b/kernel/sched_rt.c
index 64b2a37..242e476 100644
--- a/kernel/sched_rt.c
+++ b/kernel/sched_rt.c
@@ -1263,6 +1263,7 @@ static int find_lowest_rq(struct task_struct *task)
 	if (!cpumask_test_cpu(this_cpu, lowest_mask))
 		this_cpu = -1; /* Skip this_cpu opt if not among lowest */
 
+	rcu_read_lock();
 	for_each_domain(cpu, sd) {
 		if (sd->flags & SD_WAKE_AFFINE) {
 			int best_cpu;
@@ -1272,15 +1273,20 @@ static int find_lowest_rq(struct task_struct *task)
 			 * remote processor.
 			 */
 			if (this_cpu != -1 &&
-			    cpumask_test_cpu(this_cpu, sched_domain_span(sd)))
-				return this_cpu;
+			    cpumask_test_cpu(this_cpu, sched_domain_span(sd))) {
+				cpu = this_cpu;
+				goto out_unlock;
+			}
 
 			best_cpu = cpumask_first_and(lowest_mask,
 						     sched_domain_span(sd));
-			if (best_cpu < nr_cpu_ids)
-				return best_cpu;
+			if (best_cpu < nr_cpu_ids) {
+				cpu = best_cpu;
+				goto out_unlock;
+			}
 		}
 	}
+	rcu_read_unlock();
 
 	/*
 	 * And finally, if there were no matches within the domains
@@ -1294,6 +1300,10 @@ static int find_lowest_rq(struct task_struct *task)
 	if (cpu < nr_cpu_ids)
 		return cpu;
 	return -1;
+
+out_unlock:
+	rcu_read_unlock();
+	return cpu;
 }
 
 /* Will lock the rq it finds */

--
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