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=1796265687; b=IwpE4Yu/5sAiHJJZ+iSgfhqe1t9A4t6Rbw91hZdefY6dOzQUFPpqMZegWBEuS36Ac1sW HtvY376k4V7MnYLDxhVvoz6oOEv+E4skVoLLH3CuQ8ihc0WAif5gayXp8ZjGXkAc7ITPd mcT+eKi/2Pu0sUUi2lvralztvHDg+3dPyRhabioTk6i78Tl4mhKIcurunDKssTMIpIloI rhZ4NS4Ratsva3ivTFWAzc5Wre2N6a0MtcOXEp+2gACkWU19sdxQ6ECv483d2k0PBpKa3 Vl4ak6rLCL2eeCGeF6i0bCNK5xTwUpDbMU47FIPOstDxne+VMiT0Qz+PBQEygsON4DA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796265687; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=NbMp3bRLX8Vhdo19gpRGkebS+cW4DeJ2FdurjE1YHjQ=; b=cwd4GvPqUVO1QTl2e3N77fYx+lyXMnly7LvPWJAgWNyeD1sSz4ubNS0+nFYnVzBlUjNs NwnqEPckm0sEaG+osULFz6eNKNEH4PYtqYE6iUEvOBlLBtJSVweDdyQYiG3qpAimBIko0 7F9Ig0Pf9VuTGRqZHc93nuQ+21qYKA/6Tj+S5G5xis7va5nsqBu8AcOI/V9eyDMhhpOtP OSNNhjFRRRSsWV0iu0zzGdjlq0nL3C4A2jk3BNmG5TbdXwS9VmrNBXtOKeXY5aLhvZJ1m 3mVtHFjWy6b0FUGOIDxq1gzPcH/Qj5O5C7BXRJANxhDo1Wrr9BKB5VnOEAjC3lyAplQ== 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=NzRWsEz+; 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 EAB62606A322 for ; Thu, 3 Dec 2026 02:41:26 +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=NzRWsEz+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C24E1F000C1; Thu, 3 Dec 2026 02:41:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796265686; bh=NbMp3bRLX8Vhdo19gpRGkebS+cW4DeJ2FdurjE1YHjQ=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=NzRWsEz+ijzBSYUOYvjuF2jA+PlqrtPp6RC58F1gA3iwWwwJ84mUSqF43+mIdYQrp jPMcTop+bDq+DPUx+xcQKSUaZCJurppK9rYfb6U8dlPfa24bwXGnKCwB7DMSWR7uLQ 5JyfIZS7ctT0ES1u9wajM4vSRj2W/AzwtA99SUm6SYgebKBetv/rLNRpNOkWam64NL lTf3MLzTavHXFo3ubpK/+rzyLBHvqYVmzI++ljDOTImGp6HKXVDuPRmKYz7q2DGgUo VCrklrt2ilQ5DvCHAYLEcgh4wnelgDedwPKf4N3aTdwxqffvUTFlk2BUwhyU5QVf1o 4Q8SgDym4KMJQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 1/2] fsdax: check the mapped length for all dax_iomap_direct_access() callers Reply-To: sashiko-reviews@lists.linux.dev To: "Amit Prasad" Cc: nvdimm@lists.linux.dev In-Reply-To: <20261203022139.1022927-2-amit@modal.com> References: <20261203022139.1022927-1-amit@modal.com> <20261203022139.1022927-2-amit@modal.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 02:41:26 +0000 X-Mailing-List: nvdimm@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] fsdax: uninitialized CoW extent committed on dax_iomap_copy_around() fault error -- commit 8f94c2f57aa6785f8bab5e4a4dcfe7614a1a1370 Author: Amit Prasad fsdax: check the mapped length for all dax_iomap_direct_access() callers This commit checks the mapped length returned by dax_direct_access() in dax_iomap_direct_access() even when pfnp is NULL, and clamps the length passed to dax_iomap_copy_around() in dax_iomap_iter() to the mapped range. > diff --git a/fs/dax.c b/fs/dax.c > index 9d161d7ef3ef7..0bb029e6a1ebb 100644 > --- a/fs/dax.c > +++ b/fs/dax.c > @@ -1281,11 +1281,13 @@ static int dax_iomap_direct_access(const struct i= omap *iomap, loff_t pos, > rc =3D length; > goto out; > } > - if (!pfnp) > - goto out_check_addr; > rc =3D -EINVAL; > if (PFN_PHYS(length) < size) > goto out; > + if (!pfnp) { > + rc =3D 0; > + goto out_check_addr; > + } [Severity: High] Can a PMD-sized copy-on-write fault with a short source map commit an uninitialized 2MB CoW extent into the inode data fork when dax_iomap_copy_around() fails? In dax_fault_iter(), dax_insert_entry() associates the newly allocated destination CoW PFN and installs it into mapping->i_pages before calling dax_iomap_copy_around(). When srcmap maps less than PMD_SIZE (such as across a device-mapper target boundary), dax_iomap_direct_access() now returns -EINVAL, causing dax_iomap_copy_around() to fail with -EIO and dax_fault_iter() to return VM_FAULT_SIGBUS without copying the source data: fs/dax.c:dax_fault_iter() { ... *entry =3D dax_insert_entry(xas, vmf, iter, *entry, pfn, entry_flags); if (write && iomap->flags & IOMAP_F_SHARED) { err =3D dax_iomap_copy_around(pos, size, size, srcmap, kaddr); if (err) return dax_fault_return(err); } ... } Because dax_iomap_pmd_fault() advances the iomap iterator whenever the return value is not VM_FAULT_FALLBACK, it advances iter by PMD_SIZE on VM_FAULT_SIGBUS: fs/dax.c:dax_iomap_pmd_fault() { ... ret =3D dax_fault_iter(vmf, &iter, pfnp, &xas, &entry, true); if (ret !=3D VM_FAULT_FALLBACK) iter.status =3D iomap_iter_advance(&iter, PMD_SIZE); ... } xfs_dax_write_iomap_end() then receives written =3D=3D PMD_SIZE and calls xfs_reflink_end_cow() instead of xfs_reflink_cancel_cow_range(), remapping the uncopied CoW extent into the file and corrupting 2MB of file data (while on a failed PTE CoW fault, written is 0 so xfs_reflink_cancel_cow_range() frees the CoW block that dax_insert_entry() already installed into mapping->i_pages). The follow-up commit "fsdax: iterate over short dax_direct_access() ranges" updates dax_iomap_copy_around() to iterate over short srcmap mappings, but this commit is tagged for stable and leaves the fault error path in dax_fault_iter() and dax_iomap_pmd_fault() broken whenever dax_iomap_copy_around() fails. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203022139.1022= 927-1-amit@modal.com?part=3D1