* [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* Re: [PATCH] ext4: check fsnotify permissions before MOVE_EXT
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
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-12-04 14:35 UTC (permalink / raw)
To: Shawn Shao; +Cc: linux-ext4, tytso
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] ext4: modular build fails on unexported fsnotify_pre_content()
- [Medium] ext4: EXT4_IOC_MOVE_EXT calls fsnotify_file_perm() without
range info
- [Low] ext4: Fixes trailer cites f156524e5d72 instead of 5121711eb8db
--
commit 2e710f64b8de9e73123cefa3e48b3150f38ed001
Author: Shawn Shao <shawnq1@163.com>
> ext4: check fsnotify permissions before MOVE_EXT
>
> 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>
[Severity: Low]
Should the Fixes tag point to 5121711eb8db ("fs: enable pre-content events
on supported file systems") instead of f156524e5d72 ("fsnotify: introduce
pre-content permission events")?
Commit f156524e5d72 only added the generic infrastructure, while
5121711eb8db is what enabled SB_I_ALLOW_HSM on ext4 in __ext4_fill_super().
> 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
[ ... ]
> @@ -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;
[Severity: High]
Does calling fsnotify_file_perm() here break modular ext4 builds
(CONFIG_EXT4_FS=m) when CONFIG_FANOTIFY_ACCESS_PERMISSIONS=y?
fsnotify_file_perm() -> fsnotify_file_area_perm() is static inline and
emits a direct call to fsnotify_pre_content(), which is not exported in
fs/notify/fsnotify.c, causing modpost to fail on ext4.ko.
Using the exported remap_verify_area() helper or exporting
fsnotify_pre_content() would fix modular builds.
[Severity: Medium]
Should this pass the requested byte range via remap_verify_area() or
fsnotify_file_area_perm() instead of fsnotify_file_perm()?
fsnotify_file_perm() passes a NULL position to fsnotify_pre_content(),
omitting FAN_EVENT_INFO_TYPE_RANGE from FAN_PRE_ACCESS events. On ext4
with HSM watchers, that forces full-file hydration on bounded moves even
though me.orig_start, me.donor_start, and me.len are already known here.
Calling the hook before validating the range also lets invalid or
zero-length requests trigger blocking permission events before
mext_check_adjust_range() rejects them with -EINVAL.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204140055.832696-1-shawnq1@163.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ext4: check fsnotify permissions before MOVE_EXT
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
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-12-05 9:55 UTC (permalink / raw)
To: Shawn Shao, tytso
Cc: oe-kbuild-all, Andreas Dilger, Baokun Li, Jan Kara, Ojaswin Mujoo,
Ritesh Harjani, Zhang Yi, linux-ext4
Hi Shawn,
kernel test robot noticed the following build errors:
[auto build test ERROR on tytso-ext4/dev]
[also build test ERROR on linus/master v7.4-rc5 next-20261204]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Shawn-Shao/ext4-check-fsnotify-permissions-before-MOVE_EXT/20261204-140054
base: https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
patch link: https://lore.kernel.org/r/20261204140055.832696-1-shawnq1%40163.com
patch subject: [PATCH] ext4: check fsnotify permissions before MOVE_EXT
config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20261205/20261205170004.DDiEANEH-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261205/20261205170004.DDiEANEH-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261205170004.DDiEANEH-lkp@intel.com/
All errors (new ones prefixed by >>, old ones prefixed by <<):
>> ERROR: modpost: fs/ext4/ext4.ko: symbol 'fsnotify_pre_content' undefined!
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [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