]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
sched_ext: Remove redundant css_put() in scx_cgroup_init()
authorCheng-Yang Chou <yphbchou0911@gmail.com>
Tue, 3 Mar 2026 14:35:30 +0000 (22:35 +0800)
committerTejun Heo <tj@kernel.org>
Tue, 3 Mar 2026 16:22:37 +0000 (06:22 -1000)
The iterator css_for_each_descendant_pre() walks the cgroup hierarchy
under cgroup_lock(). It does not increment the reference counts on
yielded css structs.

According to the cgroup documentation, css_put() should only be used
to release a reference obtained via css_get() or css_tryget_online().
Since the iterator does not use either of these to acquire a reference,
calling css_put() in the error path of scx_cgroup_init() causes a
refcount underflow.

Remove the unbalanced css_put() to prevent a potential Use-After-Free
(UAF) vulnerability.

Fixes: 819513666966 ("sched_ext: Add cgroup support")
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/sched/ext.c

index 2ba69b3023688877afd45036e893d5a47cdbde63..eab6e09b644254a36510d735b566b5f8a6c47928 100644 (file)
@@ -3589,7 +3589,6 @@ static int scx_cgroup_init(struct scx_sched *sch)
                ret = SCX_CALL_OP_RET(sch, SCX_KF_UNLOCKED, cgroup_init, NULL,
                                      css->cgroup, &args);
                if (ret) {
-                       css_put(css);
                        scx_error(sch, "ops.cgroup_init() failed (%d)", ret);
                        return ret;
                }