Skip to content

Commit eb33141

Browse files
LorenzoBianconiZhengShunQian
authored andcommitted
ipv4: remove BUG_ON() from fib_compute_spec_dst
[ Upstream commit 9fc1202 ] 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: 35ebf65 ("ipv4: Create and use fib_compute_spec_dst() helper") Signed-off-by: Lorenzo Bianconi <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 28e2c58 commit eb33141

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/ipv4/fib_frontend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,19 +289,19 @@ __be32 fib_compute_spec_dst(struct sk_buff *skb)
289289
return ip_hdr(skb)->daddr;
290290

291291
in_dev = __in_dev_get_rcu(dev);
292-
BUG_ON(!in_dev);
293292

294293
net = dev_net(dev);
295294

296295
scope = RT_SCOPE_UNIVERSE;
297296
if (!ipv4_is_zeronet(ip_hdr(skb)->saddr)) {
297+
bool vmark = in_dev && IN_DEV_SRC_VMARK(in_dev);
298298
struct flowi4 fl4 = {
299299
.flowi4_iif = LOOPBACK_IFINDEX,
300300
.flowi4_oif = l3mdev_master_ifindex_rcu(dev),
301301
.daddr = ip_hdr(skb)->saddr,
302302
.flowi4_tos = RT_TOS(ip_hdr(skb)->tos),
303303
.flowi4_scope = scope,
304-
.flowi4_mark = IN_DEV_SRC_VMARK(in_dev) ? skb->mark : 0,
304+
.flowi4_mark = vmark ? skb->mark : 0,
305305
};
306306
if (!fib_lookup(net, &fl4, &res, 0))
307307
return FIB_RES_PREFSRC(net, res);

0 commit comments

Comments
 (0)