提交 1d29740b 编写于 作者: Z Zheng Zucheng 提交者: Yang Yingliang

sched: Fix throttle offline task trigger panic

hulk inclusion
category: bugfix
bugzilla: 51828, https://gitee.com/openeuler/kernel/issues/I4K96G
CVE: NA

--------------------------------

offline task invokes sched_setscheduler interface to change the
scheduling policy to SCHED_OTHER, trigger a system panic.
Signed-off-by: NZheng Zucheng <zhengzucheng@huawei.com>
Reviewed-by: NChen Hui <judy.chenhui@huawei.com>
Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 2f9034b2
......@@ -4333,6 +4333,18 @@ static int __sched_setscheduler(struct task_struct *p,
}
change:
#ifdef CONFIG_QOS_SCHED
/*
* If the scheduling policy of an offline task is set to a policy
* other than SCHED_IDLE, the online task preemption will be invalid,
* so return -EINVAL in this case.
*/
if (unlikely(task_group(p)->qos_level == -1 && !idle_policy(policy))) {
task_rq_unlock(rq, p, &rf);
return -EINVAL;
}
#endif
if (user) {
#ifdef CONFIG_RT_GROUP_SCHED
/*
......
......@@ -6991,7 +6991,8 @@ static bool check_qos_cfs_rq(struct cfs_rq *cfs_rq)
return false;
if (cfs_rq && cfs_rq->tg->qos_level < 0 &&
!sched_idle_cpu(cpu_of(rq_of(cfs_rq)))) {
!sched_idle_cpu(cpu_of(rq_of(cfs_rq))) &&
cfs_rq->h_nr_running == cfs_rq->idle_h_nr_running) {
throttle_qos_cfs_rq(cfs_rq);
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册