All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] ipv4: recompile ip options in ipv4_link_failure
@ 2019-04-12 20:19 Stephen Suryaputra
  2019-04-13  0:24 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Suryaputra @ 2019-04-12 20:19 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Suryaputra

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>
---
 net/ipv4/route.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index a5da63e5faa2..0206789bc2b7 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -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)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] ipv4: recompile ip options in ipv4_link_failure
  2019-04-12 20:19 [PATCH net] ipv4: recompile ip options in ipv4_link_failure Stephen Suryaputra
@ 2019-04-13  0:24 ` David Miller
  2019-04-13 23:44   ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2019-04-13  0:24 UTC (permalink / raw)
  To: ssuryaextr; +Cc: netdev

From: Stephen Suryaputra <ssuryaextr@gmail.com>
Date: Fri, 12 Apr 2019 16:19:27 -0400

> 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>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] ipv4: recompile ip options in ipv4_link_failure
  2019-04-13  0:24 ` David Miller
@ 2019-04-13 23:44   ` Eric Dumazet
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2019-04-13 23:44 UTC (permalink / raw)
  To: David Miller, ssuryaextr; +Cc: netdev



On 04/12/2019 05:24 PM, David Miller wrote:
> From: Stephen Suryaputra <ssuryaextr@gmail.com>
> Date: Fri, 12 Apr 2019 16:19:27 -0400
> 
>> 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>
> 
> Applied.
> 

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

I will send a fix.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-13 23:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-12 20:19 [PATCH net] ipv4: recompile ip options in ipv4_link_failure Stephen Suryaputra
2019-04-13  0:24 ` David Miller
2019-04-13 23:44   ` Eric Dumazet

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.