Patch "xfs: clamp the pNFS layout range to the maximum file size" has been added to the 6.18-stable tree
Sasha Levin
AppliedThis is a note to let you know that I've just added the patch titled
xfs: clamp the pNFS layout range to the maximum file size
to the 6.18-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
xfs-clamp-the-pnfs-layout-range-to-the-maximum-file-.patch
and it can be found in the queue-6.18 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
commit 2bf2d333a7ee66866581b3636b725e4600b7b6ec
Author: Daejun Park <[email protected]> Date: Thu Oct 29 11:23:03 2026 +0900
xfs: clamp the pNFS layout range to the maximum file size
[ Upstream commit 29f3c1be4e554c9dbc66e13333034e0947477cb6 ]
xfs_fs_map_blocks() lets two bad layout ranges through. An offset of 2^63 or more is negative and passes "offset > limit". A length above the limit, such as NFS4_UINT64_MAX, wraps "offset > limit - length" and stays unclamped. With NFS4_UINT64_MAX, a read layout is built from an uninitialized mapping.
Reject a negative offset and one at the limit, and clamp the length. This needs "xfs: cap the block count of xfs_iomap_write_direct() at one extent".
fs/xfs/xfs_pnfs.c +2 -3
@@ -177,10 +177,9 @@ xfs_fs_map_blocks(if (!write) limit =max (limit,round_up (i_size_read (inode), inode->i_sb->s_blocksize)); -if (offset > limit) +if (offset <0 || offset >= limit) goto out_unlock; -if (offset > limit - length) - length = limit - offset; + length =min_t (u64, length, limit - offset); error =filemap_write_and_wait (inode->i_mapping);if (error)