netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 net] af_packet: block BH in prb_shutdown_retire_blk_timer()
@ 2013-11-29  8:53 Veaceslav Falico
  2013-11-29  9:19 ` Daniel Borkmann
  0 siblings, 1 reply; 3+ messages in thread
From: Veaceslav Falico @ 2013-11-29  8:53 UTC (permalink / raw)
  To: netdev
  Cc: jstancek, Veaceslav Falico, David S. Miller, Daniel Borkmann,
	Willem de Bruijn, Phil Sutter, Eric Dumazet

Currently we're using plain spin_lock() in prb_shutdown_retire_blk_timer(),
however the timer might fire right in the middle and thus try to re-aquire
the same spinlock, leaving us in a endless loop.

To fix that, use the spin_lock_bh() to block it.

CC: "David S. Miller" <davem@davemloft.net>
CC: Daniel Borkmann <dborkman@redhat.com>
CC: Willem de Bruijn <willemb@google.com>
CC: Phil Sutter <phil@nwl.cc>
CC: Eric Dumazet <edumazet@google.com>
Reported-by: Jan Stancek <jstancek@redhat.com>
Tested-by: Jan Stancek <jstancek@redhat.com>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---

Notes:
    v1 -> v2:
    Per Eric's suggestion, reward the commit message to actually match the
    patch (thanks a lot!).

 net/packet/af_packet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index ac27c86..ba2548b 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -439,9 +439,9 @@ static void prb_shutdown_retire_blk_timer(struct packet_sock *po,
 
 	pkc = tx_ring ? &po->tx_ring.prb_bdqc : &po->rx_ring.prb_bdqc;
 
-	spin_lock(&rb_queue->lock);
+	spin_lock_bh(&rb_queue->lock);
 	pkc->delete_blk_timer = 1;
-	spin_unlock(&rb_queue->lock);
+	spin_unlock_bh(&rb_queue->lock);
 
 	prb_del_retire_blk_timer(pkc);
 }
-- 
1.8.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 net] af_packet: block BH in prb_shutdown_retire_blk_timer()
  2013-11-29  8:53 [PATCH v2 net] af_packet: block BH in prb_shutdown_retire_blk_timer() Veaceslav Falico
@ 2013-11-29  9:19 ` Daniel Borkmann
  2013-11-29 21:11   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Borkmann @ 2013-11-29  9:19 UTC (permalink / raw)
  To: Veaceslav Falico
  Cc: netdev, jstancek, David S. Miller, Willem de Bruijn, Phil Sutter,
	Eric Dumazet

On 11/29/2013 09:53 AM, Veaceslav Falico wrote:
> Currently we're using plain spin_lock() in prb_shutdown_retire_blk_timer(),
> however the timer might fire right in the middle and thus try to re-aquire
> the same spinlock, leaving us in a endless loop.
>
> To fix that, use the spin_lock_bh() to block it.
>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: Daniel Borkmann <dborkman@redhat.com>
> CC: Willem de Bruijn <willemb@google.com>
> CC: Phil Sutter <phil@nwl.cc>
> CC: Eric Dumazet <edumazet@google.com>
> Reported-by: Jan Stancek <jstancek@redhat.com>
> Tested-by: Jan Stancek <jstancek@redhat.com>
> Signed-off-by: Veaceslav Falico <vfalico@redhat.com>

Fixes: f6fb8f100b80 ("af-packet: TPACKET_V3 flexible buffer implementation.")
Acked-by: Daniel Borkmann <dborkman@redhat.com>

Thanks everyone!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 net] af_packet: block BH in prb_shutdown_retire_blk_timer()
  2013-11-29  9:19 ` Daniel Borkmann
@ 2013-11-29 21:11   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2013-11-29 21:11 UTC (permalink / raw)
  To: dborkman; +Cc: vfalico, netdev, jstancek, willemb, phil, edumazet

From: Daniel Borkmann <dborkman@redhat.com>
Date: Fri, 29 Nov 2013 10:19:29 +0100

> On 11/29/2013 09:53 AM, Veaceslav Falico wrote:
>> Currently we're using plain spin_lock() in
>> prb_shutdown_retire_blk_timer(),
>> however the timer might fire right in the middle and thus try to
>> re-aquire
>> the same spinlock, leaving us in a endless loop.
>>
>> To fix that, use the spin_lock_bh() to block it.
>>
>> CC: "David S. Miller" <davem@davemloft.net>
>> CC: Daniel Borkmann <dborkman@redhat.com>
>> CC: Willem de Bruijn <willemb@google.com>
>> CC: Phil Sutter <phil@nwl.cc>
>> CC: Eric Dumazet <edumazet@google.com>
>> Reported-by: Jan Stancek <jstancek@redhat.com>
>> Tested-by: Jan Stancek <jstancek@redhat.com>
>> Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
> 
> Fixes: f6fb8f100b80 ("af-packet: TPACKET_V3 flexible buffer
> implementation.")
> Acked-by: Daniel Borkmann <dborkman@redhat.com>

Applied and queued up for -stable, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-11-29 21:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-29  8:53 [PATCH v2 net] af_packet: block BH in prb_shutdown_retire_blk_timer() Veaceslav Falico
2013-11-29  9:19 ` Daniel Borkmann
2013-11-29 21:11   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).