Skip to contentSkip to conversation

netfilter: nf_reject_ipv6: fix locally generated packet to local address

PATCH Superseded Pablo Neira Ayuso 1 participant 1 message Oct 21

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 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 ingress/inet path. 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")
---
 net/ipv6/netfilter/nf_reject_ipv6.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
net/ipv6/netfilter/nf_reject_ipv6.c +6 -4
index 5e08d8529cc8..91e16120b654 100644
@@ -444,14 +444,16 @@ 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) {
 		memset(IP6CB(skb_in), 0, sizeof(*IP6CB(skb_in)));
-		IP6CB(skb_in)->iif = skb_in->skb_iif;
+		IP6CB(skb_in)->iif = skb_valid_dst(skb_in) ?
+					ip6_dst_idev(skb_dst(skb_in))->dev->ifindex :
+					skb_in->skb_iif;
 	}
 
-	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