Skip to content

Commit

Permalink
ipv4: recompile ip options in ipv4_link_failure
Browse files Browse the repository at this point in the history
[ Upstream commit ed0de45 ]

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

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

Signed-off-by: Stephen Suryaputra <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
ssuryaextr authored and gregkh committed Apr 27, 2019
1 parent b82df42 commit 8a430e5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion net/ipv4/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -1188,8 +1188,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)
Expand Down

0 comments on commit 8a430e5

Please sign in to comment.