[PATCH v2 2/2] xfs: clamp a pNFS LAYOUTCOMMIT extent before computing its end
From: Daejun Park via B4 Relay
Date: Tue Oct 13 2026 - 23:44:25 EST
From: Daejun Park <daejun7.park@xxxxxxxxxxx>
xfs_fs_commit_blocks() clamps the end of each committed extent to the
file size, but computes the end as offset + length first. A length
from the client can make that sum wrap around, and the loop then
passes the client's length, unclamped, to xfs_iomap_write_unwritten().
xfs_bmapi_write() then fails an assertion on XFS_DEBUG kernels, which
is a BUG with XFS_ASSERT_FATAL, and otherwise returns -ENOSR, which
nfsd warns about as a non-standard errno.
With pynfs as the client and an RW layout for the first 64 KiB of a
2 MiB sparse file, a LAYOUTCOMMIT of 2^64 - 4 KiB at 4 KiB got
NFS4ERR_IO, "nfsd: non-standard errno: -63" and a WARNING, or the
assertion on XFS_DEBUG.
Clamp the length to what is left below the size before adding it to
the offset. With this and "xfs: refuse a pNFS LAYOUTCOMMIT of a range
without blocks", the extent ends at the size and gets NFS4ERR_IO at the
hole after the laid-out range, without a warning or an assertion.
Fixes: 527851124d10 ("xfs: implement pNFS export operations")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Daejun Park <daejun7.park@xxxxxxxxxxx>
---
fs/xfs/xfs_pnfs.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/fs/xfs/xfs_pnfs.c b/fs/xfs/xfs_pnfs.c
index 05c9660aea..d76873115c 100644
--- a/fs/xfs/xfs_pnfs.c
+++ b/fs/xfs/xfs_pnfs.c
@@ -312,9 +312,7 @@ xfs_fs_commit_blocks(
if (start > size)
continue;
- end = start + maps[i].length;
- if (end > size)
- end = size;
+ end = start + min_t(u64, maps[i].length, size - start);
length = end - start;
if (!length)
--
2.43.0