mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
xfs: clamp the pNFS layout range to the maximum file size
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".
Fixes: 527851124d ("xfs: implement pNFS export operations")
Cc: stable@vger.kernel.org
Signed-off-by: Daejun Park <daejun7.park@samsung.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Pankaj Raghav <p.raghav@samsung.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
This commit is contained in:
parent
66d1ce09eb
commit
29f3c1be4e
|
|
@ -176,10 +176,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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user