arm64: fix possible spectre-v1 write in ptrace_hbp_set_event()
authorMark Rutland <mark.rutland@arm.com>
Tue, 10 Jul 2018 18:01:22 +0000 (19:01 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Sep 2018 06:38:03 +0000 (08:38 +0200)
commitc1e2aee9952b8fa32606595d0ed1c05fd3f0086f
tree6de18bbbeda12d6f57497cf478808a5d4329531c
parent991bad26b38fbb1484c8dfe825c238bb182a208f
arm64: fix possible spectre-v1 write in ptrace_hbp_set_event()

[ Upstream commit 14d6e289a89780377f8bb09de8926d3c62d763cd ]

It's possible for userspace to control idx. Sanitize idx when using it
as an array index, to inhibit the potential spectre-v1 write gadget.

Found by smatch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm64/kernel/ptrace.c