From: sashiko-bot@kernel.org
To: lirongqing <lirongqing@baidu.com>
Cc: linux-rdma@vger.kernel.org
Subject: Re: [PATCH] RDMA/mlx5: Unbind data direct device on IB device unregister
Date: Wed, 23 Sep 2026 08:31:28 +0000 [thread overview]
Message-ID: <20260923083129.3CDED1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260923081442.2520-1-lirongqing@baidu.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] RDMA/mlx5: Use-After-Free in mlx5r_umr_post_send due to teardown phase inversion
--
commit a526f3c890d0ead88aa1cec9b7e04bfef90a8d6b
Author: Li RongQing <lirongqing@baidu.com>
RDMA/mlx5: Unbind data direct device on IB device unregister
This commit adds a call to mlx5_ib_data_direct_unbind() during IB device
unregister to revoke data-direct MRs and clear the data_direct_dev pointer.
> diff --git a/drivers/infiniband/hw/mlx5/data_direct.c b/drivers/infiniband/hw/mlx5/data_direct.c
> index 93a56ee2c4ef4..66852e83c38d0 100644
> --- a/drivers/infiniband/hw/mlx5/data_direct.c
> +++ b/drivers/infiniband/hw/mlx5/data_direct.c
[ ... ]
> @@ -109,6 +109,7 @@ void mlx5_data_direct_ib_unreg(struct mlx5_ib_dev *ibdev)
> mutex_lock(&mlx5_data_direct_mutex);
> list_for_each_entry(reg, &mlx5_data_direct_reg_list, list) {
> if (reg->ibdev == ibdev) {
> + mlx5_ib_data_direct_unbind(reg->ibdev);
[Severity: High]
Does this introduce a use-after-free during device teardown?
Looking at the teardown sequence in __mlx5_ib_remove(), device stages are
cleaned up in reverse order. The MLX5_IB_STAGE_PRE_IB_REG_UMR stage is torn
down before MLX5_IB_STAGE_INIT.
During MLX5_IB_STAGE_PRE_IB_REG_UMR cleanup, mlx5r_umr_resource_cleanup()
frees the UMR queue pair:
mlx5r_umr_resource_cleanup() {
...
ib_destroy_qp(dev->umrc.qp);
...
}
Later, during MLX5_IB_STAGE_INIT cleanup, mlx5_ib_stage_init_cleanup() calls
mlx5_data_direct_ib_unreg(), which now triggers mlx5_ib_data_direct_unbind().
If there are remaining MRs to revoke, the call chain is:
mlx5_ib_data_direct_unbind()
mlx5_ib_revoke_data_direct_mrs()
mlx5r_umr_revoke_mr()
mlx5r_umr_post_send_wait()
At this point, mlx5r_umr_post_send_wait() will attempt to post a work request
using the already-freed dev->umrc.qp, causing a use-after-free if any
data-direct MRs failed to deregister cleanly.
> list_del(®->list);
> kfree(reg);
> goto end;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260923081442.2520-1-lirongqing@baidu.com?part=1
prev parent reply other threads:[~2026-09-23 8:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 8:14 [PATCH] RDMA/mlx5: Unbind data direct device on IB device unregister lirongqing
2026-09-23 8:31 ` 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=20260923083129.3CDED1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=lirongqing@baidu.com \
--cc=sashiko-reviews@lists.linux.dev \
/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.