From: sashiko-bot@kernel.org
To: "Yanze Zhang" <zhang.yanze@zte.com.cn>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH rdma v7 7/7] RDMA/zrdma: Implement device and port query operations
Date: Tue, 27 Oct 2026 02:33:49 +0000 [thread overview]
Message-ID: <sashiko-outbox-186023@kernel.org> (raw)
In-Reply-To: <20261027021119.2325798-8-zhang.yanze@zte.com.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] RDMA/zrdma: broken conditional RTNL locking in zxdh_get_drvinfo()
--
commit f5a32e13f5abe916870114665b95d03769a17e3b
Author: Yanze Zhang <zhang.yanze@zte.com.cn>
RDMA/zrdma: Implement device and port query operations
This commit implements RDMA device and port query callbacks, including device
attributes, port attributes, PKey, link layer, port immutable data, and
firmware version string extraction for the zrdma driver.
> diff --git a/drivers/infiniband/hw/zrdma/zrdma_verbs.c b/drivers/infiniband/hw/zrdma/zrdma_verbs.c
> index abac97e694138..ceaad155fc5ae 100644
> --- a/drivers/infiniband/hw/zrdma/zrdma_verbs.c
> +++ b/drivers/infiniband/hw/zrdma/zrdma_verbs.c
[ ... ]
> @@ -352,6 +354,252 @@ static int zxdh_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
> return ret;
> }
>
> +/* Fetch the driver info for @zdev->netdev, or for its first lower device
> + * when it is a bond. The lower device list is protected by rtnl_lock, and
> + * the core may call this from a netdev notifier that already holds the
> + * lock, so it is only taken when it is not held already.
> + */
> +static bool zxdh_get_drvinfo(struct zxdh_device *zdev,
> + struct ethtool_drvinfo *info)
> +{
> + struct net_device *slave = NULL, *dev;
> + struct list_head *iter;
> + bool locked;
> + bool ret = true;
> +
> + memset(info, 0, sizeof(*info));
> +
> + locked = !rtnl_is_locked();
> + if (locked)
> + rtnl_lock();
> +
> + if (zdev->netdev->priv_flags & IFF_BONDING)
> + netdev_for_each_lower_dev(zdev->netdev, slave, iter)
> + break;
> +
> + dev = slave ? slave : zdev->netdev;
> + if (dev->ethtool_ops && dev->ethtool_ops->get_drvinfo)
> + dev->ethtool_ops->get_drvinfo(dev, info);
> + else
> + ret = false;
> +
> + if (locked)
> + rtnl_unlock();
[Severity: High]
Can this conditional locking in zxdh_get_drvinfo() cause an unlocked
traversal of zdev->netdev->adj_list.lower and a use-after-free on slave when
another task holds rtnl_mutex?
In net/core/rtnetlink.c, rtnl_is_locked() checks whether any task on any cpu
currently holds rtnl_mutex, rather than whether current owns it:
int rtnl_is_locked(void)
{
return mutex_is_locked(&rtnl_mutex);
}
When zxdh_get_drvinfo() is called through zxdh_query_device() or
zxdh_get_dev_fw_str() while another task on another cpu holds rtnl_mutex
(for example, while unlinking a bonding lower device via
netdev_upper_dev_unlink() or unregistering a slave net_device),
rtnl_is_locked() returns true.
As a result, zxdh_get_drvinfo() skips rtnl_lock() and calls
netdev_for_each_lower_dev() -> netdev_lower_get_next() and
dev->ethtool_ops->get_drvinfo(dev, info) without holding rtnl_mutex, racing
directly with the task modifying the lower device list or tearing down the
slave device.
Since zxdh_get_drvinfo() is only called from process context through
zxdh_query_device() and zxdh_get_dev_fw_str(), neither of which holds
rtnl_mutex, should zxdh_get_drvinfo() unconditionally call rtnl_lock() and
rtnl_unlock()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261027021119.2325798-1-zhang.yanze@zte.com.cn?part=7
prev parent reply other threads:[~2026-10-27 2:33 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 2:11 [PATCH rdma v7 0/7] Add ZTE DingHai Ethernet Protocol Driver for RDMA Yanze Zhang
2026-10-27 2:11 ` [PATCH rdma v7 1/7] RDMA/zrdma: Add build infrastructure and module skeleton Yanze Zhang
2026-10-27 2:30 ` sashiko-bot
2026-10-27 2:11 ` [PATCH rdma v7 2/7] RDMA/zrdma: Add core data structures and ABI definitions Yanze Zhang
2026-10-27 2:28 ` sashiko-bot
2026-10-27 2:11 ` [PATCH rdma v7 3/7] RDMA/zrdma: Add internal headers and hardware register definitions Yanze Zhang
2026-10-27 2:26 ` sashiko-bot
2026-10-27 7:10 ` Markus Elfring
2026-10-27 2:11 ` [PATCH rdma v7 4/7] RDMA/zrdma: Add hardware resource initialization and verbs skeleton Yanze Zhang
2026-10-27 2:33 ` sashiko-bot
2026-10-27 2:11 ` [PATCH rdma v7 5/7] RDMA/zrdma: Add device probe and remove logic Yanze Zhang
2026-10-27 2:37 ` sashiko-bot
2026-10-27 2:11 ` [PATCH rdma v7 6/7] RDMA/zrdma: Implement context, PD, and mmap operations Yanze Zhang
2026-10-27 2:39 ` sashiko-bot
2026-10-27 2:11 ` [PATCH rdma v7 7/7] RDMA/zrdma: Implement device and port query operations Yanze Zhang
2026-10-27 2:33 ` sashiko-bot [this message]
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=sashiko-outbox-186023@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=zhang.yanze@zte.com.cn \
/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.