]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ipv4: recompile ip options in ipv4_link_failure
authorStephen Suryaputra <ssuryaextr@gmail.com>
Fri, 12 Apr 2019 20:19:27 +0000 (16:19 -0400)
committerDavid S. Miller <davem@davemloft.net>
Sat, 13 Apr 2019 00:23:46 +0000 (17:23 -0700)
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.

Signed-off-by: Stephen Suryaputra <ssuryaextr@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/route.c

index a5da63e5faa2d8118d3044a5a79b5e51bf61cafc..0206789bc2b73b70f3a543385052efbe4cd6c3b6 100644 (file)
@@ -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)