Re: [PATCH sched_ext/for-7.0-fixes] sched_ext: Fix invalid kobj cast in scx_uevent()

From: Tejun Heo

Date: Sun Mar 22 2026 - 16:01:15 EST


Hello,

The fix itself looks correct but could you please update a few things for v2?

- The patch description says that kset_register() of the sched_ext kset
itself triggers this during init. That's not actually the case -
kset_create_and_add() sets kobj.kset = NULL on the kset's own kobject,
so kobject_uevent_env() can't find a kset and the uevent is silently
dropped.

The actual trigger is the sub-scheduler kset created at
scx_alloc_and_add_sched() -> kset_create_and_add("sub", NULL,
&sch->kobj). That sub-kset's kobject has sch->kobj as its parent, and
sch->kobj.kset = scx_kset, so the uevent walk finds scx_kset and calls
scx_uevent() with the sub-kset's kobject which isn't a struct scx_sched.

Please update the description to reflect this.

- Move the variable declaration to the top of the function. There's no
functional difference but the current placement looks messy - just put
the ktype check between the declaration and the use.

- Add a comment explaining why the check is needed - that scx_uevent()
can be reached by both scx_sched kobjects (scx_ktype) and sub-scheduler
kset kobjects (kset_ktype) through the parent chain walk, and we need to
filter out the latter.

Thanks.

--
tejun