hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/8423 -------------------------------- Introduce a check for the is_offline flag at the beginning of the work function to prevent scheduling or accounting operations on cgroups that have already been offlined. This avoids potential use-after-free, inconsistent state updates, or unnecessary processing on entities that are no longer part of the active hierarchy. Fixes: aafde051ac61 ("xsched: Add support for CFS quota for cgroups") Signed-off-by: Liu Kai <liukai284@huawei.com> --- kernel/xsched/cfs_quota.c | 5 +++-- kernel/xsched/cgroup.c | 8 ++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/kernel/xsched/cfs_quota.c b/kernel/xsched/cfs_quota.c index 9de74d547931..6a1089abbaef 100644 --- a/kernel/xsched/cfs_quota.c +++ b/kernel/xsched/cfs_quota.c @@ -79,9 +79,10 @@ static void xsched_group_unthrottle(struct xsched_group *xg) void xsched_quota_refill(struct work_struct *work) { - struct xsched_group *xg; + struct xsched_group *xg = container_of(work, struct xsched_group, refill_work); - xg = container_of(work, struct xsched_group, refill_work); + if (READ_ONCE(xg->is_offline)) + return; spin_lock(&xg->lock); xg->runtime = max((xg->runtime - xg->quota), (s64)0); diff --git a/kernel/xsched/cgroup.c b/kernel/xsched/cgroup.c index 94df3005bf36..d780eb97ec47 100644 --- a/kernel/xsched/cgroup.c +++ b/kernel/xsched/cgroup.c @@ -242,14 +242,10 @@ static void xcu_css_free(struct cgroup_subsys_state *css) static void delay_xcu_cg_set_file_show_workfn(struct work_struct *work) { - struct xsched_group *xg; - - xg = container_of(work, struct xsched_group, file_show_work); + struct xsched_group *xg = container_of(work, struct xsched_group, file_show_work); - if (!xg) { - XSCHED_ERR("xsched_group cannot be null @ %s", __func__); + if (READ_ONCE(xg->is_offline)) return; - } for (int i = 0; i < XCUCG_SET_FILE_RETRY_COUNT; i++) { if (!xcu_cg_set_file_show(xg, xg->sched_class)) -- 2.34.1