mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Edward Adam Davis <eadavis@qq.com>
To: chenridong@huaweicloud.com
Cc: cgroups@vger.kernel.org, eadavis@qq.com, hannes@cmpxchg.org,
	linux-kernel@vger.kernel.org, mkoutny@suse.com,
	syzbot+33e571025d88efd1312c@syzkaller.appspotmail.com,
	syzkaller-bugs@googlegroups.com, tj@kernel.org
Subject: Re: [PATCH v2] sched/psi: fix race between file release and pressure write
Date: Mon, 13 Apr 2026 10:11:41 +0800	[thread overview]
Message-ID: <tencent_71D4D2F5C6460999EEE5AEC14C8767C74606@qq.com> (raw)
In-Reply-To: <b586bd09-8b47-415d-a183-7385a678c723@huaweicloud.com>

On Mon, 13 Apr 2026 09:51:19 +0800, Chen Ridong wrote:
>On 2026/4/11 12:25, Edward Adam Davis wrote:
>> On Fri, 10 Apr 2026 09:14:05 -1000, Tejun Heo wrote:
>>>>  static ssize_t pressure_write(struct kernfs_open_file *of, char *buf,
>>>>  			      size_t nbytes, enum psi_res res)
>>>>  {
>>>> -	struct cgroup_file_ctx *ctx = of->priv;
>>>> +	struct cgroup_file_ctx *ctx;
>>>>  	struct psi_trigger *new;
>>>>  	struct cgroup *cgrp;
>>>>  	struct psi_group *psi;
>>>> +	ssize_t ret = 0;
>>>>
>>>>  	cgrp = cgroup_kn_lock_live(of->kn, false);
>>>>  	if (!cgrp)
>>>>  		return -ENODEV;
>>>>
>>>> +	ctx = of->priv;
>>>> +	if (!ctx) {
>>>
>>> This test likely isn't necessary but that's pre-existing.
>> Where?
>> Are you referring to the check for of->released within:
>> 'kernfs_fop_write_iter()->kernfs_get_active_of()'? This check is not
>> performed under the protection of the cgroup_mutex; consequently, it
>> is susceptible to race conditions, rendering the value unreliable, as
>> it could be updated at any moment.
>>>
>>>> +		ret = -ENODEV;
>>>> +		goto out_unlock;
>>>> +	}
>>>> +
>>>>  	cgroup_get(cgrp);
>>>
>>> We don't need get/put if we don't drop the mutex, right?
>> I believe that is indeed the case; the cgroup_get() call here is intended
>> to facilitate subsequent operations, such as executing an smp store.
>> 
>
>Sorry, I don't quite understand why get/put is needed. Could you elaborate a bit
>more?
Oh, I had overlooked the fact that acquiring the live kn lock simultaneously
performs a cgroup_get; therefore, after extending the scope of the mutex,
the original explicit get/put operations are no longer necessary. I will
issue a new version of the patch shortly to address this specific point.

Edward
BR


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

Thread overview: 44+ 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-13  1:51             ` [PATCH v2] " Chen Ridong
2026-04-13  2:11               ` Edward Adam Davis [this message]
2026-04-13  2:44                 ` [PATCH v4] " Edward Adam Davis
2026-04-14  2:29                   ` Chen Ridong
2026-04-14  4:08                     ` Edward Adam Davis
2026-04-14  6:15                       ` [PATCH v5] " Edward Adam Davis
2026-04-15  0:48                         ` Chen Ridong
2026-04-17 17:37                         ` Tejun Heo
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
2026-04-11  3:26   ` syzbot
2026-04-12  6:50 ` Hillf Danton
2026-04-12  7:14   ` syzbot
2026-04-13  2:20 ` Edward Adam Davis
2026-04-13  2:44   ` 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=tencent_71D4D2F5C6460999EEE5AEC14C8767C74606@qq.com \
    --to=eadavis@qq.com \
    --cc=cgroups@vger.kernel.org \
    --cc=chenridong@huaweicloud.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkoutny@suse.com \
    --cc=syzbot+33e571025d88efd1312c@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=tj@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®