Commit ce9aaa3
sched_ext: Read scx_root under scx_cgroup_ops_rwsem in cgroup setters
[ Upstream commit 80afd4c ]
scx_group_set_{weight,idle,bandwidth}() cache scx_root before acquiring
scx_cgroup_ops_rwsem, so the pointer can be stale by the time the op runs.
If the loaded scheduler is disabled and freed (via RCU work) and another is
enabled between the naked load and the rwsem acquire, the reader sees
scx_cgroup_enabled=true (the new scheduler's) but dereferences the freed one
- UAF on SCX_HAS_OP(sch, ...) / SCX_CALL_OP(sch, ...).
scx_cgroup_enabled is toggled only under scx_cgroup_ops_rwsem write
(scx_cgroup_{init,exit}), so reading scx_root inside the rwsem read section
correlates @sch with the enabled snapshot.
Fixes: a5bd6ba ("sched_ext: Use cgroup_lock/unlock() to synchronize against cgroup operations")
Cc: stable@vger.kernel.org # v6.18+
Reported-by: Chris Mason <clm@meta.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Andrea Righi <arighi@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 30cf8e0 commit ce9aaa3
1 file changed
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3251 | 3251 | | |
3252 | 3252 | | |
3253 | 3253 | | |
3254 | | - | |
| 3254 | + | |
3255 | 3255 | | |
3256 | 3256 | | |
| 3257 | + | |
3257 | 3258 | | |
3258 | 3259 | | |
3259 | 3260 | | |
| |||
3267 | 3268 | | |
3268 | 3269 | | |
3269 | 3270 | | |
3270 | | - | |
| 3271 | + | |
3271 | 3272 | | |
3272 | 3273 | | |
| 3274 | + | |
3273 | 3275 | | |
3274 | 3276 | | |
3275 | 3277 | | |
| |||
3284 | 3286 | | |
3285 | 3287 | | |
3286 | 3288 | | |
3287 | | - | |
| 3289 | + | |
3288 | 3290 | | |
3289 | 3291 | | |
| 3292 | + | |
3290 | 3293 | | |
3291 | 3294 | | |
3292 | 3295 | | |
| |||
0 commit comments