Re: [syzbot] [ntfs3?] KASAN: slab-use-after-free Read in chrdev_open

From: Hillf Danton
Date: Sun Jun 16 2024 - 02:33:38 EST


#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 83a7eefedc9b

--- x/fs/open.c
+++ y/fs/open.c
@@ -952,6 +952,12 @@ static int do_dentry_open(struct file *f
if (!open)
open = f->f_op->open;
if (open) {
+ struct mount *mnt = real_mount(f->f_path.mnt);
+ error = -ENODEV;
+ if (mnt->mnt.mnt_flags & MNT_DOOMED)
+ goto cleanup_all;
+ if (mnt_get_count(mnt) < 2)
+ goto cleanup_all;
error = open(inode, f);
if (error)
goto cleanup_all;
--