Re: [syzbot] [ntfs3?] KASAN: slab-use-after-free Read in chrdev_open
From: Hillf Danton
Date: Tue May 28 2024 - 07:14:28 EST
#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
--- x/fs/open.c
+++ y/fs/open.c
@@ -952,7 +952,13 @@ static int do_dentry_open(struct file *f
if (!open)
open = f->f_op->open;
if (open) {
+ struct super_block *sb = inode->i_sb;
+
+ error = -ENODEV;
+ if (!super_trylock_shared(sb))
+ goto cleanup_all;
error = open(inode, f);
+ up_read(&sb->s_umount);
if (error)
goto cleanup_all;
}
--