[lkml]   [2018]   [Jul]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 4.14 17/44] vfio/pci: Fix potential Spectre v1
4.14-stable review patch.  If anyone has any objections, please let me know.


From: Gustavo A. R. Silva <>

commit 0e714d27786ce1fb3efa9aac58abc096e68b1c2a upstream.

info.index 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:

drivers/vfio/pci/vfio_pci.c:734 vfio_pci_ioctl()
warn: potential spectre issue 'vdev->region'

Fix this by sanitizing info.index before indirectly using it to index

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].


Signed-off-by: Gustavo A. R. Silva <>
Signed-off-by: Alex Williamson <>
Signed-off-by: Greg Kroah-Hartman <>

drivers/vfio/pci/vfio_pci.c | 4 ++++
1 file changed, 4 insertions(+)

--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -28,6 +28,7 @@
#include <linux/uaccess.h>
#include <linux/vfio.h>
#include <linux/vgaarb.h>
+#include <linux/nospec.h>

#include "vfio_pci_private.h"

@@ -746,6 +747,9 @@ static long vfio_pci_ioctl(void *device_
if (info.index >=
VFIO_PCI_NUM_REGIONS + vdev->num_regions)
return -EINVAL;
+ info.index = array_index_nospec(info.index,
+ vdev->num_regions);

i = info.index - VFIO_PCI_NUM_REGIONS;

 \ /
  Last update: 2018-07-23 14:59    [W:0.184 / U:3.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site