netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Deadlock in af_packet/packet_rcv
@ 2004-11-25 20:55 Olaf Kirch
  2004-11-30  4:02 ` David S. Miller
  2004-11-30  9:32 ` Tommy Christensen
  0 siblings, 2 replies; 9+ messages in thread
From: Olaf Kirch @ 2004-11-25 20:55 UTC (permalink / raw)
  To: netdev


Before introduction of lock-less loopback, all of netdev_xmit_nit was
running with bottom halves disabled, and some code seems to rely on
this. One of them is af_packet's packet_rcv handler, which is called
from the receive path via netdev_xmit_nit.  It takes a spin lock,
and if an interrupt occurs and calls netdev_xmit during this time,
the CPU deadlocks.

The patch below disables BHs while in the TX path for loopback and
similar devices.

An alternative, less conservative fix would be to just use spin_lock_bh
in af_packet.c.

Signed-off-by: Olaf Kirch <okir@suse.de>


Index: linux-2.6.9/net/core/dev.c
===================================================================
--- linux-2.6.9.orig/net/core/dev.c
+++ linux-2.6.9/net/core/dev.c
@@ -1222,6 +1222,7 @@ int __skb_linearize(struct sk_buff *skb,
 }
 
 #define HARD_TX_LOCK(dev, cpu) {			\
+	local_disable_bh();				\
 	if ((dev->features & NETIF_F_LLTX) == 0) {	\
 		spin_lock(&dev->xmit_lock);		\
 		dev->xmit_lock_owner = cpu;		\
@@ -1233,6 +1234,7 @@ int __skb_linearize(struct sk_buff *skb,
 		dev->xmit_lock_owner = -1;		\
 		spin_unlock(&dev->xmit_lock);		\
 	}						\
+	local_enable_bh();				\
 }
 
 static inline void qdisc_run(struct net_device *dev)

-- 
Olaf Kirch     | Things that make Monday morning interesting, #2:
okir@suse.de   |        "We have 8,000 NFS mount points, why do we keep
---------------+ 	 running out of privileged ports?"

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

end of thread, other threads:[~2004-11-30 21:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-25 20:55 [PATCH] Deadlock in af_packet/packet_rcv Olaf Kirch
2004-11-30  4:02 ` David S. Miller
2004-11-30 10:48   ` Olaf Kirch
2004-11-30  9:32 ` Tommy Christensen
2004-11-30 11:01   ` Olaf Kirch
2004-11-30 11:31     ` Tommy Christensen
2004-11-30 11:45       ` Olaf Kirch
2004-11-30 11:56         ` Tommy Christensen
2004-11-30 21:07           ` David S. 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).