All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: syzbot <syzbot+5d34cc6474499a5ff516@syzkaller.appspotmail.com>
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [ntfs3?] KASAN: slab-use-after-free Read in chrdev_open
Date: Sat, 27 Apr 2024 18:44:25 +0800	[thread overview]
Message-ID: <20240427104425.3926-1-hdanton@sina.com> (raw)
In-Reply-To: <000000000000f386f90616fea5ef@google.com>

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
@@ -377,6 +377,9 @@ static int chrdev_open(struct inode *ino
 	struct cdev *new = NULL;
 	int ret = 0;
 
+	if (!igrab(inode))
+		return -ENXIO;
+
 	spin_lock(&cdev_lock);
 	p = inode->i_cdev;
 	if (!p) {
@@ -384,8 +387,10 @@ static int chrdev_open(struct inode *ino
 		int idx;
 		spin_unlock(&cdev_lock);
 		kobj = kobj_lookup(cdev_map, inode->i_rdev, &idx);
-		if (!kobj)
+		if (!kobj) {
+			iput(inode);
 			return -ENXIO;
+		}
 		new = container_of(kobj, struct cdev, kobj);
 		spin_lock(&cdev_lock);
 		/* Check i_cdev again in case somebody beat us to it while
@@ -401,8 +406,10 @@ static int chrdev_open(struct inode *ino
 		ret = -ENXIO;
 	spin_unlock(&cdev_lock);
 	cdev_put(new);
-	if (ret)
+	if (ret) {
+		iput(inode);
 		return ret;
+	}
 
 	ret = -ENXIO;
 	fops = fops_get(p->ops);
@@ -416,10 +423,12 @@ static int chrdev_open(struct inode *ino
 			goto out_cdev_put;
 	}
 
+	iput(inode);
 	return 0;
 
  out_cdev_put:
 	cdev_put(p);
+	iput(inode);
 	return ret;
 }
 
--

  parent reply	other threads:[~2024-04-27 10:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-26 12:00 [syzbot] [ntfs3?] KASAN: slab-use-after-free Read in chrdev_open syzbot
2024-04-26 20:57 ` syzbot
2024-04-27  2:06 ` Hillf Danton
2024-04-27  2:58   ` syzbot
2024-04-27  6:29 ` Hillf Danton
2024-04-27  6:52   ` syzbot
2024-04-27  9:18 ` Hillf Danton
2024-04-27  9:45   ` syzbot
2024-04-27 10:44 ` Hillf Danton [this message]
2024-04-27 10:58   ` syzbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240427104425.3926-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+5d34cc6474499a5ff516@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.