Linux EXT4 FS development
 help / color / mirror / Atom feed
* [PATCH] ext4: check fsnotify permissions before MOVE_EXT
@ 2026-12-04 14:00 Shawn Shao
  2026-12-04 14:35 ` sashiko-bot
  2026-12-05  9:55 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Shawn Shao @ 2026-12-04 14:00 UTC (permalink / raw)
  To: tytso
  Cc: Andreas Dilger, Baokun Li, Jan Kara, Ojaswin Mujoo,
	Ritesh Harjani, Zhang Yi, linux-ext4

The EXT4_IOC_MOVE_EXT ioctl manipulates file extents directly without
running the permission hooks used by regular reads and writes. Check
read permission on the source and write permission on the donor before
moving extents.

Built and tested on x86-64 QEMU against the base revision.

Fixes: f156524e5d72 ("fsnotify: introduce pre-content permission events")
Signed-off-by: Shawn Shao <shawnq1@163.com>
---
Additional test information:
HEAD commit: 7cd8495c0f16275c4f9abe1cef09a7b5fcd6d046
git tree: 194227446ae61b4971eea1b7bed06856fe3cc477
source version: Linux 7.4.0-rc4
compiler: gcc 11.4.0, GNU ld 2.38
A reproducer and positive/control logs are available privately to maintainers.

 fs/ext4/ioctl.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 83630cd40712c..be272853d1fa7 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -9,6 +9,7 @@
  */
 
 #include <linux/fs.h>
+#include <linux/fsnotify.h>
 #include <linux/capability.h>
 #include <linux/time.h>
 #include <linux/compat.h>
@@ -1687,6 +1688,14 @@ static long __ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 		if (file_inode(filp)->i_sb != file_inode(fd_file(donor))->i_sb)
 			return -EXDEV;
 
+		/* Extent movement reads the source and overwrites the donor. */
+		err = fsnotify_file_perm(filp, MAY_READ);
+		if (err)
+			return err;
+		err = fsnotify_file_perm(fd_file(donor), MAY_WRITE);
+		if (err)
+			return err;
+
 		err = mnt_want_write_file(filp);
 		if (err)
 			return err;
-- 
2.34.1


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

end of thread, other threads:[~2026-12-05  9:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 14:00 [PATCH] ext4: check fsnotify permissions before MOVE_EXT Shawn Shao
2026-12-04 14:35 ` sashiko-bot
2026-12-05  9:55 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox