* [PATCH] RDMA/core: Fix use-after-free in ib_get_eth_speed()
@ 2026-08-21 7:05 Eric Dumazet
2026-08-21 8:19 ` Kalesh Anakkur Purayil
2026-08-21 13:26 ` Jason Gunthorpe
0 siblings, 2 replies; 4+ messages in thread
From: Eric Dumazet @ 2026-08-21 7:05 UTC (permalink / raw)
To: Jason Gunthorpe, Leon Romanovsky
Cc: linux-rdma, Jakub Kicinski, Paolo Abeni, netdev, eric.dumazet,
Eric Dumazet
In ib_get_eth_speed(), dev_put(netdev) is called before inspecting
rc and dereferencing netdev->name in pr_warn(). If dev_put() drops
the final reference to netdev, netdev->name accesses freed memory.
Move dev_put(netdev) after the warning block so netdev is kept
alive while its name is read.
Fixes: d41861942fc5 ("IB/core: Add generic function to extract IB speed from netdev")
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
drivers/infiniband/core/verbs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 86811d31092ce03c8156b444fece47b824231219..57f109c8085dadf90bcc498a9ee64eea3c5f5271 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -2052,8 +2052,6 @@ int ib_get_eth_speed(struct ib_device *dev, u32 port_num, u16 *speed, u8 *width)
rc = __ethtool_get_link_ksettings(netdev, &lksettings);
rtnl_unlock();
- dev_put(netdev);
-
if (!rc && lksettings.base.speed != (u32)SPEED_UNKNOWN) {
netdev_speed = lksettings.base.speed;
} else {
@@ -2063,6 +2061,8 @@ int ib_get_eth_speed(struct ib_device *dev, u32 port_num, u16 *speed, u8 *width)
netdev->name, netdev_speed);
}
+ dev_put(netdev);
+
ib_get_width_and_speed(netdev_speed, lksettings.lanes,
speed, width);
--
2.55.0.766.g2966f0265a-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] RDMA/core: Fix use-after-free in ib_get_eth_speed()
2026-08-21 7:05 [PATCH] RDMA/core: Fix use-after-free in ib_get_eth_speed() Eric Dumazet
@ 2026-08-21 8:19 ` Kalesh Anakkur Purayil
2026-08-21 13:26 ` Jason Gunthorpe
1 sibling, 0 replies; 4+ messages in thread
From: Kalesh Anakkur Purayil @ 2026-08-21 8:19 UTC (permalink / raw)
To: Eric Dumazet
Cc: Jason Gunthorpe, Leon Romanovsky, linux-rdma, Jakub Kicinski,
Paolo Abeni, netdev, eric.dumazet
[-- Attachment #1: Type: text/plain, Size: 630 bytes --]
On Fri, Aug 21, 2026 at 12:37 PM Eric Dumazet <edumazet@google.com> wrote:
>
> In ib_get_eth_speed(), dev_put(netdev) is called before inspecting
> rc and dereferencing netdev->name in pr_warn(). If dev_put() drops
> the final reference to netdev, netdev->name accesses freed memory.
>
> Move dev_put(netdev) after the warning block so netdev is kept
> alive while its name is read.
>
> Fixes: d41861942fc5 ("IB/core: Add generic function to extract IB speed from netdev")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
--
Regards,
Kalesh AP
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5509 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] RDMA/core: Fix use-after-free in ib_get_eth_speed()
2026-08-21 7:05 [PATCH] RDMA/core: Fix use-after-free in ib_get_eth_speed() Eric Dumazet
2026-08-21 8:19 ` Kalesh Anakkur Purayil
@ 2026-08-21 13:26 ` Jason Gunthorpe
2026-08-21 13:33 ` Eric Dumazet
1 sibling, 1 reply; 4+ messages in thread
From: Jason Gunthorpe @ 2026-08-21 13:26 UTC (permalink / raw)
To: Eric Dumazet
Cc: Leon Romanovsky, linux-rdma, Jakub Kicinski, Paolo Abeni, netdev,
eric.dumazet
On Fri, Aug 21, 2026 at 07:05:12AM +0000, Eric Dumazet wrote:
> In ib_get_eth_speed(), dev_put(netdev) is called before inspecting
> rc and dereferencing netdev->name in pr_warn(). If dev_put() drops
> the final reference to netdev, netdev->name accesses freed memory.
>
> Move dev_put(netdev) after the warning block so netdev is kept
> alive while its name is read.
>
> Fixes: d41861942fc5 ("IB/core: Add generic function to extract IB speed from netdev")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
> drivers/infiniband/core/verbs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
I was intending to take this patch next cycle:
https://patchwork.kernel.org/project/linux-rdma/patch/20260812081708.32468-1-krystianmkaniewski@gmail.com/
Which has the same change embedded?
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] RDMA/core: Fix use-after-free in ib_get_eth_speed()
2026-08-21 13:26 ` Jason Gunthorpe
@ 2026-08-21 13:33 ` Eric Dumazet
0 siblings, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2026-08-21 13:33 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Leon Romanovsky, linux-rdma, Jakub Kicinski, Paolo Abeni, netdev,
eric.dumazet
On Fri, Aug 21, 2026 at 3:26 PM Jason Gunthorpe <jgg@ziepe.ca> wrote:
>
> On Fri, Aug 21, 2026 at 07:05:12AM +0000, Eric Dumazet wrote:
> > In ib_get_eth_speed(), dev_put(netdev) is called before inspecting
> > rc and dereferencing netdev->name in pr_warn(). If dev_put() drops
> > the final reference to netdev, netdev->name accesses freed memory.
> >
> > Move dev_put(netdev) after the warning block so netdev is kept
> > alive while its name is read.
> >
> > Fixes: d41861942fc5 ("IB/core: Add generic function to extract IB speed from netdev")
> > Signed-off-by: Eric Dumazet <edumazet@google.com>
> > ---
> > drivers/infiniband/core/verbs.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
>
> I was intending to take this patch next cycle:
>
> https://patchwork.kernel.org/project/linux-rdma/patch/20260812081708.32468-1-krystianmkaniewski@gmail.com/
Ah... I missed that.
>
> Which has the same change embedded?
SGTM thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-21 13:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-21 7:05 [PATCH] RDMA/core: Fix use-after-free in ib_get_eth_speed() Eric Dumazet
2026-08-21 8:19 ` Kalesh Anakkur Purayil
2026-08-21 13:26 ` Jason Gunthorpe
2026-08-21 13:33 ` Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox