Re: [PATCH] fair sched: Fix signed integer overflow problem in fair sched

From: Peter Zijlstra
Date: Thu Apr 02 2020 - 11:33:48 EST


On Thu, Apr 02, 2020 at 02:52:40PM +0000, hejingxian wrote:
> During execution applications in my arm64 virtual machine with UBSAN, the UBSAN error message is showed:
> UBSAN: Undefined behaviour in kernel/sched/fair.c
> signed integer overflow:
> 166982794708445 * 64885 cannot be represented in type 'long int'
> CPU: 40 PID: 4134072 Comm: stress-ng-sched Kdump: loaded Tainted: G B W OE 4.19.95-vhulk2002.1.0.0041.eulerosv2r8.aarch64 #1
> Hardware name: Huawei TaiShan 2280 V2/BC82AMDD, BIOS 0.98 08/25/2019
> Call trace:
> dump_backtrace+0x0/0x310
> show_stack+0x28/0x38
> dump_stack+0xd8/0x108
> ubsan_epilogue+0x1c/0x94
> handle_overflow+0x14c/0x19c
> __ubsan_handle_mul_overflow+0x34/0x44
> task_numa_find_cpu+0xdec/0x1058
> task_numa_migrate+0x3ac/0x12d0
> task_numa_fault+0x4f0/0x5f0
> do_numa_page+0x480/0x848
> __handle_mm_fault+0x8d8/0x9b0
> handle_mm_fault+0x280/0x460
> do_page_fault+0x3ec/0x890
> do_translation_fault+0xe4/0x100
> do_mem_abort+0xc0/0x1b0
> el0_da+0x24/0x28
>
> The multiplication of signed long integers in load_too_imbalanced may
> occur overflow, then we use unsigned long integers instead of signed integers.

NAK, UBSAN is smoking dope, and you patch is actively wrong.