]> git.baikalelectronics.ru Git - kernel.git/commit
tcp: ensure skb->dev is NULL before leaving TCP stack
authorEric Dumazet <edumazet@google.com>
Thu, 19 Mar 2020 19:49:55 +0000 (12:49 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Apr 2020 09:01:39 +0000 (11:01 +0200)
commit311a4105717711ea548311742142d6f407ff65dd
tree5435822106a0c09bb741d0eb739300674a605dd2
parentc2a35d34c931447ba556a55890ad811ccc8ed513
tcp: ensure skb->dev is NULL before leaving TCP stack

[ Upstream commit 9d1edb708dd0d900dcf6f5c57f4f83536392a205 ]

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 0a590088d50a
("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: 42899b27ca39 ("tcp: implement rb-tree based retransmit queue")
Fixes: 0a590088d50a ("netfilter: Support iif matches in POSTROUTING")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Martin Zaharinov <micron10@gmail.com>
Cc: Florian Westphal <fw@strlen.de>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ipv4/tcp_output.c