[PATCH OLK-6.6] xsched: prevent linked list corruption in RT priority updates
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IDB5TR ----------------------------------------- Add scheduling class validation in xsched_rt_prio_set() to ensure only RT-scheduled tasks can perform RT priority modifications. Previously, CFS tasks could trigger xse_rt_del() operations via sys_xsched_setattr, corrupting CFS runqueue linked lists. The fix checks xse->class == &rt_xsched_class before any RT scheduler operations, maintaining proper separation between CFS and RT scheduling domains. Fixes: 832cfa264d7c ("xsched: add xsched_{set,get}attr syscall") Signed-off-by: Liu Kai <liukai284@huawei.com> --- kernel/xsched/rt.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/kernel/xsched/rt.c b/kernel/xsched/rt.c index 498d5ac618a1..db7d97fed787 100644 --- a/kernel/xsched/rt.c +++ b/kernel/xsched/rt.c @@ -168,17 +168,20 @@ void xsched_rt_prio_set(pid_t tgid, unsigned int prio) mutex_lock(&xcu->xcu_lock); ctx = ctx_find_by_tgid_and_xcu(tgid, xcu); - if (ctx) { - xse = &ctx->xse; - xse->rt.prio = clamp_t(unsigned int, prio, XSE_PRIO_HIGH, XSE_PRIO_LOW); - if (xse->on_rq) { - xse_rt_del(xse); - xse_rt_add(xse, xcu); - } + if (!ctx || ctx->xse.class != &rt_xsched_class) { + mutex_unlock(&xcu->xcu_lock); + mutex_unlock(&xcu->ctx_list_lock); + continue; + } + + xse = &ctx->xse; + xse->rt.prio = clamp_t(unsigned int, prio, XSE_PRIO_HIGH, XSE_PRIO_LOW); + if (xse->on_rq) { + xse_rt_del(xse); + xse_rt_add(xse, xcu); } mutex_unlock(&xcu->xcu_lock); mutex_unlock(&xcu->ctx_list_lock); } } - -- 2.34.1
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/19683 邮件列表地址:https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/KOE... FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/19683 Mailing list address: https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/KOE...
participants (2)
-
Liu Kai -
patchwork bot