Thread (27 messages) 27 messages, 6 authors, 2024-01-31

Re: [PATCH v2 ipsec-next 1/2] xfrm: introduce forwarding of ICMP Error messages

From: Steffen Klassert <steffen.klassert@secunet.com>
Date: 2023-11-17 09:13:19

On Fri, Oct 27, 2023 at 10:16:29AM +0200, Antony Antony wrote:
+
+static struct sk_buff *xfrm_icmp_flow_decode(struct sk_buff *skb,
+					     unsigned short family,
+					     struct flowi *fl,
+					     struct flowi *fl1)
+{
+	struct net *net = dev_net(skb->dev);
+	struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC);
+	int hl = family == AF_INET ? (sizeof(struct iphdr) +  sizeof(struct icmphdr)) :
+		 (sizeof(struct ipv6hdr) + sizeof(struct icmp6hdr));
+	skb_reset_network_header(newskb);
This is not needed there.
+
+	if (!pskb_pull(newskb, hl))
+		return NULL;
This leaks newskb.
+	skb_reset_network_header(newskb);
+
+	if (xfrm_decode_session_reverse(net, newskb, fl1, family) < 0) {
+		kfree_skb(newskb);
The newskb is not dropped because of an error, maybe better use
consume_skb().
+		XFRM_INC_STATS(net, LINUX_MIB_XFRMINHDRERROR);
This might bump a second stat counter for this packet. Also
this is not really an error, because you just can't parse
the payload of the icmp packet.
+		return NULL;
+	}
+
+	fl1->flowi_oif = fl->flowi_oif;
+	fl1->flowi_mark = fl->flowi_mark;
+	fl1->flowi_tos = fl->flowi_tos;
+	nf_nat_decode_session(newskb, fl1, family);
+
+	return newskb;
Why do you return newskb here? It is not used in all
of the calling functions.

The rest looks good, thanks!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help