Skip to content

Commit fee05f4

Browse files
GustavoARSilvagregkh
authored andcommitted
drivers/misc/sgi-gru: fix Spectre v1 vulnerability
req.gid can be 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: vers/misc/sgi-gru/grukdump.c:200 gru_dump_chiplet_request() warn: potential spectre issue 'gru_base' [w] Fix this by sanitizing req.gid before calling macro GID_TO_GRU, which uses it to index gru_base. 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: [email protected] Signed-off-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e670de5 commit fee05f4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/misc/sgi-gru/grukdump.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#include <linux/delay.h>
2828
#include <linux/bitops.h>
2929
#include <asm/uv/uv_hub.h>
30+
31+
#include <linux/nospec.h>
32+
3033
#include "gru.h"
3134
#include "grutables.h"
3235
#include "gruhandles.h"
@@ -196,6 +199,7 @@ int gru_dump_chiplet_request(unsigned long arg)
196199
/* Currently, only dump by gid is implemented */
197200
if (req.gid >= gru_max_gids)
198201
return -EINVAL;
202+
req.gid = array_index_nospec(req.gid, gru_max_gids);
199203

200204
gru = GID_TO_GRU(req.gid);
201205
ubuf = req.buf;

0 commit comments

Comments
 (0)