linux-stable/fs/ext4
Ojaswin Mujoo 9b12755135 ext4: fix reserved gdt blocks handling in fsmap
commit 3ffbdd1f11 upstream.

In some cases like small FSes with no meta_bg and where the resize
doesn't need extra gdt blocks as it can fit in the current one,
s_reserved_gdt_blocks is set as 0, which causes fsmap to emit a 0
length entry, which is incorrect.

  $ mkfs.ext4 -b 65536 -O bigalloc /dev/sda 5G
  $ mount /dev/sda /mnt/scratch
  $ xfs_io -c "fsmap -d" /mnt/scartch

        0: 253:48 [0..127]: static fs metadata 128
        1: 253:48 [128..255]: special 102:1 128
        2: 253:48 [256..255]: special 102:2 0     <---- 0 len entry
        3: 253:48 [256..383]: special 102:3 128

Fix this by adding a check for this case.

Cc: stable@kernel.org
Fixes: 0c9ec4beec ("ext4: support GETFSMAP ioctls")
Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Link: https://patch.msgid.link/08781b796453a5770112aa96ad14c864fbf31935.1754377641.git.ojaswin@linux.ibm.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-08-28 16:21:31 +02:00
..
acl.c
acl.h
balloc.c ext4: reorder capability check last 2025-06-04 14:32:31 +02:00
bitmap.c
block_validity.c
dir.c ext4: fix OOB read when checking dotdot dir 2025-05-02 07:39:24 +02:00
ext4_extents.h
ext4_jbd2.c
ext4_jbd2.h
ext4.h ext4: avoid ext4_error()'s caused by ENOMEM in the truncate path 2025-02-01 18:18:53 +01:00
extents_status.c ext4: make sure allocate pending entry not fail 2023-12-08 08:44:24 +01:00
extents_status.h
extents.c ext4: fix calculation of credits for extent tree modification 2025-06-27 11:02:51 +01:00
file.c
fsmap.c ext4: fix reserved gdt blocks handling in fsmap 2025-08-28 16:21:31 +02:00
fsmap.h
fsync.c
hash.c
ialloc.c ext4: avoid negative min_clusters in find_group_orlov() 2024-11-08 16:20:30 +01:00
indirect.c
inline.c ext4: do not BUG when INLINE_DATA_FL lacks system.data xattr 2025-08-28 16:21:27 +02:00
inode.c ext4: check fast symlink for ea_inode correctly 2025-08-28 16:21:31 +02:00
ioctl.c
Kconfig
Makefile
mballoc.c ext4: fix FS_IOC_GETFSMAP handling 2024-12-14 19:44:35 +01:00
mballoc.h ext4: fix FS_IOC_GETFSMAP handling 2024-12-14 19:44:35 +01:00
migrate.c ext4: fix i_data_sem unlock order in ext4_ind_migrate() 2024-11-08 16:20:39 +01:00
mmp.c
move_extent.c ext4: fix double-free of blocks due to wrong extents moved_len 2024-02-23 08:25:11 +01:00
namei.c ext4: fix off-by-one error in do_split 2025-05-02 07:39:15 +02:00
page-io.c
readpage.c
resize.c ext4: fix corruption during on-line resize 2024-04-13 12:51:26 +02:00
super.c ext4: don't over-report free space or inodes in statvfs 2025-05-02 07:39:24 +02:00
symlink.c
sysfs.c
truncate.h
verity.c
xattr_security.c
xattr_trusted.c
xattr_user.c
xattr.c ext4: ignore xattrs past end 2025-05-02 07:39:11 +02:00
xattr.h