From: Edward Srouji <edwards@nvidia.com>
To: Leon Romanovsky <leon@kernel.org>, Jason Gunthorpe <jgg@ziepe.ca>,
"Yishai Hadas" <yishaih@nvidia.com>,
Yishai Hadas <yishaih@mellanox.com>
Cc: <linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
"Edward Srouji" <edwards@nvidia.com>,
Sashiko <sashiko-bot@kernel.org>, Uri Dar <udar@nvidia.com>,
<stable@vger.kernel.org>, Michael Gur <michaelgur@nvidia.com>
Subject: [PATCH rdma-next v2 0/3] RDMA: Fix DEVX UMEM mailbox size overflow
Date: Wed, 11 Nov 2026 15:57:01 +0200 [thread overview]
Message-ID: <20261111-devx-umem-mailbox-overflow-v2-0-1e7ca8237b58@nvidia.com> (raw)
Registering a DEVX UMEM builds a CREATE_UMEM mailbox whose size grows
with the number of MTTs, i.e. with the user-supplied length and
pgsz_bitmap. The size is stored in a u32, so a UMEM of about 2TB with
4KB pages wraps it, the mailbox is under-allocated and
mlx5_ib_populate_pas() writes past its end.
Patch 1 fixes a pre-existing issue in the same path, reported by Sashiko
on v1: devx_umem_find_best_pgsize() can return a page size that is not
in the user's pgsz_bitmap.
Patch 2 computes the mailbox size with the saturating size_mul() and
size_add() helpers and rejects UMEMs whose mailbox exceeds INT_MAX, the
largest in_size mlx5_cmd_exec() accepts.
Patch 3 handles the remaining corner: _uverbs_alloc() adds a small
header to the request before calling kvmalloc(), so a mailbox just
under INT_MAX can still push kvmalloc() over its INT_MAX limit and
trigger a WARN. Since these sizes come from userspace, the allocation
now uses __GFP_NOWARN and fails with -ENOMEM.
Mailbox sizes within 512 bytes of INT_MAX also overflow the block count
in mlx5_calc_cmd_blocks(). That predates this series and fails safely
with -ENOMEM before the command reaches firmware, so it is left for a
separate mlx5_core change.
The overflow was found with an AI-assisted static analysis tool and
confirmed by code review.
Patch 2 relies on size_mul() and size_add(), so stable trees older than
5.18 will need a manual backport.
Signed-off-by: Edward Srouji <edwards@nvidia.com>
---
Changes in v2:
- Keep cmd->inlen unsigned and bound the mailbox size explicitly
- Add patch 1 to respect pgsz_bitmap when reducing the page size
(Sashiko)
- Link to v1: https://lore.kernel.org/r/20261109-devx-umem-mailbox-overflow-v1-0-4a63baab25dc@nvidia.com
---
Edward Srouji (1):
RDMA/mlx5: Respect pgsz_bitmap when reducing the DEVX UMEM page size
Uri Dar (2):
RDMA/mlx5: Fix DEVX UMEM mailbox size truncation
RDMA/core: Don't warn on oversized bundle allocations
drivers/infiniband/core/ib_core_uverbs.c | 2 +-
drivers/infiniband/hw/mlx5/devx.c | 23 ++++++++++++++++-------
2 files changed, 17 insertions(+), 8 deletions(-)
---
base-commit: e50525a486300e5ff8014c9985b8477b2fca0368
change-id: 20261109-devx-umem-mailbox-overflow-c741bc73deb4
Best regards,
--
Edward Srouji <edwards@nvidia.com>
next reply other threads:[~2026-11-11 13:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 13:57 Edward Srouji [this message]
2026-11-11 13:57 ` [PATCH rdma-next v2 1/3] RDMA/mlx5: Respect pgsz_bitmap when reducing the DEVX UMEM page size Edward Srouji
2026-11-11 13:57 ` [PATCH rdma-next v2 2/3] RDMA/mlx5: Fix DEVX UMEM mailbox size truncation Edward Srouji
2026-11-11 13:57 ` [PATCH rdma-next v2 3/3] RDMA/core: Don't warn on oversized bundle allocations Edward Srouji
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=20261111-devx-umem-mailbox-overflow-v2-0-1e7ca8237b58@nvidia.com \
--to=edwards@nvidia.com \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=michaelgur@nvidia.com \
--cc=sashiko-bot@kernel.org \
--cc=stable@vger.kernel.org \
--cc=udar@nvidia.com \
--cc=yishaih@mellanox.com \
--cc=yishaih@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®