Skip to content

Commit 8728c54

Browse files
Eric Dumazetdavem330
authored andcommitted
net: dev_pick_tx() fix
When dev_pick_tx() caches tx queue_index on a socket, we must check socket dst_entry matches skb one, or risk a crash later, as reported by Denys Fedorysychenko, if old packets are in flight during a route change, involving devices with different number of queues. Bug introduced by commit a4ee3ce (net: Use sk_tx_queue_mapping for connected sockets) Reported-by: Denys Fedorysychenko <nuclearcat@nuclearcat.com> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4eaa0e3 commit 8728c54

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/core/dev.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,8 +1989,12 @@ static struct netdev_queue *dev_pick_tx(struct net_device *dev,
19891989
if (dev->real_num_tx_queues > 1)
19901990
queue_index = skb_tx_hash(dev, skb);
19911991

1992-
if (sk && sk->sk_dst_cache)
1993-
sk_tx_queue_set(sk, queue_index);
1992+
if (sk) {
1993+
struct dst_entry *dst = rcu_dereference(sk->sk_dst_cache);
1994+
1995+
if (dst && skb_dst(skb) == dst)
1996+
sk_tx_queue_set(sk, queue_index);
1997+
}
19941998
}
19951999
}
19962000

0 commit comments

Comments
 (0)