Skip to content

Commit

Permalink
ipv4/route: fail early when inet dev is missing
Browse files Browse the repository at this point in the history
If a non local multicast packet reaches ip_route_input_rcu() while
the ingress device IPv4 private data (in_dev) is NULL, we end up
doing a NULL pointer dereference in IN_DEV_MFORWARD().

Since the later call to ip_route_input_mc() is going to fail if
!in_dev, we can fail early in such scenario and avoid the dangerous
code path.

v1 -> v2:
 - clarified the commit message, no code changes

Reported-by: Tianhao Zhao <[email protected]>
Fixes: e58e415 ("net: Enable support for VRF with ipv4 multicast")
Signed-off-by: Paolo Abeni <[email protected]>
Reviewed-by: David Ahern <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Paolo Abeni authored and davem330 committed Mar 6, 2019
1 parent f4772de commit 22c7476
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions net/ipv4/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -2149,12 +2149,13 @@ int ip_route_input_rcu(struct sk_buff *skb, __be32 daddr, __be32 saddr,
int our = 0;
int err = -EINVAL;

if (in_dev)
our = ip_check_mc_rcu(in_dev, daddr, saddr,
ip_hdr(skb)->protocol);
if (!in_dev)
return err;
our = ip_check_mc_rcu(in_dev, daddr, saddr,
ip_hdr(skb)->protocol);

/* check l3 master if no match yet */
if ((!in_dev || !our) && netif_is_l3_slave(dev)) {
if (!our && netif_is_l3_slave(dev)) {
struct in_device *l3_in_dev;

l3_in_dev = __in_dev_get_rcu(skb->dev);
Expand Down

0 comments on commit 22c7476

Please sign in to comment.