netfilter: nf_reject_ipv6: fix locally generated packet to local address
Subsystems (2)
Pablo Neira Ayuso
maintainerPATCH v3 1/1 netfilter: nf_reject_ipv6: fix locally generated packet to local address
Set on skb dst before checking if this packet is in the inet/ingress path. The inet/ingress hook runs before prerouting, no skb dst should be found in most cases.
This fixes reject for locally generated packet that are sent to a local address on ethX arrives through lo, really perform the same handling as ip6_rcv_core().
Reported by sashiko.
Fixes 73a73d442f99 ("netfilter: nf_reject: initialize IPCB at inet ingress")
Signed-off-by Pablo Neira Ayuso <[email protected]>
---
v3: skb dst should always be set on after nf_reject6_fill_skb_dst,
remove dead branch in if (hooknum == NF_INET_INGRESS).
net/ipv6/netfilter/nf_reject_ipv6.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
net/ipv6/netfilter/nf_reject_ipv6.c +10 -4
@@ -444,14 +444,20 @@ void nf_send_unreach6(struct net *net, struct sk_buff *skb_in,if (hooknum ==NF_INET_LOCAL_OUT && skb_in->dev ==NULL ) skb_in->dev = net->loopback_dev; +if (!skb_valid_dst (skb_in) &&nf_reject6_fill_skb_dst (skb_in) <0 ) +return ; +if (hooknum ==NF_INET_INGRESS ) { +const struct inet6_dev *idev; +memset (IP6CB (skb_in),0 ,sizeof (*IP6CB (skb_in))); -IP6CB (skb_in)->iif = skb_in->skb_iif; + idev =ip6_dst_idev (skb_dst (skb_in)); +if (idev) +IP6CB (skb_in)->iif = idev->dev->ifindex; +else +IP6CB (skb_in)->iif = skb_in->dev->ifindex; } -if (!skb_valid_dst (skb_in) &&nf_reject6_fill_skb_dst (skb_in) <0 ) -return ; -icmpv6_send (skb_in,ICMPV6_DEST_UNREACH , code,0 ); }EXPORT_SYMBOL_GPL (nf_send_unreach6);
Signature · 1 line
2.47.3