public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hillf Danton <hdanton@sina.com>
To: syzbot <syzbot+33e571025d88efd1312c@syzkaller.appspotmail.com>
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [cgroups?] KASAN: slab-use-after-free Read in pressure_write
Date: Sat, 11 Apr 2026 11:10:43 +0800	[thread overview]
Message-ID: <20260411031045.1713-1-hdanton@sina.com> (raw)
In-Reply-To: <69d779b0.a00a0220.468cb.0018.GAE@google.com>

> Date: Thu, 09 Apr 2026 03:04:32 -0700	[thread overview]
> Hello,
> 
> syzbot found the following issue on:
> 
> HEAD commit:    591cd656a1bf Linux 7.0-rc7
> git tree:       upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=114a36ba580000
> kernel config:  https://syzkaller.appspot.com/x/.config?x=45cb3c58fd963c27
> dashboard link: https://syzkaller.appspot.com/bug?extid=33e571025d88efd1312c
> compiler:       Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
> syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=16cb33da580000
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=12648bd6580000

#syz test

--- x/fs/kernfs/file.c
+++ y/fs/kernfs/file.c
@@ -298,6 +298,7 @@ static ssize_t kernfs_fop_read_iter(stru
 	return kernfs_file_read_iter(iocb, iter);
 }
 
+static DEFINE_MUTEX(drain_mutex);
 /*
  * Copy data in from userland and pass it to the matching kernfs write
  * operation.
@@ -322,13 +323,17 @@ static ssize_t kernfs_fop_write_iter(str
 		len = min_t(size_t, len, PAGE_SIZE);
 	}
 
+	if (!mutex_trylock(&drain_mutex))
+		return -EINVAL;
 	buf = of->prealloc_buf;
 	if (buf)
 		mutex_lock(&of->prealloc_mutex);
 	else
 		buf = kmalloc(len + 1, GFP_KERNEL);
-	if (!buf)
+	if (!buf) {
+		mutex_unlock(&drain_mutex);
 		return -ENOMEM;
+	}
 
 	if (copy_from_iter(buf, len, iter) != len) {
 		len = -EFAULT;
@@ -364,6 +369,7 @@ out_free:
 		mutex_unlock(&of->prealloc_mutex);
 	else
 		kfree(buf);
+	mutex_unlock(&drain_mutex);
 	return len;
 }
 
@@ -814,10 +820,12 @@ void kernfs_drain_open_files(struct kern
 	struct kernfs_open_file *of;
 	struct mutex *mutex;
 
+	mutex_lock(&drain_mutex);
 	mutex = kernfs_open_file_mutex_lock(kn);
 	on = kernfs_deref_open_node_locked(kn);
 	if (!on) {
 		mutex_unlock(mutex);
+		mutex_unlock(&drain_mutex);
 		return;
 	}
 
@@ -836,6 +844,7 @@ void kernfs_drain_open_files(struct kern
 
 	WARN_ON_ONCE(on->nr_mmapped || on->nr_to_release);
 	mutex_unlock(mutex);
+	mutex_unlock(&drain_mutex);
 }
 
 /*
--

  parent reply	other threads:[~2026-04-11  3:13 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-09 10:04 [syzbot] [cgroups?] KASAN: slab-use-after-free Read in pressure_write syzbot
2026-04-09 13:06 ` Edward Adam Davis
2026-04-09 13:27   ` syzbot
2026-04-09 13:35 ` Edward Adam Davis
2026-04-09 13:50   ` syzbot
2026-04-09 14:02 ` Edward Adam Davis
2026-04-09 14:28   ` syzbot
2026-04-10  0:56 ` Edward Adam Davis
2026-04-10  1:19   ` syzbot
2026-04-10  4:00 ` Hillf Danton
2026-04-10  4:17   ` syzbot
2026-04-10  4:00 ` [PATCH] sched/psi: fix race between file release and pressure write Edward Adam Davis
2026-04-10  9:00   ` Chen Ridong
2026-04-10  9:45     ` Edward Adam Davis
2026-04-10 12:39       ` [PATCH v2] " Edward Adam Davis
2026-04-10 19:14         ` Tejun Heo
2026-04-11  4:25           ` Edward Adam Davis
2026-04-11  7:39             ` Tejun Heo
2026-04-11  8:29               ` Edward Adam Davis
2026-04-11 20:40                 ` Tejun Heo
2026-04-12  2:32                   ` Edward Adam Davis
2026-04-12  2:47                     ` [PATCH v3] " Edward Adam Davis
2026-04-10 10:00 ` [syzbot] [cgroups?] KASAN: slab-use-after-free Read in pressure_write Edward Adam Davis
2026-04-10 10:25   ` syzbot
2026-04-10 10:48 ` Edward Adam Davis
2026-04-10 11:10   ` syzbot
2026-04-10 12:02 ` Hillf Danton
2026-04-10 12:27   ` syzbot
2026-04-10 12:13 ` Edward Adam Davis
2026-04-10 12:40   ` syzbot
2026-04-11  3:10 ` Hillf Danton [this message]
2026-04-11  3:26   ` syzbot
2026-04-12  6:50 ` Hillf Danton
2026-04-12  7:14   ` 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=20260411031045.1713-1-hdanton@sina.com \
    --to=hdanton@sina.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+33e571025d88efd1312c@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox