[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250822070715.1565236-3-chenridong@huaweicloud.com>
Date: Fri, 22 Aug 2025 07:07:15 +0000
From: Chen Ridong <chenridong@...weicloud.com>
To: gregkh@...uxfoundation.org,
tj@...nel.org,
hannes@...xchg.org,
mkoutny@...e.com,
peterz@...radead.org,
zhouchengming@...edance.com
Cc: linux-kernel@...r.kernel.org,
cgroups@...r.kernel.org,
lujialin4@...wei.com,
chenridong@...wei.com,
libaokun1@...wei.com
Subject: [PATCH v2 2/2] cgroup/psi: Set of->priv to NULL upon file release
From: Chen Ridong <chenridong@...wei.com>
Setting of->priv to NULL when the file is released enables earlier bug
detection. This allows potential bugs to manifest as NULL pointer
dereferences rather than use-after-free errors[1], which are generally more
difficult to diagnose.
[1] https://lore.kernel.org/cgroups/38ef3ff9-b380-44f0-9315-8b3714b0948d@huaweicloud.com/T/#m8a3b3f88f0ff3da5925d342e90043394f8b2091b
Signed-off-by: Chen Ridong <chenridong@...wei.com>
---
kernel/cgroup/cgroup.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 312c6a8b55bb..d8b82afed181 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -4159,6 +4159,7 @@ static void cgroup_file_release(struct kernfs_open_file *of)
cft->release(of);
put_cgroup_ns(ctx->ns);
kfree(ctx);
+ of->priv = NULL;
}
static ssize_t cgroup_file_write(struct kernfs_open_file *of, char *buf,
--
2.34.1
Powered by blists - more mailing lists