OSDN Git Service

misc: hmc6352: fix potential Spectre v1
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Wed, 15 Aug 2018 15:50:41 +0000 (10:50 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Sep 2018 06:39:31 +0000 (08:39 +0200)
commit9ed3ad68de71f17d0a1102d07fc4fa84b03195a3
treed796082004d3e60c29704622999d9b1691e5a428
parent094302a07e8952ddcb8cc8d7a047e29a1843d150
misc: hmc6352: fix potential Spectre v1

commit de916736aaaadddbd6061472969f667b14204aa9 upstream.

val is indirectly controlled by user-space, hence leading to a
potential exploitation of the Spectre variant 1 vulnerability.

This issue was detected with the help of Smatch:

drivers/misc/hmc6352.c:54 compass_store() warn: potential spectre issue
'map' [r]

Fix this by sanitizing val before using it to index map

Notice that given that speculation windows are large, the policy is
to kill the speculation on the first load and not worry if it can be
completed with a dependent load/store [1].

[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2

Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/hmc6352.c