Commit 94a4acfe authored by Chen Ridong's avatar Chen Ridong Committed by Tejun Heo
Browse files

cgroup/psi: Set of->priv to NULL upon file release

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: default avatarChen Ridong <chenridong@huawei.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 79f919a8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4182,6 +4182,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,