Skip to contentSkip to conversation

aoe: avoid using skb member after dev_queue_xmit

PATCH In review Ed Cashin 3 participants 4 messages Oct 24, 2012 – Oct 25, 2012

Subsystems (3)
lore
Share & tools
lore

Ed Cashin

author
#0 lore raw

PATCH 1/1 aoe: avoid using skb member after dev_queue_xmit

After calling dev_queue_xmit it is no longer safe to access the members of the skb.

---
 drivers/block/aoe/aoenet.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/block/aoe/aoenet.c +3 -1
index ae56828..2e47404 100644
@@ -55,12 +55,14 @@ static int
 tx(void) __must_hold(&txlock)
 {
 	struct sk_buff *skb;
+	struct net_device *ifp;
 
 	while ((skb = skb_dequeue(&skbtxq))) {
 		spin_unlock_irq(&txlock);
+		ifp = skb->dev;
 		if (dev_queue_xmit(skb) = NET_XMIT_DROP && net_ratelimit())
 			pr_warn("aoe: packet could not be sent on %s.  %s\n",
-				skb->dev ? skb->dev->name : "netif",
+				ifp ? ifp->name : "netif",
 				"consider increasing tx_queue_len");
 		spin_lock_irq(&txlock);
 	}
Signature · 1 line
1.7.1
#1 lore raw
Quoted 4 lines · On Wed, 24 Oct 2012 14:26:13 -0400 Ed Cashin <[email protected]> wrote:

After calling dev_queue_xmit it is no longer safe to access the members of the skb.

hm, that was clever. How did Dan detect this bug?

Quoted 8 lines
drivers/block/aoe/aoenet.c +1 -0
@@ -55,12 +55,14 @@ static int
 tx(void) __must_hold(&txlock)
 {
 	struct sk_buff *skb;
+	struct net_device *ifp;
 

drivers/block/aoe/aoenet.c static int · line 68

Quoted 10 lines
drivers/block/aoe/aoenet.c +2 -1
 	while ((skb = skb_dequeue(&skbtxq))) {
 		spin_unlock_irq(&txlock);
+		ifp = skb->dev;
 		if (dev_queue_xmit(skb) = NET_XMIT_DROP && net_ratelimit())
 			pr_warn("aoe: packet could not be sent on %s.  %s\n",
-				skb->dev ? skb->dev->name : "netif",
+				ifp ? ifp->name : "netif",
 				"consider increasing tx_queue_len");
 		spin_lock_irq(&txlock);
 	}

Queued as a fix against the not-yet-upstream aoe-print-warning-regarding-a-common-reason-for-dropped-transmits.patch, thanks.

#2 lore raw
Quoted 9 lines · Andrew Morton
Quoted 4 lines · On Wed, 24 Oct 2012 14:26:13 -0400 Ed Cashin <[email protected]> wrote:

After calling dev_queue_xmit it is no longer safe to access the members of the skb.

hm, that was clever. How did Dan detect this bug?

It was a Smatch thing, but it wasn't enabled by default. I think I will enable it. This is the second bug use after dev_queue_xmit() in two years.

regards,
dan carpenter

author
#3 lore raw
Quoted 7 lines · Dan Carpenter
Quoted 6 lines · Andrew Morton
Quoted 3 lines · On Wed, 24 Oct 2012 14:26:13 -0400 Ed Cashin <[email protected]> wrote:

After calling dev_queue_xmit it is no longer safe to access the members of the skb.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

hm, that was clever. How did Dan detect this bug?

It was a Smatch thing, but it wasn't enabled by default. I think I will enable it. This is the second bug use after dev_queue_xmit() in two years.

OK, no more procrastinating. I'm using smatch from today forward.

Signature · 2 lines
  Ed Cashin
  [email protected]