From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796487013; b=3Qg5PAoD7h9x5X9sQxaARzaZmU412eS0hxP1PoQvkAyW1TJNXXna6UE4YGa2fmZUaTpu gGk+mPog3CTv+/+pAD/cjvwEf+WM4M2q/U8ix4bmg0UXGUQE9BJUCtyqXxErwPdAoP5Tv WxuBYKi84IvO+Ac2IUqbuabXKdJryMQkiaacQB8pGUYFjlFFXXotTAvAn0DSkBcgcatKd cZkFDlaL5uqium/Q8qgmpIU5cNhZe9kHweIXUP2hrri5ffS8dFM6Uds50BqATiiv7E6Uq uD8Pt/wjayrGteoBHAYJZkxrT4cfXH14BmFyMpSmkFZR1xA6C+ElG5sJ2RXAzR5hh3g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796487013; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=0KFEUN1kdI6geHOCybiGcvIoi97MqvCRh9hT6kclfG8=; b=nCbJyEotEKqacA+O/9RhLx/ToUC3sUp8q7IS5M2ZlpBqw/kAR3oMvNk3mgDmAgB86WRe 2ebyg6fVFjYy01gv5JGCH8/z8FDN6TVVQnHVxbYlTMhg0Ta54AEKNayd1S8w93RX3bVF2 C9ymGH0gvZBvV7rQaR6Qz4rlzu3fAoVWhwUVQ/kl9LqJ4rfKPzvJJsltcqPfZ7MbDiyPJ 9L2f3P0uLupdfRW9lF/Ieoa3qLG9jII5oqpID6KBhwohgv3iWCDjampZK1nNsEVi/Iofh gGkYZBorQMs9TrtSL1TgEoEFz9aHAKXPyawT/GVpzuJjU5m59gpPfayfTkEZnXez47w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="e/x1xZLq"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB44E606A332 for ; Sat, 5 Dec 2026 16:10:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=e/x1xZLq Received: by smtp.kernel.org (Postfix) with ESMTPSA id 747C71F00A13; Sat, 5 Dec 2026 16:10:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796487013; bh=0KFEUN1kdI6geHOCybiGcvIoi97MqvCRh9hT6kclfG8=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=e/x1xZLq1v0y6BoVjD3FK2OKaIldTYixxWk3ii0v5Vrgo943z+MOqvzoK0Hnmjn+B AOM2rraKzvUiVovk04fLTw6/NKDV3xEHwVTEAUlGXKd0jikAYY6lYC2m60X7SLu1X4 BkJhkLkcG9wWoSN2qUCPSrOOq/YfilUbarpzirohNtfKEwqluXPOcK1ss+zmmnaZx+ 3x0wSUf7IqrEHGmRt9zsC2566g7fOzl/fYIIjwwU3iI7+4+YyjL3PloXRCE6nhlUpz EIfpF8t6GlgkOvBCHJyEs9xYo2G0fnPHbfwptZqiBoAcdbZljUJBy9C5shmP5dq9Yo lQYYbk7uo54MQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RDMA v2 11/13] RDMA/bng_re: Add AH verbs Reply-To: sashiko-reviews@lists.linux.dev To: "Siva Reddy Kallam" Cc: linux-rdma@vger.kernel.org In-Reply-To: <20261204155249.1002019-12-siva.kallam@broadcom.com> References: <20261204155249.1002019-1-siva.kallam@broadcom.com> <20261204155249.1002019-12-siva.kallam@broadcom.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 16:10:12 +0000 X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 6 potential issues to consider: - [High] RDMA/bng_re: u8 sgid_index in struct bng_sp_ah truncates 16-bit HW GID ID - [Medium] RDMA/bng_re: dest_ah_wq lacks WQ_MEM_RECLAIM for flush in bng_re_dealloc_pd() - [Medium] RDMA/bng_re: bng_re_create_ah() omits udata validation and response zero-pad - [Medium] RDMA/bng_re: TOCTOU and slot-reuse race on sgid_tbl.hw_id in bng_re_create_ah() - [Medium] RDMA/bng_re: un-ratelimited error logs on user AH create failures - [Low] RDMA/bng_re: missing static qualifier for bng_re_posted_destroy_ah() -- commit 4aa82821c41dc952a28686bc8dc4fa9145fbfc1c Author: Mohammed Faraaz RDMA/bng_re: Add AH verbs This commit adds the create, destroy, and query AH verbs for bng_re, along with the MPC AH modify command path, a workqueue for deferred non-sleepable AH destroys, and the uverbs response structure. > diff --git a/drivers/infiniband/hw/bng_re/bng_dev.c b/drivers/infiniband/= hw/bng_re/bng_dev.c > index 33556edaf37cd..2b6a4694a37e9 100644 > --- a/drivers/infiniband/hw/bng_re/bng_dev.c > +++ b/drivers/infiniband/hw/bng_re/bng_dev.c [ ... ] > @@ -555,6 +570,12 @@ static int bng_re_dev_init(struct bng_re_dev *rdev) > } > bng_re_debugfs_add_mpc(rdev); > bng_re_debugfs_add_mpctune(rdev); > + > + rdev->dest_ah_wq =3D alloc_ordered_workqueue("bng_re_dest_ah", 0); > + if (!rdev->dest_ah_wq) { > + rc =3D -ENOMEM; > + goto deinit_mpc; > + } > return 0; [Severity: Medium] Should dest_ah_wq be allocated with WQ_MEM_RECLAIM? bng_re_dealloc_pd() calls flush_workqueue(rdev->dest_ah_wq), and storage RDMA ULPs such as NVMe-oF/RDMA call ib_dealloc_pd() from WQ_MEM_RECLAIM workqueues (for example nvme_reset_wq via nvme_rdma_error_recovery_work() -> ... -> nvme_rdma_free_dev() -> ib_dealloc_pd()). Flushing a !WQ_MEM_RECLAIM workqueue from a WQ_MEM_RECLAIM worker triggers WARN_ONCE in check_flush_dependency() and risks a reclaim deadlock under memory pressure because bng_re_dest_ah has no rescuer thread. [ ... ] > diff --git a/drivers/infiniband/hw/bng_re/bng_sp.h b/drivers/infiniband/h= w/bng_re/bng_sp.h > index 74375615146b1..838566c0a4aa0 100644 > --- a/drivers/infiniband/hw/bng_re/bng_sp.h > +++ b/drivers/infiniband/hw/bng_re/bng_sp.h > @@ -207,6 +207,22 @@ struct bng_re_hw_stats { > struct bng_re_rstat rstat; > }; > =20 > +struct bng_sp_ah { > + struct bng_re_gid dgid; > + struct bng_sp_pd *pd; > + u32 id; > + u8 sgid_index; [Severity: High] Won't declaring sgid_index as u8 truncate 16-bit firmware HW GID IDs? sgid_tbl.hw_id is a u16 array and struct ah_modify_data expects __le16 sgid_index, so any firmware-assigned ID >=3D 256 has its upper byte dropped when bng_re_create_ah() assigns sgid_tbl.hw_id[ctx->idx] into ah->sp_ah.sgid_index. bng_sp_fill_mpc_ah_modify_parms() then zero-extends the truncated value, programming the wrong source GID index into the HW AH. Changing sgid_index to u16 fixes this. [ ... ] > diff --git a/drivers/infiniband/hw/bng_re/bng_verbs.c b/drivers/infiniban= d/hw/bng_re/bng_verbs.c > index 0f71740a254fa..a54ab2b9b96fe 100644 > --- a/drivers/infiniband/hw/bng_re/bng_verbs.c > +++ b/drivers/infiniband/hw/bng_re/bng_verbs.c [ ... ] > @@ -1568,3 +1575,185 @@ int bng_re_destroy_srq(struct ib_srq *ib_srq, str= uct ib_udata *udata) > =20 > return 0; > } > + > +void bng_re_posted_destroy_ah(struct work_struct *work) [Severity: Low] bng_re_posted_destroy_ah() is only referenced in bng_re_destroy_ah() in this file, so it can be static and its prototype removed from bng_verbs.h. [ ... ] > + if (ctx->idx >=3D rdev->bng_res.sgid_tbl.max || > + rdev->bng_res.sgid_tbl.hw_id[ctx->idx] =3D=3D 0xFFFF) { > + ibdev_err(&rdev->ibdev, "GID index %u has no HW id", ctx->idx); > + return -EINVAL; > + } > + ah->sp_ah.sgid_index =3D rdev->bng_res.sgid_tbl.hw_id[ctx->idx]; [Severity: Medium] Can concurrent GID deletion and addition race with this hw_id lookup? rdma_create_ah() holds only a kref on sgid_attr, and del_gid() in drivers/infiniband/core/cache.c calls ops.del_gid() immediately without waiting for that kref to drop. Because sgid_tbl has no lock shared with bng_re_create_ah(), the double read of hw_id[ctx->idx] can observe 0xFFFF after the check passes: CPU0 CPU1 bng_re_create_ah() del_gid() ctx =3D rdma_read_gid_hw_context() bng_re_del_gid() check hw_id[ctx->idx] !=3D 0xFFFF bng_sp_del_sgid() sgid_tbl->hw_id[idx] =3D 0xFFFF sgid_index =3D hw_id[ctx->idx] <-- reads 0xFFFF In addition, bng_sp_del_sgid() zeroes sgid_tbl->tbl[index].gid immediately, so a concurrent bng_sp_add_sgid() can reuse ctx->idx for a different GID or VLAN and bng_re_create_ah() will program that unrelated hw_id into the AH. [ ... ] > + rc =3D bng_sp_fill_and_send_mpc_ah_modify(&rdev->bng_res, > + ahs, 1, false, block); > + if (rc) { > + ibdev_err(&rdev->ibdev, "Failed to create HW AH"); > + return rc; > + } > + > + if (udata) { > + struct bng_re_ah_resp resp =3D {}; > + > + resp.ah_id =3D ah->sp_ah.id; > + rc =3D ib_copy_to_udata(udata, &resp, > + min(udata->outlen, sizeof(resp))); [Severity: Medium] Should bng_re_create_ah() validate empty input udata with ib_is_udata_in_empty(udata) and return the response via ib_respond_udata(udata, resp), as bng_re_alloc_pd() does? Without ib_is_udata_in_empty(), non-zero driver input from newer userspace is silently ignored instead of returning -EOPNOTSUPP. Using raw ib_copy_to_udata() also skips zero-filling trailing bytes when udata->outlen exceeds sizeof(resp). > + if (rc) { > + ibdev_err(&rdev->ibdev, "Failed to copy AH response"); > + goto fail_destroy; > + } [Severity: Medium] Can an unprivileged uverbs user flood the kernel log through these error paths? Calling IB_USER_VERBS_CMD_CREATE_AH with an unmapped or read-only response buffer triggers this un-ratelimited ibdev_err() on every syscall. Once the AH XID pool is exhausted, every subsequent user create_ah call also emits two un-ratelimited errors: dev_err() in bng_sp_fill_and_send_mpc_ah_modify() and ibdev_err() on "Failed to create HW AH" above. Using ibdev_dbg() or ratelimited logging (as in bng_re_create_user_cq() and bng_re_destroy_ah()) avoids user-triggerable log flooding. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204155249.1002= 019-1-siva.kallam@broadcom.com?part=3D11