提交 7760937d 编写于 作者: P Paolo Abeni 提交者: Greg Kroah-Hartman

ipv4/route: fail early when inet dev is missing

[ Upstream commit 22c74764aa2943ecdf9f07c900d8a9c8ba6c9265 ]

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: NTianhao Zhao <tizhao@redhat.com>
Fixes: e58e4159 ("net: Enable support for VRF with ipv4 multicast")
Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
Reviewed-by: NDavid Ahern <dsahern@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 df737fd0
...@@ -2155,12 +2155,13 @@ int ip_route_input_rcu(struct sk_buff *skb, __be32 daddr, __be32 saddr, ...@@ -2155,12 +2155,13 @@ int ip_route_input_rcu(struct sk_buff *skb, __be32 daddr, __be32 saddr,
int our = 0; int our = 0;
int err = -EINVAL; int err = -EINVAL;
if (in_dev) if (!in_dev)
our = ip_check_mc_rcu(in_dev, daddr, saddr, return err;
ip_hdr(skb)->protocol); our = ip_check_mc_rcu(in_dev, daddr, saddr,
ip_hdr(skb)->protocol);
/* check l3 master if no match yet */ /* 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; struct in_device *l3_in_dev;
l3_in_dev = __in_dev_get_rcu(skb->dev); l3_in_dev = __in_dev_get_rcu(skb->dev);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册