All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 6.12.y] ext4: fix fd leak in EXT4_IOC_MOVE_EXT cross-sb validation
@ 2026-07-25  2:40 Yun Zhou
  2026-07-25  6:02 ` Patch "ext4: fix fd leak in EXT4_IOC_MOVE_EXT cross-sb validation" has been added to the 6.12-stable tree gregkh
  0 siblings, 1 reply; 2+ messages in thread
From: Yun Zhou @ 2026-07-25  2:40 UTC (permalink / raw)
  To: gregkh; +Cc: harshit.m.mogalapalli, stable, patches

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 <harshit.m.mogalapalli@oracle.com>
Signed-off-by: Yun Zhou <yun.zhou@windriver.com>
---
 fs/ext4/ioctl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index a8a024bb62b4..e726f9dbc146 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -1372,8 +1372,10 @@ static long __ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 			goto mext_out;
 		}
 
-		if (file_inode(filp)->i_sb != file_inode(fd_file(donor))->i_sb)
-			return -EXDEV;
+		if (file_inode(filp)->i_sb != file_inode(fd_file(donor))->i_sb) {
+			err = -EXDEV;
+			goto mext_out;
+		}
 
 		err = mnt_want_write_file(filp);
 		if (err)
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-25  6:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-25  2:40 [PATCH 6.12.y] ext4: fix fd leak in EXT4_IOC_MOVE_EXT cross-sb validation Yun Zhou
2026-07-25  6:02 ` Patch "ext4: fix fd leak in EXT4_IOC_MOVE_EXT cross-sb validation" has been added to the 6.12-stable tree gregkh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.