diff mbox

[v2,net] af_packet: block BH in prb_shutdown_retire_blk_timer()

Message ID 1385715203-14712-1-git-send-email-vfalico@redhat.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Veaceslav Falico Nov. 29, 2013, 8:53 a.m. UTC
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(-)

Comments

Daniel Borkmann Nov. 29, 2013, 9:19 a.m. UTC | #1
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!
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Nov. 29, 2013, 9:11 p.m. UTC | #2
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!
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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);
 }