summaryrefslogtreecommitdiffstats
path: root/fs/super.c
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2024-04-16 20:14:52 +0200
committerJan Kara <jack@suse.cz>2024-04-17 15:06:50 +0200
commit795bb82d12a16a4cee42845b0e4c7e3276574e5d (patch)
treee82347600c4058d7e4c08ca42d7afd9af065405a /fs/super.c
parentfsnotify: optimize the case of no permission event watchers (diff)
downloadlinux-795bb82d12a16a4cee42845b0e4c7e3276574e5d.tar.xz
linux-795bb82d12a16a4cee42845b0e4c7e3276574e5d.zip
fsnotify: fix UAF from FS_ERROR event on a shutting down filesystem
Protect against use after free when filesystem calls fsnotify_sb_error() during fs shutdown. Move freeing of sb->s_fsnotify_info to destroy_super_work(), because it may be accessed from fs shutdown context. Reported-by: syzbot+5e3f9b2a67b45f16d4e6@syzkaller.appspotmail.com Suggested-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/linux-fsdevel/20240416173211.4lnmgctyo4jn5fha@quack3/ Fixes: 07a3b8d0bf72 ("fsnotify: lazy attach fsnotify_sb_info state to sb") Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz> Message-Id: <20240416181452.567070-1-amir73il@gmail.com>
Diffstat (limited to 'fs/super.c')
-rw-r--r--fs/super.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/super.c b/fs/super.c
index 71d9779c42b1..81656c7807db 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -274,6 +274,7 @@ static void destroy_super_work(struct work_struct *work)
{
struct super_block *s = container_of(work, struct super_block,
destroy_work);
+ fsnotify_sb_free(s);
security_sb_free(s);
put_user_ns(s->s_user_ns);
kfree(s->s_subtype);