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

From: Hillf Danton
Date: Sat Apr 27 2024 - 05:18:28 EST


On Fri, 26 Apr 2024 05:00:21 -0700
> syzbot found the following issue on:
>
> HEAD commit: e33c4963bf53 Merge tag 'nfsd-6.9-5' of git://git.kernel.or..
> git tree: upstream
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12499380980000

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

--- x/fs/char_dev.c
+++ y/fs/char_dev.c
@@ -387,6 +387,8 @@ static int chrdev_open(struct inode *ino
if (!kobj)
return -ENXIO;
new = container_of(kobj, struct cdev, kobj);
+ if (!cdev_get(new))
+ return -ENXIO;
spin_lock(&cdev_lock);
/* Check i_cdev again in case somebody beat us to it while
we dropped the lock. */
--