From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zhenyu Wang Subject: Re: [PATCH] drm/i915/kvmgt: Fix potential Spectre v1 Date: Tue, 7 Aug 2018 10:26:24 +0800 Message-ID: <20180807022624.GY22630@zhen-hp.sh.intel.com> References: <20180803034019.GA18366@embeddedor.com> Reply-To: Zhenyu Wang Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0905923599==" Return-path: In-Reply-To: <20180803034019.GA18366@embeddedor.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: "Gustavo A. R. Silva" Cc: David Airlie , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Rodrigo Vivi , intel-gvt-dev@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org --===============0905923599== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="hc4757KF+wLS/WHK" Content-Disposition: inline --hc4757KF+wLS/WHK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 2018.08.02 22:40:19 -0500, Gustavo A. R. Silva wrote: > info.index can be indirectly controlled by user-space, hence leading > to a potential exploitation of the Spectre variant 1 vulnerability. >=20 > This issue was detected with the help of Smatch: >=20 > drivers/gpu/drm/i915/gvt/kvmgt.c:1232 intel_vgpu_ioctl() warn: > potential spectre issue 'vgpu->vdev.region' [r] >=20 > Fix this by sanitizing info.index before indirectly using it to index > vgpu->vdev.region Thanks for catching this! Applied. >=20 > 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]. >=20 > [1] https://marc.info/?l=3Dlinux-kernel&m=3D152449131114778&w=3D2 >=20 > Cc: stable@vger.kernel.org > Signed-off-by: Gustavo A. R. Silva > --- > drivers/gpu/drm/i915/gvt/kvmgt.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/gpu/drm/i915/gvt/kvmgt.c b/drivers/gpu/drm/i915/gvt/= kvmgt.c > index 4d2f53a..b703f20 100644 > --- a/drivers/gpu/drm/i915/gvt/kvmgt.c > +++ b/drivers/gpu/drm/i915/gvt/kvmgt.c > @@ -43,6 +43,8 @@ > #include > #include > =20 > +#include > + > #include "i915_drv.h" > #include "gvt.h" > =20 > @@ -1139,7 +1141,8 @@ static long intel_vgpu_ioctl(struct mdev_device *md= ev, unsigned int cmd, > } else if (cmd =3D=3D VFIO_DEVICE_GET_REGION_INFO) { > struct vfio_region_info info; > struct vfio_info_cap caps =3D { .buf =3D NULL, .size =3D 0 }; > - int i, ret; > + unsigned int i; > + int ret; > struct vfio_region_info_cap_sparse_mmap *sparse =3D NULL; > size_t size; > int nr_areas =3D 1; > @@ -1224,6 +1227,10 @@ static long intel_vgpu_ioctl(struct mdev_device *m= dev, unsigned int cmd, > if (info.index >=3D VFIO_PCI_NUM_REGIONS + > vgpu->vdev.num_regions) > return -EINVAL; > + info.index =3D > + array_index_nospec(info.index, > + VFIO_PCI_NUM_REGIONS + > + vgpu->vdev.num_regions); > =20 > i =3D info.index - VFIO_PCI_NUM_REGIONS; > =20 > --=20 > 2.7.4 >=20 > _______________________________________________ > intel-gvt-dev mailing list > intel-gvt-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev --=20 Open Source Technology Center, Intel ltd. $gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827 --hc4757KF+wLS/WHK Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQTXuabgHDW6LPt9CICxBBozTXgYJwUCW2kDTwAKCRCxBBozTXgY J58IAJ9vy8iEV8uRpctpj6P5oa6oCd1mswCeJ1Psy3HD97wVSuYiHISLTkOgSN4= =hejq -----END PGP SIGNATURE----- --hc4757KF+wLS/WHK-- --===============0905923599== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSW50ZWwtZ2Z4 IG1haWxpbmcgbGlzdApJbnRlbC1nZnhAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vaW50ZWwtZ2Z4Cg== --===============0905923599==--