Skip to content

Commit b738a18

Browse files
edumazetdavem330
authored andcommitted
tcp: ensure skb->dev is NULL before leaving TCP stack
skb->rbnode is sharing three skb fields : next, prev, dev When a packet is sent, TCP keeps the original skb (master) in a rtx queue, which was converted to rbtree a while back. __tcp_transmit_skb() is responsible to clone the master skb, and add the TCP header to the clone before sending it to network layer. skb_clone() already clears skb->next and skb->prev, but copies the master oskb->dev into the clone. We need to clear skb->dev, otherwise lower layers could interpret the value as a pointer to a netdev. This old bug surfaced recently when commit 28f8bfd ("netfilter: Support iif matches in POSTROUTING") was merged. Before this netfilter commit, skb->dev value was ignored and changed before reaching dev_queue_xmit() Fixes: 75c119a ("tcp: implement rb-tree based retransmit queue") Fixes: 28f8bfd ("netfilter: Support iif matches in POSTROUTING") Signed-off-by: Eric Dumazet <[email protected]> Reported-by: Martin Zaharinov <[email protected]> Cc: Florian Westphal <[email protected]> Cc: Pablo Neira Ayuso <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f1f20a8 commit b738a18

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net/ipv4/tcp_output.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,10 @@ static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb,
11091109

11101110
if (unlikely(!skb))
11111111
return -ENOBUFS;
1112+
/* retransmit skbs might have a non zero value in skb->dev
1113+
* because skb->dev is aliased with skb->rbnode.rb_left
1114+
*/
1115+
skb->dev = NULL;
11121116
}
11131117

11141118
inet = inet_sk(sk);

0 commit comments

Comments
 (0)