From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F1C19E7DEFF for ; Mon, 2 Feb 2026 16:04:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=JtJ+MO4XKNqk5AYs7Xhigs03k1ve8lY7wV2S7zekqj4=; b=RwrQ+yixwnDC5A6KQ3xf7VS26+ sU+qkLwbJIwmie6+EOd8PmVKbcLXJBPuyDmHCArF9os2AYz2b74okhY1N/smaVzKCyCZmwVaOn0ri r3KAXwhheoROVKLrr3OEZG6IrWGxKsP5mq30ylF+/RDHYAB05ATnZ24hNEo4Y5pXUZi7wMhB/Sbj9 HuusYqqr4g7/dT+XCFobpG3izi3PIX5Gup+6GmAlsuT2WN580lpYE8picRo9kUTYBsNHZiHpvPG6x NM/n/POkbmpR+TXRgnbZVvwaGTUxBPdEHwSSaPoXRWwhPtJ8K8WZM9SdDZlK8f2pdxtnQUEkibiCh xq7cKopQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vmwPg-00000005GIO-34c5; Mon, 02 Feb 2026 16:04:32 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vmwPe-00000005GHz-0mD5 for linux-nvme@lists.infradead.org; Mon, 02 Feb 2026 16:04:31 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 0EE2D40631; Mon, 2 Feb 2026 16:04:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BFA7C116C6; Mon, 2 Feb 2026 16:04:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770048268; bh=i9C4x2L6jLrWK55vr+wvHQqCEdNNkxwb2ocUf8llZi8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oveCre4dLd+PAyAP86LxStRh0GyZ4GupsC7r9LgN8M+YbpuHGARne83Di/WLjBoPj sliBZcMcVd95bhSMJiIB1Eu0HssWYbvbEz06Se65JZ5onDcrktxIL/yKbgFtC8J9FS dxOff70nKtfyn2F+wTYigEblungU6+wAYtI5jn44QmjOz3YmpO9Gb3KqoKufMUbjpr nZ0U78yMmpO+3Bfs7+iXPXS2wUAs52StbzXodSeYw/YmObV2vTeSXc9wW0MoJzmdxO n3M9kQ9aCixABgcsdvJgfm0dZhrCYORNJ4iJtNg7ImavkOFgcHYTk0MoEROVvGlZE4 oE7QnSz5b8h3A== Date: Mon, 2 Feb 2026 17:58:04 +0200 From: Leon Romanovsky To: Robin Murphy Cc: Christoph Hellwig , Pradeep P V K , kbusch@kernel.org, axboe@kernel.dk, sagi@grimberg.me, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, nitin.rawat@oss.qualcomm.com, Marek Szyprowski , iommu@lists.linux.dev Subject: Re: [PATCH V1] nvme-pci: Fix NULL pointer dereference in nvme_pci_prp_iter_next Message-ID: <20260202155804.GN34749@unreal> References: <20260202143548.GA19313@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260202_080430_241552_8E2F30D6 X-CRM114-Status: GOOD ( 18.99 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org On Mon, Feb 02, 2026 at 03:16:50PM +0000, Robin Murphy wrote: > On 2026-02-02 2:35 pm, Christoph Hellwig wrote: > > On Mon, Feb 02, 2026 at 06:27:38PM +0530, Pradeep P V K wrote: > > > Fix a NULL pointer dereference that occurs in nvme_pci_prp_iter_next() > > > when SWIOTLB bounce buffering becomes active during runtime. > > > > > > The issue occurs when SWIOTLB activation changes the device's DMA > > > mapping requirements at runtime, > > > > > > creating a mismatch between > > > iod->dma_vecs allocation and access logic. > > > > > > The problem manifests when: > > > 1. Device initially operates with dma_skip_sync=true > > > (coherent DMA assumed) > > > 2. First SWIOTLB mapping occurs due to DMA address limitations, > > > memory encryption, or IOMMU bounce buffering requirements > > > 3. SWIOTLB calls dma_reset_need_sync(), permanently setting > > > dma_skip_sync=false > > > 4. Subsequent I/Os now have dma_need_unmap()=true, requiring > > > iod->dma_vecs > > > > I think this patch just papers over the bug. If dma_need_unmap > > can't be trusted before the dma_map_* call, we've not saved > > the unmap information and the unmap won't work properly. > > The dma_need_unmap() kerneldoc says: > > "This function must be called after all mappings that might > need to be unmapped have been performed." > > Trying to infer anything from it beforehand is definitely a bug in the > caller. At least for HMM, dma_need_unmap() works as expected. HMM doesn't work with SWIOTLB. Thanks