Skip to contentSkip to conversation

af_packet: block BH in prb_shutdown_retire_blk_timer()

PATCH In review Veaceslav Falico 3 participants 3 messages Nov 29, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 af_packet: block BH in prb_shutdown_retire_blk_timer()

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" <[email protected]>
CC Daniel Borkmann <[email protected]>
CC Willem de Bruijn <[email protected]>
CC Phil Sutter <[email protected]>
CC Eric Dumazet <[email protected]>

---

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(-)
net/packet/af_packet.c +2 -2
index ac27c86..ba2548b 100644
@@ -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);
 }
Signature · 1 line
1.8.4
Acked-by on v2 1/1
#1 lore raw
Quoted 6 lines · Veaceslav Falico

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.

Quoted 8 lines
CC "David S. Miller" <[email protected]>
CC Daniel Borkmann <[email protected]>
CC Willem de Bruijn <[email protected]>
CC Phil Sutter <[email protected]>
CC Eric Dumazet <[email protected]>
Fixes f6fb8f100b80 ("af-packet: TPACKET_V3 flexible buffer implementation.")

Thanks everyone!

maintainer
#2 lore raw

From: Daniel Borkmann <[email protected]>
Date: Fri, 29 Nov 2013 10:19:29 +0100

Quoted 18 lines · Veaceslav Falico
Quoted 8 lines

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.

Quoted 8 lines
CC "David S. Miller" <[email protected]>
CC Daniel Borkmann <[email protected]>
CC Willem de Bruijn <[email protected]>
CC Phil Sutter <[email protected]>
CC Eric Dumazet <[email protected]>
Quoted 3 lines
Fixes f6fb8f100b80 ("af-packet: TPACKET_V3 flexible buffer

implementation.")

Applied and queued up for -stable, thanks!