netfilter: nf_dup_netdev: do not push mac header a second time
authorFlorian Westphal <fw@strlen.de>
Mon, 20 Jun 2022 14:17:30 +0000 (16:17 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 21 Jun 2022 08:50:40 +0000 (10:50 +0200)
commit574a5b85dc3b9ab672ff3fba0ee020f927960648
tree97357fd42503d008036961aa4a5b11bfed832920
parent5d79d8af8dec58bf709b3124d09d9572edd9c617
netfilter: nf_dup_netdev: do not push mac header a second time

Eric reports skb_under_panic when using dup/fwd via bond+egress hook.
Before pushing mac header, we should make sure that we're called from
ingress to put back what was pulled earlier.

In egress case, the MAC header is already there; we should leave skb
alone.

While at it be more careful here: skb might have been altered and
headroom reduced, so add a skb_cow() before so that headroom is
increased if necessary.

nf_do_netdev_egress() assumes skb ownership (it normally ends with
a call to dev_queue_xmit), so we must free the packet on error.

Fixes: f87b9464d152 ("netfilter: nft_fwd_netdev: Support egress hook")
Reported-by: Eric Garver <eric@garver.life>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_dup_netdev.c