Skip to contentSkip to conversation

: Fix dev->qdisc race for NETDEV_TX_LOCKED case

NET Applied Thomas Graf 3 participants 4 messages May 10, 2007

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

When transmit fails with NETDEV_TX_LOCKED the skb is requeued to dev->qdisc again. The dev->qdisc pointer is protected by the queue lock which needs to be dropped when attempting to transmit and acquired again before requeing. The problem is that qdisc_restart() fetches the dev->qdisc pointer once and stores it in the `q' variable which is invalidated when dropping the queue_lock, therefore the variable needs to be refreshed before requeueing.

net/sched/sch_generic.c +1 -0
Index: net-2.6/net/sched/sch_generic.c
===================================================================
@@ -139,6 +139,7 @@ static inline int qdisc_restart(struct n
 				}
 				if (ret == NETDEV_TX_LOCKED && nolock) {
 					spin_lock(&dev->queue_lock);
+					q = dev->qdisc;
 					goto collision;
 				}
 			}
#1 lore raw
Quoted 10 lines · Thomas Graf

When transmit fails with NETDEV_TX_LOCKED the skb is requeued to dev->qdisc again. The dev->qdisc pointer is protected by the queue lock which needs to be dropped when attempting to transmit and acquired again before requeing. The problem is that qdisc_restart() fetches the dev->qdisc pointer once and stores it in the `q' variable which is invalidated when dropping the queue_lock, therefore the variable needs to be refreshed before requeueing.

I agree, good catch Thomas.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
maintainer Applied
#2 lore raw

From: Herbert Xu <[email protected]>
Date: Thu, 10 May 2007 21:55:17 +1000

Quoted 10 lines
Quoted 9 lines · Thomas Graf

When transmit fails with NETDEV_TX_LOCKED the skb is requeued to dev->qdisc again. The dev->qdisc pointer is protected by the queue lock which needs to be dropped when attempting to transmit and acquired again before requeing. The problem is that qdisc_restart() fetches the dev->qdisc pointer once and stores it in the `q' variable which is invalidated when dropping the queue_lock, therefore the variable needs to be refreshed before requeueing.

Quoted 3 lines
Quoted 1 line

I agree, good catch Thomas.

Applied to my tree and I'll push it off to Linus tomorrow unless someone finds a problem with it by then.

Thanks.

#3 lore raw
Quoted 3 lines · David Miller

Applied to my tree and I'll push it off to Linus tomorrow unless someone finds a problem with it by then.

BTW, guess how this bug was introduced? By the lockless patch, surprise surprise :)

The sooner we are rid of it the better.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt