diff options
author | Eric Dumazet <edumazet@google.com> | 2017-06-19 11:49:22 +0200 |
---|---|---|
committer | Mukendi Kabobo, NicanordX <nicanordx.mukendi.kabobo@intel.com> | 2017-07-06 06:09:16 -0700 |
commit | e74d61385ed0c7adfc910f380de8114134d2253d (patch) | |
tree | ca9c8cb5260654442dc58de8b0a0af7151c8197b | |
parent | c2fab6c8899bea8e3ac5a4bd8b816ece9e5b68c2 (diff) | |
download | x86-e74d61385ed0c7adfc910f380de8114134d2253d.tar.gz |
ipv4: keep skb->dst around in presence of IP options
Andrey Konovalov got crashes in __ip_options_echo() when a NULL skb->dst
is accessed.
ipv4_pktinfo_prepare() should not drop the dst if (evil) IP options
are present.
We could refine the test to the presence of ts_needtime or srr,
but IP options are not often used, so let's be conservative.
Thanks to syzkaller team for finding this bug.
Change-Id: I76d78d2ec831ff447334e8c71efb72736305c8f9
Fixes: d826eb14ecef ("ipv4: PKTINFO doesnt need dst reference")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Andrey Konovalov <andreyknvl@google.com>
Tracked-On: https://jira01.devtools.intel.com/browse/AW-5928
Signed-off-by: Loic Akue <loicx.akue@intel.com>
Reviewed-on: https://android.intel.com/590707
Reviewed-by: Dubray, SimonX <simonx.dubray@intel.com>
Reviewed-by: Tasayco Loarte, VictorX <victorx.tasayco.loarte@intel.com>
-rw-r--r-- | net/ipv4/ip_sockglue.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index a50124260f5a..fde3f787fc3a 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -1190,7 +1190,14 @@ void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb) pktinfo->ipi_ifindex = 0; pktinfo->ipi_spec_dst.s_addr = 0; } - skb_dst_drop(skb); + /* We need to keep the dst for __ip_options_echo() + * We could restrict the test to opt.ts_needtime || opt.srr, + * but the following is good enough as IP options are not often used. + */ + if (unlikely(IPCB(skb)->opt.optlen)) + skb_dst_force(skb); + else + skb_dst_drop(skb); } int ip_setsockopt(struct sock *sk, int level, |