]> git.baikalelectronics.ru Git - kernel.git/commit
sched/fair: Fix multiplication overflow on 32-bit systems
authorAndrey Ryabinin <aryabinin@virtuozzo.com>
Mon, 14 Dec 2015 12:47:23 +0000 (15:47 +0300)
committerIngo Molnar <mingo@kernel.org>
Wed, 6 Jan 2016 10:01:05 +0000 (11:01 +0100)
commit0bcbb8da063c8237632d4445e8a7f34fa9c1075d
tree75d4c8d90c3dcde20942e77a6542fe1d4620d258
parent73f1ca524dcfacb1c1094981a15020ca7d781438
sched/fair: Fix multiplication overflow on 32-bit systems

Make 'r' 64-bit type to avoid overflow in 'r * LOAD_AVG_MAX'
on 32-bit systems:

UBSAN: Undefined behaviour in kernel/sched/fair.c:2785:18
signed integer overflow:
87950 * 47742 cannot be represented in type 'int'

The most likely effect of this bug are bad load average numbers
resulting in weird scheduling. It's also likely that this can
persist for a longer time - until the system goes idle for
a long time so that all load avg numbers get reset.

[ This is the CFS load average metric, not the procfs output, which
  is separate. ]

Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 3e2b1a64c47b ("sched/fair: Rewrite runnable load and utilization average tracking")
Link: http://lkml.kernel.org/r/1450097243-30137-1-git-send-email-aryabinin@virtuozzo.com
[ Improved the changelog. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/sched/fair.c