Author: Yun Zhou <[email protected]>
Date: Sat Jul 25 10:40:29 2026 +0800
ext4: fix fd leak in EXT4_IOC_MOVE_EXT cross-sb validation
The backport of upstream commit c143957520c6 ("ext4: validate donor
file superblock early in EXT4_IOC_MOVE_EXT") uses a bare 'return -EXDEV'
which is safe upstream because the fd is managed via CLASS(fd) with
automatic cleanup (commit 8152f8201088 ("fdget(), more trivial
conversions")).
However, on 6.12.y the ioctl still uses the traditional fdget/fdput
pattern, so the bare return bypasses fdput(donor) at the mext_out label,
leaking the file reference.
Fix by setting err and using goto mext_out.
Fixes: 74796e886ca3 ("ext4: validate donor file superblock early in EXT4_IOC_MOVE_EXT")
Reported-by: Harshit Mogalapalli <[email protected]>
Signed-off-by: Yun Zhou <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>