Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8728c544 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

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 a4ee3ce3
(net: Use sk_tx_queue_mapping for connected sockets)

Reported-by: default avatarDenys Fedorysychenko <nuclearcat@nuclearcat.com>
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4eaa0e3c
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -1989,10 +1989,14 @@ static struct netdev_queue *dev_pick_tx(struct net_device *dev,
			if (dev->real_num_tx_queues > 1)
				queue_index = skb_tx_hash(dev, skb);

			if (sk && sk->sk_dst_cache)
			if (sk) {
				struct dst_entry *dst = rcu_dereference(sk->sk_dst_cache);

				if (dst && skb_dst(skb) == dst)
					sk_tx_queue_set(sk, queue_index);
			}
		}
	}

	skb_set_queue_mapping(skb, queue_index);
	return netdev_get_tx_queue(dev, queue_index);