Skip to contentSkip to conversation

ipv4: recompile ip options in ipv4_link_failure

PATCH Applied Stephen Suryaputra 3 participants 3 messages Apr 12, 2019 – Apr 13, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv4: recompile ip options in ipv4_link_failure

Recompile IP options since IPCB may not be valid anymore when ipv4_link_failure is called from arp_error_report.

Refer to the commit 3da1ed7ac398 ("net: avoid use IPCB in cipso_v4_error") and the commit before that (9ef6b42ad6fd) for a similar issue.

---
 net/ipv4/route.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
net/ipv4/route.c +9 -1
index a5da63e5faa2..0206789bc2b7 100644
@@ -1186,8 +1186,16 @@ static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie)
 static void ipv4_link_failure(struct sk_buff *skb)
 {
 	struct rtable *rt;
+	struct ip_options opt;
 
-	icmp_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0);
+	/* Recompile ip options since IPCB may not be valid anymore.
+	 */
+	memset(&opt, 0, sizeof(opt));
+	opt.optlen = ip_hdr(skb)->ihl*4 - sizeof(struct iphdr);
+	if (__ip_options_compile(dev_net(skb->dev), &opt, skb, NULL))
+		return;
+
+	__icmp_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_UNREACH, 0, &opt);
 
 	rt = skb_rtable(skb);
 	if (rt)
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw

From: Stephen Suryaputra <[email protected]>
Date: Fri, 12 Apr 2019 16:19:27 -0400

Quoted 7 lines

Recompile IP options since IPCB may not be valid anymore when ipv4_link_failure is called from arp_error_report.

Refer to the commit 3da1ed7ac398 ("net: avoid use IPCB in cipso_v4_error") and the commit before that (9ef6b42ad6fd) for a similar issue.

Applied.

#2 lore raw
Quoted 6 lines · David Miller

From: Stephen Suryaputra <[email protected]>
Date: Fri, 12 Apr 2019 16:19:27 -0400

Quoted 3 lines

Recompile IP options since IPCB may not be valid anymore when ipv4_link_failure is called from arp_error_report.

Quoted 7 lines
Quoted 4 lines

Refer to the commit 3da1ed7ac398 ("net: avoid use IPCB in cipso_v4_error") and the commit before that (9ef6b42ad6fd) for a similar issue.

Applied.

I believe __ip_options_compile() needs to be called from rcu_read_lock()

I will send a fix.