From: Denis Kirjanov <kirjanov@gmail.com>
To: netdev@vger.kernel.org
Cc: edumazet@google.com, jgg@ziepe.ca, leon@kernel.org,
Denis Kirjanov <dkirjanov@suse.de>,
syzbot+5fe14f2ff4ccbace9a26@syzkaller.appspotmail.com
Subject: [PATCH v2 net] RDMA/core: fix UAF in ib_get_eth_speed
Date: Thu, 28 Mar 2024 07:32:33 -0400 [thread overview]
Message-ID: <20240328113233.21388-1-dkirjanov@suse.de> (raw)
A call to ib_device_get_netdev from ib_get_eth_speed
may lead to a race condition while accessing a netdevice
instance since we don't hold the rtnl lock while checking
the registration state:
if (res && res->reg_state != NETREG_REGISTERED) {
v2: unlock rtnl on error patch
Reported-by: syzbot+5fe14f2ff4ccbace9a26@syzkaller.appspotmail.com
Fixes: d41861942fc55 ("IB/core: Add generic function to extract IB speed from netdev")
Signed-off-by: Denis Kirjanov <dkirjanov@suse.de>
---
drivers/infiniband/core/verbs.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 94a7f3b0c71c..9c09d8c328b4 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -1976,11 +1976,13 @@ int ib_get_eth_speed(struct ib_device *dev, u32 port_num, u16 *speed, u8 *width)
if (rdma_port_get_link_layer(dev, port_num) != IB_LINK_LAYER_ETHERNET)
return -EINVAL;
+ rtnl_lock();
netdev = ib_device_get_netdev(dev, port_num);
- if (!netdev)
+ if (!netdev) {
+ rtnl_unlock()
return -ENODEV;
+ }
- rtnl_lock();
rc = __ethtool_get_link_ksettings(netdev, &lksettings);
rtnl_unlock();
--
2.30.2
next reply other threads:[~2024-03-28 11:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-28 11:32 Denis Kirjanov [this message]
2024-03-28 11:51 ` [PATCH v2 net] RDMA/core: fix UAF in ib_get_eth_speed Eric Dumazet
2024-03-28 12:18 ` Denis Kirjanov
2024-03-28 11:58 ` Ratheesh Kannoth
2024-03-28 12:01 ` Naveen Mamindlapalli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240328113233.21388-1-dkirjanov@suse.de \
--to=kirjanov@gmail.com \
--cc=dkirjanov@suse.de \
--cc=edumazet@google.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=syzbot+5fe14f2ff4ccbace9a26@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.