diff options
author | Lorenzo Bianconi <lorenzo.bianconi@redhat.com> | 2018-07-27 12:15:46 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-07-28 22:06:12 -0400 |
commit | 9fc12023d6f51551d6ca9ed7e02ecc19d79caf17 (patch) | |
tree | d8ebbe02f2b8d4e7b57291af9acd485d79c22fed | |
parent | ab123fe071c9aa9680ecd62eb080eb26cff4892c (diff) |
ipv4: remove BUG_ON() from fib_compute_spec_dst
Remove BUG_ON() from fib_compute_spec_dst routine and check
in_dev pointer during flowi4 data structure initialization.
fib_compute_spec_dst routine can be run concurrently with device removal
where ip_ptr net_device pointer is set to NULL. This can happen
if userspace enables pkt info on UDP rx socket and the device
is removed while traffic is flowing
Fixes: 35ebf65e851c ("ipv4: Create and use fib_compute_spec_dst() helper")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/fib_frontend.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index e46cdd310e5f..2998b0e47d4b 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
@@ -292,19 +292,19 @@ __be32 fib_compute_spec_dst(struct sk_buff *skb) | |||
292 | return ip_hdr(skb)->daddr; | 292 | return ip_hdr(skb)->daddr; |
293 | 293 | ||
294 | in_dev = __in_dev_get_rcu(dev); | 294 | in_dev = __in_dev_get_rcu(dev); |
295 | BUG_ON(!in_dev); | ||
296 | 295 | ||
297 | net = dev_net(dev); | 296 | net = dev_net(dev); |
298 | 297 | ||
299 | scope = RT_SCOPE_UNIVERSE; | 298 | scope = RT_SCOPE_UNIVERSE; |
300 | if (!ipv4_is_zeronet(ip_hdr(skb)->saddr)) { | 299 | if (!ipv4_is_zeronet(ip_hdr(skb)->saddr)) { |
300 | bool vmark = in_dev && IN_DEV_SRC_VMARK(in_dev); | ||
301 | struct flowi4 fl4 = { | 301 | struct flowi4 fl4 = { |
302 | .flowi4_iif = LOOPBACK_IFINDEX, | 302 | .flowi4_iif = LOOPBACK_IFINDEX, |
303 | .flowi4_oif = l3mdev_master_ifindex_rcu(dev), | 303 | .flowi4_oif = l3mdev_master_ifindex_rcu(dev), |
304 | .daddr = ip_hdr(skb)->saddr, | 304 | .daddr = ip_hdr(skb)->saddr, |
305 | .flowi4_tos = RT_TOS(ip_hdr(skb)->tos), | 305 | .flowi4_tos = RT_TOS(ip_hdr(skb)->tos), |
306 | .flowi4_scope = scope, | 306 | .flowi4_scope = scope, |
307 | .flowi4_mark = IN_DEV_SRC_VMARK(in_dev) ? skb->mark : 0, | 307 | .flowi4_mark = vmark ? skb->mark : 0, |
308 | }; | 308 | }; |
309 | if (!fib_lookup(net, &fl4, &res, 0)) | 309 | if (!fib_lookup(net, &fl4, &res, 0)) |
310 | return FIB_RES_PREFSRC(net, res); | 310 | return FIB_RES_PREFSRC(net, res); |