]> 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:28:15 +0000 (16:28 +0200)
commit327276cb8a7eb15a85e3f2fac7cd953c42afadd2
treee92931b3dd530519ed450470c91c2b67064110be
parent6c7fadac6cbcb0b6dd62dbbb9268eae2f5d9cb74
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