All of lore.kernel.org
 help / color / mirror / Atom feed
From: syzbot <syzbot+5e3f9b2a67b45f16d4e6@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [syzbot] Re: [syzbot] [ext4?] KASAN: slab-use-after-free Read in fsnotify
Date: Fri, 12 Apr 2024 18:40:45 -0700	[thread overview]
Message-ID: <000000000000276bf20615f07a61@google.com> (raw)
In-Reply-To: <00000000000042c9190615cdb315@google.com>

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.

***

Subject: Re: [syzbot] [ext4?] KASAN: slab-use-after-free Read in fsnotify
Author: hdanton@sina.com

On Thu, 11 Apr 2024 01:11:20 -0700
> syzbot found the following issue on:
> 
> HEAD commit:    6ebf211bb11d Add linux-next specific files for 20240410
> git tree:       linux-next
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1621af9d180000

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git  6ebf211bb11d

--- x/fs/notify/fsnotify.c
+++ y/fs/notify/fsnotify.c
@@ -101,8 +101,8 @@ void fsnotify_sb_delete(struct super_blo
 	wait_var_event(fsnotify_sb_watched_objects(sb),
 		       !atomic_long_read(fsnotify_sb_watched_objects(sb)));
 	WARN_ON(fsnotify_sb_has_priority_watchers(sb, FSNOTIFY_PRIO_CONTENT));
-	WARN_ON(fsnotify_sb_has_priority_watchers(sb,
-						  FSNOTIFY_PRIO_PRE_CONTENT));
+	WARN_ON(fsnotify_sb_has_priority_watchers(sb, FSNOTIFY_PRIO_PRE_CONTENT));
+	synchronize_srcu(&fsnotify_mark_srcu);
 	kfree(sbinfo);
 }
 
@@ -499,7 +499,7 @@ int fsnotify(__u32 mask, const void *dat
 {
 	const struct path *path = fsnotify_data_path(data, data_type);
 	struct super_block *sb = fsnotify_data_sb(data, data_type);
-	struct fsnotify_sb_info *sbinfo = fsnotify_sb_info(sb);
+	struct fsnotify_sb_info *sbinfo;
 	struct fsnotify_iter_info iter_info = {};
 	struct mount *mnt = NULL;
 	struct inode *inode2 = NULL;
@@ -529,6 +529,8 @@ int fsnotify(__u32 mask, const void *dat
 		inode2_type = FSNOTIFY_ITER_TYPE_PARENT;
 	}
 
+	iter_info.srcu_idx = srcu_read_lock(&fsnotify_mark_srcu);
+	sbinfo = fsnotify_sb_info(sb);
 	/*
 	 * Optimization: srcu_read_lock() has a memory barrier which can
 	 * be expensive.  It protects walking the *_fsnotify_marks lists.
@@ -539,8 +541,10 @@ int fsnotify(__u32 mask, const void *dat
 	if ((!sbinfo || !sbinfo->sb_marks) &&
 	    (!mnt || !mnt->mnt_fsnotify_marks) &&
 	    (!inode || !inode->i_fsnotify_marks) &&
-	    (!inode2 || !inode2->i_fsnotify_marks))
-		return 0;
+	    (!inode2 || !inode2->i_fsnotify_marks)) {
+		ret = 0;
+		goto out;
+	}
 
 	marks_mask = sb->s_fsnotify_mask;
 	if (mnt)
@@ -558,10 +562,10 @@ int fsnotify(__u32 mask, const void *dat
 	 * Otherwise, return if none of the marks care about this type of event.
 	 */
 	test_mask = (mask & ALL_FSNOTIFY_EVENTS);
-	if (!(test_mask & marks_mask))
-		return 0;
-
-	iter_info.srcu_idx = srcu_read_lock(&fsnotify_mark_srcu);
+	if (!(test_mask & marks_mask)) {
+		ret = 0;
+		goto out;
+	}
 
 	if (sbinfo) {
 		iter_info.marks[FSNOTIFY_ITER_TYPE_SB] =
--

  parent reply	other threads:[~2024-04-13  1:40 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-11  8:11 [syzbot] [ext4?] KASAN: slab-use-after-free Read in fsnotify syzbot
2024-04-11 12:13 ` Jan Kara
2024-04-11 16:07   ` Amir Goldstein
2024-04-11 19:25     ` Gabriel Krisman Bertazi
2024-04-11 20:27       ` Khazhy Kumykov
2024-04-12 10:24         ` Amir Goldstein
2024-04-11 20:06     ` syzbot
2024-04-12  7:52       ` Amir Goldstein
2024-04-12 14:30         ` syzbot
2024-04-12 14:32           ` Aleksandr Nogikh
2024-04-13  1:40 ` Hillf Danton
2024-04-13  6:42   ` Amir Goldstein
2024-04-13  8:58     ` syzbot
2024-04-13  8:40   ` syzbot
2024-04-13  1:40 ` syzbot [this message]
2024-04-13  6:42 ` [syzbot] " syzbot
2024-04-13  8:45   ` Hillf Danton
2024-04-13  9:32     ` Amir Goldstein
2024-04-13 12:04       ` Hillf Danton
2024-04-15 14:03       ` [syzbot] " Jan Kara
2024-04-15 14:47         ` Amir Goldstein
2024-04-16 10:47           ` Amir Goldstein
2024-04-17  2:03             ` syzbot
2024-04-16 13:22           ` [syzbot] " Jan Kara
2024-04-16 16:27             ` Amir Goldstein
2024-04-16 17:32               ` Jan Kara
2024-04-16 17:55                 ` Amir Goldstein
2024-04-16 22:50                 ` Hillf Danton

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=000000000000276bf20615f07a61@google.com \
    --to=syzbot+5e3f9b2a67b45f16d4e6@syzkaller.appspotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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.