From: Selvin Xavier <selvin.xavier@broadcom.com>
To: leon@kernel.org, jgg@ziepe.ca
Cc: linux-rdma@vger.kernel.org, andrew.gospodarek@broadcom.com,
kalesh-anakkur.purayil@broadcom.com,
Selvin Xavier <selvin.xavier@broadcom.com>
Subject: [PATCH for-rc v3 3/8] RDMA/bnxt_re: Validate SRQ max_sge at create time
Date: Mon, 21 Sep 2026 23:12:25 -0700 [thread overview]
Message-ID: <20260922061230.7909-4-selvin.xavier@broadcom.com> (raw)
In-Reply-To: <20260922061230.7909-1-selvin.xavier@broadcom.com>
bnxt_re_create_srq() stored attr.max_sge into srq->qplib_srq.max_sge
unvalidated, which defeats the num_sge check in
bnxt_re_post_srq_recv() since that check compares against this same
attacker-chosen value. Reject max_sge > dev_attr->max_srq_sges at
create time, and clamp dev_attr->max_srq_sges to BNXT_STATIC_MAX_SGE
since SRQ WQEs use the fixed-size SGE array.
Fixes: 37cb11acf1f7 ("RDMA/bnxt_re: Add SRQ support for Broadcom adapters")
Signed-off-by: Selvin Xavier <selvin.xavier@broadcom.com>
---
drivers/infiniband/hw/bnxt_re/ib_verbs.c | 8 ++++++++
drivers/infiniband/hw/bnxt_re/qplib_sp.c | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
index c293c30da13e..f81490fab0d1 100644
--- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c
+++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c
@@ -2236,6 +2236,14 @@ int bnxt_re_create_srq(struct ib_srq *ib_srq,
goto exit;
}
+ if (srq_init_attr->attr.max_sge > dev_attr->max_srq_sges) {
+ ibdev_err(&rdev->ibdev,
+ "Create SRQ failed - max_sge %d exceeds supported %d",
+ srq_init_attr->attr.max_sge, dev_attr->max_srq_sges);
+ rc = -EINVAL;
+ goto exit;
+ }
+
if (srq_init_attr->srq_type != IB_SRQT_BASIC) {
rc = -EOPNOTSUPP;
goto exit;
diff --git a/drivers/infiniband/hw/bnxt_re/qplib_sp.c b/drivers/infiniband/hw/bnxt_re/qplib_sp.c
index ec9eb52a8ebf..9aaa2b5204b8 100644
--- a/drivers/infiniband/hw/bnxt_re/qplib_sp.c
+++ b/drivers/infiniband/hw/bnxt_re/qplib_sp.c
@@ -160,7 +160,7 @@ int bnxt_qplib_get_dev_attr(struct bnxt_qplib_rcfw *rcfw)
attr->max_srq = le16_to_cpu(sb->max_srq);
attr->max_srq_wqes = le32_to_cpu(sb->max_srq_wr) - 1;
- attr->max_srq_sges = sb->max_srq_sge;
+ attr->max_srq_sges = min_t(u32, sb->max_srq_sge, BNXT_STATIC_MAX_SGE);
attr->max_pkey = 1;
attr->max_inline_data = attr->max_qp_sges * sizeof(struct sq_sge);
if (!bnxt_qplib_is_chip_gen_p7(rcfw->res->cctx))
--
2.39.3
next prev parent reply other threads:[~2026-09-22 0:51 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 6:12 [PATCH for-rc v3 0/8] RDMA/bnxt_re: Fix input validation and Selvin Xavier
2026-09-22 6:12 ` [PATCH for-rc v3 1/8] RDMA/bnxt_re: Fix integer overflow in send payload size computation Selvin Xavier
2026-09-22 1:09 ` sashiko-bot
2026-09-22 6:12 ` [PATCH for-rc v3 2/8] RDMA/bnxt_re: Detect wrong sge_len passed for inline Selvin Xavier
2026-09-22 1:08 ` sashiko-bot
2026-09-22 6:12 ` Selvin Xavier [this message]
2026-09-22 1:07 ` [PATCH for-rc v3 3/8] RDMA/bnxt_re: Validate SRQ max_sge at create time sashiko-bot
2026-09-22 6:12 ` [PATCH for-rc v3 4/8] RDMA/bnxt_re: Initialize wqe.flags in bnxt_re_post_srq_recv() Selvin Xavier
2026-09-22 1:02 ` sashiko-bot
2026-09-22 6:12 ` [PATCH for-rc v3 5/8] RDMA/bnxt_re: Validate num_sge " Selvin Xavier
2026-09-22 1:07 ` sashiko-bot
2026-09-22 4:39 ` Selvin Xavier
2026-09-29 8:33 ` Leon Romanovsky
2026-09-22 6:12 ` [PATCH for-rc v3 6/8] RDMA/bnxt_re: Serialize dcb_wq access against async notifier Selvin Xavier
2026-09-22 1:05 ` sashiko-bot
2026-09-22 6:12 ` [PATCH for-rc v3 7/8] RDMA/bnxt_re: Fix the PD and DPI table size Selvin Xavier
2026-09-22 1:01 ` sashiko-bot
2026-09-22 6:12 ` [PATCH for-rc v3 8/8] RDMA/bnxt_re: Use bnxt_ext_stats_supported for counter count selection Selvin Xavier
2026-09-22 1:06 ` sashiko-bot
2026-09-29 8:34 ` (subset) [PATCH for-rc v3 0/8] RDMA/bnxt_re: Fix input validation and Leon Romanovsky
2026-09-29 8:36 ` Leon Romanovsky
2026-10-01 5:21 ` Selvin Xavier
2026-09-29 8:42 ` (subset) " Leon Romanovsky
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=20260922061230.7909-4-selvin.xavier@broadcom.com \
--to=selvin.xavier@broadcom.com \
--cc=andrew.gospodarek@broadcom.com \
--cc=jgg@ziepe.ca \
--cc=kalesh-anakkur.purayil@broadcom.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).