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] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190628182216.GY26519@linux.ibm.com>
Date:   Fri, 28 Jun 2019 11:22:16 -0700
From:   "Paul E. McKenney" <paulmck@...ux.ibm.com>
To:     Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc:     Joel Fernandes <joel@...lfernandes.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        rcu <rcu@...r.kernel.org>, LKML <linux-kernel@...r.kernel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Josh Triplett <josh@...htriplett.org>,
        Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
        Lai Jiangshan <jiangshanlai@...il.com>
Subject: Re: [RFC] Deadlock via recursive wakeup via RCU with threadirqs

On Fri, Jun 28, 2019 at 07:45:45PM +0200, Sebastian Andrzej Siewior wrote:
> On 2019-06-28 10:30:11 [-0700], Paul E. McKenney wrote:
> > > I believe the .blocked field remains set even though we are not any more in a
> > > reader section because of deferred processing of the blocked lists that you
> > > mentioned yesterday.
> > 
> > That can indeed happen.  However, in current -rcu, that would mean
> > that .deferred_qs is also set, which (if in_irq()) would prevent
> > the raise_softirq_irqsoff() from being invoked.  Which was why I was
> > asking the questions about whether in_irq() returns true within threaded
> > interrupts yesterday.  If it does, I need to find if there is some way
> > of determining whether rcu_read_unlock_special() is being called from
> > a threaded interrupt in order to suppress the call to raise_softirq()
> > in that case.
> 
> Please not that:
> | void irq_exit(void)
> | {
> |…
> in_irq() returns true
> |         preempt_count_sub(HARDIRQ_OFFSET);
> in_irq() returns false
> |         if (!in_interrupt() && local_softirq_pending())
> |                 invoke_softirq();
> 
> -> invoke_softirq() does
> |        if (!force_irqthreads) {
> |                 __do_softirq();
> |         } else {
> |                 wakeup_softirqd();
> |         }
> 
> so for `force_irqthreads' rcu_read_unlock_special() within
> wakeup_softirqd() will see false.

OK, fair point.  How about the following instead, again on -rcu?

Here is the rationale for the new version of the "if" statement:

1.	irqs_were_disabled:  If interrupts are enabled, we should
	instead let the upcoming irq_enable()/local_bh_enable()
	do the rescheduling for us.
2.	use_softirq: If we aren't using softirq, then
	raise_softirq_irqoff() will be unhelpful.
3a.	in_interrupt(): If this returns true, the subsequent
	call to raise_softirq_irqoff() is guaranteed not to
	do a wakeup, so that call will be both very cheap and
	quite safe.
3b.	Otherwise, if !in_interrupt(), if exp (an expedited RCU grace
	period is being blocked), then incurring wakeup overhead
	is worthwhile, and if also !.deferred_qs then scheduler locks
	cannot be held so the wakeup will be safe.

Does that make more sense?

							Thanx, Paul

------------------------------------------------------------------------

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 82c925df1d92..83333cfe8707 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -624,8 +624,9 @@ static void rcu_read_unlock_special(struct task_struct *t)
 		      (rdp->grpmask & rnp->expmask) ||
 		      tick_nohz_full_cpu(rdp->cpu);
 		// Need to defer quiescent state until everything is enabled.
-		if ((exp || in_irq()) && irqs_were_disabled && use_softirq &&
-		    (in_irq() || !t->rcu_read_unlock_special.b.deferred_qs)) {
+		if (irqs_were_disabled && use_softirq &&
+		    (in_interrupt() ||
+		     (exp && !t->rcu_read_unlock_special.b.deferred_qs))) {
 			// Using softirq, safe to awaken, and we get
 			// no help from enabling irqs, unlike bh/preempt.
 			raise_softirq_irqoff(RCU_SOFTIRQ);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ