sched/core: Fix possible Spectre-v1 indexing for sched_prio_to_weight[]
commit5d728a4ecab107668f241c6d2a10cc9380830c25
authorPeter Zijlstra <peterz@infradead.org>
Fri, 20 Apr 2018 12:29:51 +0000 (20 14:29 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 May 2018 08:12:35 +0000 (16 10:12 +0200)
tree7dfab1d231881ae1b765b31cd6a574c5eec6bc9c
parent62e16d89b4cf9b64436c33c6383df321eca91bec
sched/core: Fix possible Spectre-v1 indexing for sched_prio_to_weight[]

commit 7281c8dec8a87685cb54d503d8cceef5a0fc2fdd upstream.

> kernel/sched/core.c:6921 cpu_weight_nice_write_s64() warn: potential spectre issue 'sched_prio_to_weight'

Userspace controls @nice, so sanitize the value before using it to
index an array.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: <stable@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/sched/core.c