From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35810606A325 for ; Tue, 1 Dec 2026 06:44:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=pffYwZq4; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ri/CEgLE DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Date: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:Cc:To:Subject: From:Message-ID:MIME-Version:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=RkYs1qCl2gyLCPFwFOVDzlwvHJJ9L9hs/YUqI6JgbjE=; b=pffYwZq4SJKeXNR/Y6zFJ0sDzU fBLWgTpvMQEmba/ETExJZ15BqcnizmJS3ILx3RTvGXaMjVuiJbf+GT6dfrJ0eV3FGvWiWv572PyNR NUCfVBu2wcXeNSXfT42P8FXhlxUdX0eDbM1ub3uSIwhR1FdgM0ZEZQXluv7gySXcbHkq/KAj3h++X /2BiZauEHYYHD/A5+L7P/UzAFEqthnNsC88em2RNO1/Sgfj4VUoLhEnl+riaq6EVxJnHS7xKt2YLC u9WxIRA1/tw0vd2NI+UWlrpkIhhxhDlvrSwQXQm6+uvJhpOjspFf9dPnB5v4q1R8I5QmX9t5YUgUw 0u/sIqKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYHb4-00000006pG5-3aIP; Tue, 01 Dec 2026 06:44:14 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYHb3-00000006pFa-2EnX for linux-nvme@lists.infradead.org; Tue, 01 Dec 2026 06:44:13 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id B1F9E611E6; Tue, 1 Dec 2026 06:44:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0478E1F000C1; Tue, 1 Dec 2026 06:44:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796107452; bh=RkYs1qCl2gyLCPFwFOVDzlwvHJJ9L9hs/YUqI6JgbjE=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Ri/CEgLEVArYIuyn0+FEbrqkngF2vkhX+ZzdwhklZY/SlQCNKb4gNfdE99Aosn2B5 z8oHeV83XnSr/UxIn8hyANeE1npksCCxU8nNdTucRWcXJ6C+pU1acofMXM4oV4exDE k1vFK2HeLm+cHmW2O5wpS6FsvhCTu8MFT0WPWtWfmMTWqmFmvicvxBVE5n8ndm3dGN 9xLyex+1Bbv7ai4r8BO1IkQKLWDUzfj+FTA3YQjoCh+YN7e6M8g8hzS83uaepS9BK2 ZUomjgkIJyFGD+KG6hPUnfk5KMCZW4hK4hGFDinSRkhyR89yHjHa/uWueYLB8lg6s+ BSKnWTdIsvNig== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] nvme-pci: validate dmabuf size and sg_table bounds in nvme_dma_buf_io_map() To: "Bilal Hashim" Cc: linux-nvme@lists.infradead.org In-Reply-To: <179610715173.42980.4278125034253504647@126.com> References: <179610715173.42980.4278125034253504647@126.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 06:44:11 +0000 X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "Linux-nvme" X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] nvme-pci: missing Fixes trailer for nvme_dma_buf_io_map() bounds fix -- commit 0f211451ecf8fb8b6438a1ca1c4bb449732f7069 Author: Bilal Hashim > nvme-pci: validate dmabuf size and sg_table bounds in nvme_dma_buf_io_map= () > > In nvme_dma_buf_io_map(): > > 1. ctx->dmabuf->size (size_t) is divided by NVME_CTRL_PAGE_SIZE and > stored into a 32-bit unsigned nr_entries without checking for zero or > overflow, and nvme_rq_setup_dmabuf_map() indexes the buffer via the > 32-bit bio->bi_iter.bi_offset. Reject empty dma-bufs or dma-bufs > larger than UINT_MAX. > 2. When populating map->dma_list[] from the scatter-gather table, there > is no bounds check against nr_entries. If the sg_table total DMA > length exceeds nr_entries * NVME_CTRL_PAGE_SIZE, map->dma_list[i++] > overflows the allocated buffer. Conversely, if the sg_table total DMA > length is smaller than nr_entries * NVME_CTRL_PAGE_SIZE, trailing > entries in map->dma_list[] remain uninitialized (kvmalloc_flex() does > not zero-initialize) and could be programmed as arbitrary NVMe DMA > addresses. > > Validate ctx->dmabuf->size before computing nr_entries, bounds-check > each write into map->dma_list[], and verify that the entire dma_list was > populated. > > Found by manual code inspection. > > Signed-off-by: Bilal Hashim [Severity: Low] This fixes missing size and scatter-gather bounds checks in nvme_dma_buf_io_map(). Should this include: Fixes: ce5e386c1108 ("nvme-pci: implement dma-buf backed requests") --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/179610715173.42980.= 4278125034253504647@126.com?part=3D1