Commit bb7f8f19 authored by Parav Pandit's avatar Parav Pandit Committed by Doug Ledford

IB/core: Fix possible crash to access NULL netdev

resolved_dev returned might be NULL as ifindex is transient number.
Ignoring NULL check of resolved_dev might crash the kernel.
Therefore perform NULL check before accessing resolved_dev.

Additionally rdma_resolve_ip_route() invokes addr_resolve() which
performs check and address translation for loopback ifindex.
Therefore, checking it again in rdma_resolve_ip_route() is not helpful.
Therefore, the code is simplified to avoid IFF_LOOPBACK check.

Fixes: 20029832 ("IB/core: Validate route when we init ah")
Reviewed-by: default avatarDaniel Jurgens <danielj@mellanox.com>
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 942c9b6c
...@@ -1291,10 +1291,9 @@ int ib_init_ah_attr_from_path(struct ib_device *device, u8 port_num, ...@@ -1291,10 +1291,9 @@ int ib_init_ah_attr_from_path(struct ib_device *device, u8 port_num,
resolved_dev = dev_get_by_index(dev_addr.net, resolved_dev = dev_get_by_index(dev_addr.net,
dev_addr.bound_dev_if); dev_addr.bound_dev_if);
if (resolved_dev->flags & IFF_LOOPBACK) { if (!resolved_dev) {
dev_put(resolved_dev); dev_put(idev);
resolved_dev = idev; return -ENODEV;
dev_hold(resolved_dev);
} }
ndev = ib_get_ndev_from_path(rec); ndev = ib_get_ndev_from_path(rec);
rcu_read_lock(); rcu_read_lock();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment