[SRU][J][PATCH 1/1] net/smc: fix neighbour and rtable leak in smc_ib_find_route()
Massimiliano Pellizzer
massimiliano.pellizzer at canonical.com
Tue Apr 29 13:11:46 UTC 2025
From: Wen Gu <guwen at linux.alibaba.com>
BugLink: https://bugs.launchpad.net/bugs/2109601
https://ubuntu.com/security/CVE-2024-36945
In smc_ib_find_route(), the neighbour found by neigh_lookup() and rtable
resolved by ip_route_output_flow() are not released or put before return.
It may cause the refcount leak, so fix it.
Link: https://lore.kernel.org/r/20240506015439.108739-1-guwen@linux.alibaba.com
Fixes: e5c4744cfb59 ("net/smc: add SMC-Rv2 connection establishment")
Signed-off-by: Wen Gu <guwen at linux.alibaba.com>
Link: https://lore.kernel.org/r/20240507125331.2808-1-guwen@linux.alibaba.com
Signed-off-by: Paolo Abeni <pabeni at redhat.com>
(cherry picked from commit 2ddc0dd7fec86ee53b8928a5cca5fbddd4fc7c06)
CVE-2024-36945
Signed-off-by: Massimiliano Pellizzer <massimiliano.pellizzer at canonical.com>
---
net/smc/smc_ib.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/net/smc/smc_ib.c b/net/smc/smc_ib.c
index fe5d5399c4e8..6469a027ea03 100644
--- a/net/smc/smc_ib.c
+++ b/net/smc/smc_ib.c
@@ -207,13 +207,18 @@ int smc_ib_find_route(__be32 saddr, __be32 daddr,
if (IS_ERR(rt))
goto out;
if (rt->rt_uses_gateway && rt->rt_gw_family != AF_INET)
- goto out;
- neigh = rt->dst.ops->neigh_lookup(&rt->dst, NULL, &fl4.daddr);
- if (neigh) {
- memcpy(nexthop_mac, neigh->ha, ETH_ALEN);
- *uses_gateway = rt->rt_uses_gateway;
- return 0;
- }
+ goto out_rt;
+ neigh = dst_neigh_lookup(&rt->dst, &fl4.daddr);
+ if (!neigh)
+ goto out_rt;
+ memcpy(nexthop_mac, neigh->ha, ETH_ALEN);
+ *uses_gateway = rt->rt_uses_gateway;
+ neigh_release(neigh);
+ ip_rt_put(rt);
+ return 0;
+
+out_rt:
+ ip_rt_put(rt);
out:
return -ENOENT;
}
--
2.43.0
More information about the kernel-team
mailing list