Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH] RDMA/mthca: Check for null udata during reg_user_mr
@ 2026-06-30 15:55 Jacob Moroni
  2026-06-30 15:59 ` Jason Gunthorpe
  0 siblings, 1 reply; 4+ messages in thread
From: Jacob Moroni @ 2026-06-30 15:55 UTC (permalink / raw)
  To: jgg, leon; +Cc: linux-rdma, Jacob Moroni

The mthca driver was unconditionally checking udata->inlen,
but udata could be null if the user intentionally triggers
the UVERBS_METHOD_REG_MR ioctl. Prevent the potential null
deref by adding a check.

Signed-off-by: Jacob Moroni <jmoroni@google.com>
---
 drivers/infiniband/hw/mthca/mthca_provider.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index f90f67afc8f..6005ed40665 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -863,6 +863,9 @@ static struct ib_mr *mthca_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
 	if (dmah)
 		return ERR_PTR(-EOPNOTSUPP);
 
+	if (!udata)
+		return ERR_PTR(-EINVAL);
+
 	if (udata->inlen < sizeof ucmd) {
 		if (!context->reg_mr_warned) {
 			mthca_warn(dev, "Process '%s' did not pass in MR attrs.\n",
-- 
2.55.0.rc0.799.gd6f94ed593-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-06-30 17:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-30 15:55 [PATCH] RDMA/mthca: Check for null udata during reg_user_mr Jacob Moroni
2026-06-30 15:59 ` Jason Gunthorpe
2026-06-30 16:04   ` Jacob Moroni
2026-06-30 17:43     ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox