sched/fair: Use 'unsigned long' for group_shares, group_runnable
hulk inclusion category: bugfix bugzilla: 13687 CVE: NA ---------------------------------------- group_share and group_runnable are tracked as 'unsigned long', however some functions using them as 'long' which is ultimately assigned back to 'unsigned long' variables in reweight_entity. Since there is not scope on using a different and signed type, this change improves code consistency and avoids further type conversions. More important, to prevent undefined behavior caused by overflow. Using them as 'long' resulted in the following stack trace (on top of v4.19.34) Signed-off-by: NCheng Jian <cj.chengjian@huawei.com> ============================================================================== UBSAN: Undefined behaviour in kernel/sched/fair.c:3055:9 signed integer overflow: 1048576 * 9144968455305 cannot be represented in type 'long int' dump_backtrace+0x0/0x338 show_stack+0x28/0x38 dump_stack+0xc8/0x100 ubsan_epilogue+0x18/0x6c handle_overflow+0x170/0x1c0 __ubsan_handle_mul_overflow+0x34/0x44 update_cfs_group+0x244/0x248 dequeue_entity+0x478/0x12c0 dequeue_task_fair+0x6c/0xd98 __sched_setscheduler+0x320/0xdf0 _sched_setscheduler+0xf4/0x158 do_sched_setscheduler+0x118/0x1a0 __arm64_sys_sched_setscheduler+0x50/0x70 el0_svc_common+0xf4/0x258 el0_svc_handler+0x50/0xa8 ============================================================================== UBSAN: Undefined behaviour in kernel/sched/fair.c:3111:11 signed integer overflow: 97833896519391 * 952504 cannot be represented in type 'long int' Call trace: dump_backtrace+0x0/0x338 show_stack+0x28/0x38 dump_stack+0xc8/0x100 ubsan_epilogue+0x18/0x6c handle_overflow+0x170/0x1c0 __ubsan_handle_mul_overflow+0x34/0x44 update_cfs_group+0x210/0x248 enqueue_entity+0x7b4/0x1868 enqueue_task_fair+0x12c/0xe70 __sched_setscheduler+0x4cc/0xdf0 _sched_setscheduler+0xf4/0x158 do_sched_setscheduler+0x118/0x1a0 __arm64_sys_sched_setscheduler+0x50/0x70 el0_svc_common+0xf4/0x258 el0_svc_handler+0x50/0xa8 el0_svc+0x8/0xc ============================================================================== Cc: stable@vger.kernel.org Signed-off-by: NCheng Jian <cj.chengjian@huawei.com> Signed-off-by: NCheng Jian <cj.chengjian@huawei.com> Reviewed-by: NYang Yingliang <yangyingliang@huawei.com> Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Showing
想要评论请 注册 或 登录