dm ioctl: prevent potential spectre v1 gadget
authorJordy Zomer <jordy@jordyzomer.github.io>
Sat, 29 Jan 2022 14:58:39 +0000 (15:58 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Apr 2022 18:59:05 +0000 (20:59 +0200)
commit02cc46f397eb3691c56affbd5073e54f7a82ac32
tree77484f6161dde9fa65def0466bf0fb166681c656
parent049072749a5e1fe277ee64746bbe9fca5c55f3f9
dm ioctl: prevent potential spectre v1 gadget

[ Upstream commit cd9c88da171a62c4b0f1c70e50c75845969fbc18 ]

It appears like cmd could be a Spectre v1 gadget as it's supplied by a
user and used as an array index. Prevent the contents of kernel memory
from being leaked to userspace via speculative execution by using
array_index_nospec.

Signed-off-by: Jordy Zomer <jordy@pwning.systems>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/md/dm-ioctl.c