Re: [syzbot] [ntfs3?] KASAN: slab-use-after-free Read in chrdev_open
From: Hillf Danton
Date: Sun Jun 16 2024 - 07:16:14 EST
#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 83a7eefedc9b
--- x/fs/open.c
+++ y/fs/open.c
@@ -35,6 +35,8 @@
#include <linux/filelock.h>
#include "internal.h"
+#include "mount.h"
+#include "pnode.h"
int do_truncate(struct mnt_idmap *idmap, struct dentry *dentry,
loff_t length, unsigned int time_attrs, struct file *filp)
@@ -952,6 +954,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;
--