]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
fsnotify: Shutdown fsnotify before destroying sb's dcache
authorJan Kara <jack@suse.cz>
Wed, 15 Oct 2025 14:06:33 +0000 (16:06 +0200)
committerJan Kara <jack@suse.cz>
Fri, 23 Jan 2026 12:26:45 +0000 (13:26 +0100)
Currently fsnotify_sb_delete() was called after we have evicted
superblock's dcache and inode cache. This was done mainly so that we
iterate as few inodes as possible when removing inode marks. However, as
Jakub reported, this is problematic because for some filesystems
encoding of file handles uses sb->s_root which gets cleared as part of
dcache eviction. And either delayed fsnotify events or reading fdinfo
for fsnotify group with marks on fs being unmounted may trigger encoding
of file handles during unmount. So move shutdown of fsnotify subsystem
before shrinking of dcache.

Link: https://lore.kernel.org/linux-fsdevel/CAOQ4uxgXvwumYvJm3cLDFfx-TsU3g5-yVsTiG=6i8KS48dn0mQ@mail.gmail.com/
Reported-by: Jakub Acs <acsjakub@amazon.de>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/super.c

index 3d85265d14001d51524dbaec0778af8f12c048ac..9c13e68277dd616d9a69bffb79f225bb8936c4fc 100644 (file)
@@ -618,6 +618,7 @@ void generic_shutdown_super(struct super_block *sb)
        const struct super_operations *sop = sb->s_op;
 
        if (sb->s_root) {
+               fsnotify_sb_delete(sb);
                shrink_dcache_for_umount(sb);
                sync_filesystem(sb);
                sb->s_flags &= ~SB_ACTIVE;
@@ -629,9 +630,8 @@ void generic_shutdown_super(struct super_block *sb)
 
                /*
                 * Clean up and evict any inodes that still have references due
-                * to fsnotify or the security policy.
+                * to the security policy.
                 */
-               fsnotify_sb_delete(sb);
                security_sb_delete(sb);
 
                if (sb->s_dio_done_wq) {