[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ql5573r2nbex53fyygwczyjipmtalc22n3hxxzmqwi2sgadodt@a5pesn5gunf2>
Date: Fri, 15 Aug 2025 16:42:06 +0200
From: Michal Koutný <mkoutny@...e.com>
To: Greg KH <gregkh@...uxfoundation.org>
Cc: Chen Ridong <chenridong@...weicloud.com>, tj@...nel.org,
hannes@...xchg.org, peterz@...radead.org, zhouchengming@...edance.com,
linux-kernel@...r.kernel.org, cgroups@...r.kernel.org, lujialin4@...wei.com,
chenridong@...wei.com
Subject: Re: [PATCH] kernfs: Fix UAF in PSI polling when open file is released
On Fri, Aug 15, 2025 at 08:11:39AM +0200, Greg KH <gregkh@...uxfoundation.org> wrote:
> > diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
> > index a6c692cac616..d5d01f0b9392 100644
> > --- a/fs/kernfs/file.c
> > +++ b/fs/kernfs/file.c
> > @@ -852,7 +852,7 @@ static __poll_t kernfs_fop_poll(struct file *filp, poll_table *wait)
> > struct kernfs_node *kn = kernfs_dentry_node(filp->f_path.dentry);
> > __poll_t ret;
> >
> > - if (!kernfs_get_active(kn))
> > + if (of->released || !kernfs_get_active(kn))
>
> I can see why the cgroup change is needed,
I don't see it that much. of->priv isn't checked in cgroup code anywhere
so it isn't helpful zeroing. As Ridong writes it may trade UaF for NULL
pointer deref :-/ (Additionally, same zeroing would be needed in error
path in cgroup_file_open().)
I _think_ the place to cleanup would be in
@@ -3978,6 +3978,8 @@ static ssize_t cgroup_pressure_write(struct kernfs_open_file *of,
psi->enabled = enable;
if (enable)
psi_cgroup_restart(psi);
+ else
+ psi_trigger_destroy(???);
}
cgroup_kn_unlock(of->kn);
The issue is that cgroup_pressure_write doesn't know all possible
triggers to be cancelled. (The fix with of->released would only
sanitize effect but not the cause IMO.)
HTH,
Michal
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists