]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ext2: Handle fiemap on empty files to prevent EINVAL
authorWei Gao <wegao@suse.com>
Fri, 13 Jun 2025 15:18:38 +0000 (11:18 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:25:51 +0000 (16:25 +0200)
commit3beaa57870b4de42aaaad53db2449dfcbc9fccbf
treea2fef47a4456591c02b5bf31a1e7b9b5d01aa2d6
parent9233db810d15a145d3e7851f17e4a7db4787fcb8
ext2: Handle fiemap on empty files to prevent EINVAL

[ Upstream commit a099b09a3342a0b28ea330e405501b5b4d0424b4 ]

Previously, ext2_fiemap would unconditionally apply "len = min_t(u64, len,
i_size_read(inode));", When inode->i_size was 0 (for an empty file), this
would reduce the requested len to 0. Passing len = 0 to iomap_fiemap could
then result in an -EINVAL error, even for valid queries on empty files.

Link: https://github.com/linux-test-project/ltp/issues/1246
Signed-off-by: Wei Gao <wegao@suse.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20250613152402.3432135-1-wegao@suse.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ext2/inode.c