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=1796487008; b=rA5Qp2PkRNX+0XFsrLzw9kmaAHptpl79BwaJrEvx/obpyicbCx7+EiXBnrJ5rVGLv21H L9Ml35HdUJsK7+YRodq8oAOvOsSXH7soYF1LdGIFKoi1ProXssIITNDRKSRGPd3UKckKd xfvwCXR78Iriiu2FpFH4dYsPHRQRQWM4PAfn5zDEDe8gttAm/kUvdnqljv1DQ9QLpqWpx T5nA1OzHzFk2/uZSET4dZAnoXaemh+jvfihjCeg9UcNWIFdqFdymWn4zym+cVnLROpmBX h5PVkgiaaHeq6PwaueaPaOcZgYEEowyPH6cW2U+NYC8oG8modLc9roL61R68f7clDrw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796487008; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=tYRV6B9eGDh5+9NjeW+0xaJdf8rJ6rcLqW1BXaUVrRE=; b=UCfTjpVP8BwfLBV9KDTx8WUXK+W7dZ9m7c9k/KiFReiHSZAwXLHdv062yx4ntwI0DJGW NVmX6lspnL7QAzVvTEzlBcqeO9QoioqB7Tsy588TxqYSzDd3PN61P2pb13otz86PevGPn aDGHOidlj939twzUYGr9f8gUGTm/cl4AckcOLL/0zxnk/BKe1DVjLotisUWaqVCh91qpt PWuHJEnWwHl/3YVQ5OIKE9FacszF6yBRX4fCSwcwlsiy4iiIhlSbqmesBq1EgHBYhCkGS xJAcMN0gbhnUmWjuWW3KTYLuiaT+eC3+zhN6Zz4l3qFNijl3X5rHLOfvAG077MnBeyQ== 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=PgofCBT8; 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 BDB73606A338 for ; Sat, 5 Dec 2026 16:10:08 +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=PgofCBT8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D42E1F00A12; Sat, 5 Dec 2026 16:10:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796487008; bh=tYRV6B9eGDh5+9NjeW+0xaJdf8rJ6rcLqW1BXaUVrRE=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=PgofCBT8vpUM5aRDIB7TvZIdCqaQt0W8ctpqmiH3AuLbuBgkvPGzDqcuBElMi+Xv4 Qpc8ofWG9uoAR66eAK+RAb1qJOsUF1n2e4sYotLtjhvCjZA2eKc8DmSycmoWCeGKZB RwbvaTSszGROL9pf81xHBcNnkYN8mr2nu2qFeN522qSV5DmBIkp8cWBNZg7Pe+UHIC BoygngF+LD+GqzlajLw710keKYHCgjXt8aHPSQZYEp4IzVtdfUlboSDmm136cgBoPc oAtYasLcfKOCeoWo7I/fUP+fDhP/uLgx/N3IenswFdZxqQvHoQeO+H0LnjzJZAurwj x7jontUSzWeAg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [RDMA v2 04/13] RDMA/bng_re: Add ucontext/mmap verbs Reply-To: sashiko-reviews@lists.linux.dev To: "Siva Reddy Kallam" Cc: linux-rdma@vger.kernel.org In-Reply-To: <20261204155249.1002019-5-siva.kallam@broadcom.com> References: <20261204155249.1002019-1-siva.kallam@broadcom.com> <20261204155249.1002019-5-siva.kallam@broadcom.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 16:10:08 +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 5 potential issues to consider: - [Medium] RDMA/bng_re: doorbell page size mismatch between DPI math and FW init - [Medium] RDMA/bng_re: silently ignores short udata input in bng_re_alloc_ucontext() - [Medium] RDMA/bng_re: missing trailing zero-fill on response in bng_re_alloc_ucontext() - [Medium] RDMA/bng_re: unratelimited KERN_ERR log flooding in bng_re_alloc_ucontext() - [Low] RDMA/bng_re: wrong printk format specifiers in bng_re_dealloc_dpi() -- commit 511e878f370833248f60a01e5aa8d21ada2aaf78 Author: Siva Reddy Kallam RDMA/bng_re: Add ucontext/mmap verbs This patch adds ucontext allocation, deallocation, disassociation, and mmap verbs to the bng_re driver, along with DPI allocation and deallocation helpers and the ucontext UAPI definitions. > diff --git a/drivers/infiniband/hw/bng_re/bng_res.c b/drivers/infiniband/= hw/bng_re/bng_res.c > index c5f9fff56726d..6fbe88001eba4 100644 > --- a/drivers/infiniband/hw/bng_re/bng_res.c > +++ b/drivers/infiniband/hw/bng_re/bng_res.c [ ... ] > +int bng_re_dealloc_dpi(struct bng_re_res *res, > + struct bng_re_dpi *dpi) > +{ > + struct bng_re_dpi_tbl *dpit =3D &res->dpi_tbl; > + int rc =3D 0; > + > + mutex_lock(&res->dpi_tbl_lock); > + if (dpi->bit >=3D dpit->max) { > + dev_warn(&res->pdev->dev, > + "Invalid DPI? dpi =3D %d, bit =3D %d\n", > + dpi->dpi, dpi->bit); > + rc =3D -EINVAL; > + goto release; > + } > + > + /* Check ownership first so a repeated free cannot unmap anything */ > + if (test_and_set_bit(dpi->bit, dpit->tbl)) { > + dev_warn(&res->pdev->dev, > + "Freeing an unused DPI? dpi =3D %d, bit =3D %d\n", > + dpi->dpi, dpi->bit); > + dev_warn(&res->pdev->dev, > + "umdbr =3D %lld, dbr =3D %p, type =3D %d\n", > + dpi->umdbr, dpi->dbr, dpi->type); > + dev_warn(&res->pdev->dev, > + "dpit max =3D %d, priv_db =3D %p\n", > + dpit->max, dpit->priv_db); [Severity: Low] Should these dev_warn() calls use unsigned format specifiers? dpi->dpi, dpi->bit, and dpit->max are u32 (so a repeated free after setting dpi->bit to U32_MAX prints bit =3D -1 with %d instead of %u), and dpi->umdbr is a u64 BAR address that should use %#llx or %llu rather than %lld. > diff --git a/drivers/infiniband/hw/bng_re/bng_res.h b/drivers/infiniband/= hw/bng_re/bng_res.h > index cc1872f3ab54d..b43827ee1b184 100644 > --- a/drivers/infiniband/hw/bng_re/bng_res.h > +++ b/drivers/infiniband/hw/bng_re/bng_res.h [ ... ] > +/* > + * HW doorbell page size. bnge does not program db_page_size through > + * HWRM_FUNC_CFG, so firmware uses its 4KB default. DPI numbers are in > + * units of this size, independent of the CPU PAGE_SIZE; each DPI handed > + * to user space still owns a full CPU page so mappings never overlap. > + */ > +#define BNG_RE_DB_PAGE_SIZE SZ_4K [Severity: Medium] Does hardcoding BNG_RE_DB_PAGE_SIZE to SZ_4K conflict with the doorbell page size programmed into RoCE firmware? bng_re_init_rcfw() configures firmware to use host PAGE_SIZE instead of the 4KB default: drivers/infiniband/hw/bng_re/bng_fw.c:bng_re_init_rcfw() { ... req.log2_dbr_pg_size =3D cpu_to_le16(PAGE_SHIFT - BNG_FW_DBR_BASE_PAGE_SHIFT); ... } On hosts where PAGE_SIZE > 4KB (such as 64KB arm64), DPI numbers computed in bng_res_alloc_dpi_tbl() and bng_re_alloc_dpi() in 4KB units disagree with firmware's doorbell page size by PAGE_SIZE / SZ_4K, so user DPIs passed to firmware are mis-indexed or rejected. > diff --git a/drivers/infiniband/hw/bng_re/bng_verbs.c b/drivers/infiniban= d/hw/bng_re/bng_verbs.c > index 6750dfa4a1680..45ade397342aa 100644 > --- a/drivers/infiniband/hw/bng_re/bng_verbs.c > +++ b/drivers/infiniband/hw/bng_re/bng_verbs.c [ ... ] > + if (udata->inlen >=3D sizeof(ureq)) { > + rc =3D ib_copy_from_udata(&ureq, udata, sizeof(ureq)); > + if (rc) > + return rc; > + if (udata->inlen > sizeof(ureq) && > + !ib_is_udata_cleared(udata, sizeof(ureq), > + udata->inlen - sizeof(ureq))) > + return -EOPNOTSUPP; > + if (ureq.comp_mask & ~BNG_RE_COMP_MASK_REQ_UCNTX_SUPPORTED) > + return -EOPNOTSUPP; > + } [Severity: Medium] Can a truncated non-empty udata buffer bypass input validation here? When 0 < udata->inlen < sizeof(ureq) (such as a 4-byte payload via uverbs write()), this block is skipped and the call succeeds instead of returning -EINVAL. Using if (udata->inlen) with ib_copy_validate_udata_in_cm() rejects short inputs while keeping the trailing-zero and comp_mask checks. [ ... ] > + rc =3D ib_copy_to_udata(udata, &resp, min(udata->outlen, sizeof(resp))); [Severity: Medium] Does this leave trailing userspace response bytes unzeroed when udata->outlen > sizeof(resp)? The RDMA udata ABI contract requires zero-filling any response bytes beyond sizeof(resp) so newer userspace expecting an extended bng_re_uctx_resp does not read uninitialized bytes from its output buffer. Switching to ib_respond_udata(udata, resp) handles the copy and trailing clear_user(). > + if (rc) { > + ibdev_err(ibdev, "Failed to copy user context"); > + rc =3D -EFAULT; > + goto copy_udata_fail; > + } [Severity: Medium] Can an unprivileged user flood the kernel log with this unratelimited ibdev_err()? Supplying an unwritable outbuf fails GET_CONTEXT without installing ufile->ucontext, so a single open uverbs fd can repeat the call in a tight loop and emit a KERN_ERR line every time. The unratelimited dev_err() in bng_re_get_user_dpi() has the same issue once DPIs are exhausted. Switching to ib_respond_udata() (which logs EFAULT with ibdev_dbg()) and downgrading or ratelimiting the bng_re_get_user_dpi() message avoids both. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204155249.1002= 019-1-siva.kallam@broadcom.com?part=3D4