From 628f33362e80953ca80c457ca53e4c8458381a7b Mon Sep 17 00:00:00 2001 From: Jacob Moroni Date: Mon, 13 Jul 2026 17:12:56 +0000 Subject: RDMA/irdma: Fix legacy i40iw compat check in create_qp The irdma driver maintains backward compatibility with the legacy i40iw userspace provider by checking the length of the user response buffer in irdma_create_qp. Previously, the check relied on udata->outlen < sizeof(uresp). That is technically okay since there have only ever been two sizes for the resp struct (legacy and current). However, it would be a problem if the resp struct is ever expanded in the future because it would end up triggering the legacy fallback path for non-legacy irdma providers that just haven't moved over to the newer expanded struct yet. Fix this by explicitly checking for the exact legacy resp size. Signed-off-by: Jacob Moroni Link: https://patch.msgid.link/20260713171257.3131493-6-jmoroni@google.com Signed-off-by: Leon Romanovsky --- drivers/infiniband/hw/irdma/verbs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c index 1dd4a48c268d..81593bb1917e 100644 --- a/drivers/infiniband/hw/irdma/verbs.c +++ b/drivers/infiniband/hw/irdma/verbs.c @@ -1138,8 +1138,12 @@ static int irdma_create_qp(struct ib_qp *ibqp, init_completion(&iwqp->free_qp); if (udata) { - /* GEN_1 legacy support with libi40iw does not have expanded uresp struct */ - if (udata->outlen < sizeof(uresp)) { + /* GEN_1 legacy support with libi40iw does not have expanded + * uresp struct. Check for the exact legacy size (20 bytes) to + * ensure that newer expanded uresp structs don't accidentally + * trigger the legacy fallback. + */ + if (udata->outlen == IRDMA_CREATE_QP_MIN_RESP_LEN) { uresp.lsmm = 1; uresp.push_idx = IRDMA_INVALID_PUSH_PAGE_INDEX_GEN_1; } else { -- cgit v1.2.3