Return-Path: =?utf-8?q?=3CBATV+f8d8a1baba6b42e20c18+5463+infradead=2Eorg+d?= =?utf-8?q?wmw2=40twosheds=2Esrs=2Einfradead=2Eorg=3E?= Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 08 Aug 2018 13:58:52 -0000 Received: from twosheds.infradead.org ([2001:8b0:10b:1:21d:7dff:fe04:dbe2]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from =?utf-8?q?=3CBATV+f8d8a1baba6b42e20c18+5463+infradea?= =?utf-8?q?d=2Eorg+dwmw2=40twosheds=2Esrs=2Einfradead=2Eorg=3E=29?= id 1fnOuB-0003gi-6N for speck@linutronix.de; Wed, 08 Aug 2018 15:53:40 +0200 Received: from [2001:8b0:10b:1::b8f] by twosheds.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fnOu9-003ztr-3T for speck@linutronix.de; Wed, 08 Aug 2018 13:53:37 +0000 Message-ID: <1533736415.3615.64.camel@infradead.org> Subject: [MODERATED] Cache load gadgets From: David Woodhouse Date: Wed, 08 Aug 2018 14:53:35 +0100 Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable To: speck@linutronix.de List-ID: If we aren't disabling hyperthreading, then we get to lose sleep over what a VM guest can trick us into loading into L1$ while a sibling runs the attack. For this they only need half a Spectre-v1 gadget; they only need to load something into L1. We've tweaked our scanner and trawled through the false positives, and we have a handful of patches which look something like the one below. Should we be getting these into the tree for next Tuesday's release? From: Julian Stecklina Date: Mon, 6 Aug 2018 13:55:43 +0200 Subject: [PATCH] kvm, x86: fix potential cache load gadget MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit APIC IDs are guest provided. The array access in the Local APIC code is a potential cache load gadget. Signed-off-by: Julian Stecklina Signed-off-by: David Woodhouse Reviewed-by: Martin Pohlack Reviewed-by: Jan H. Sch=C3=B6nherr --- =C2=A0arch/x86/kvm/lapic.c | 5 +++-- =C2=A01 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 55cf55f..e919283 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -28,6 +28,7 @@ =C2=A0#include =C2=A0#include =C2=A0#include +#include =C2=A0#include =C2=A0#include =C2=A0#include @@ -133,7 +134,7 @@ static inline bool kvm_apic_map_get_logical_dest(struct k= vm_apic_map *map, =C2=A0 if (offset <=3D max_apic_id) { =C2=A0 u8 cluster_size =3D min(max_apic_id - offset + 1, 16U); =C2=A0 - *cluster =3D &map->phys_map[offset]; + *cluster =3D &map->phys_map[array_index_nospec(offset, max_apic_id + 1)]; =C2=A0 *mask =3D dest_id & (0xffff >> (16 - cluster_size)); =C2=A0 } else { =C2=A0 *mask =3D 0; @@ -821,7 +822,7 @@ static inline bool kvm_apic_map_get_dest_lapic(struct kvm= *kvm, =C2=A0 if (irq->dest_id > map->max_apic_id) { =C2=A0 *bitmap =3D 0; =C2=A0 } else { - *dst =3D &map->phys_map[irq->dest_id]; + *dst =3D &map->phys_map[array_index_nospec(irq->dest_id, map->max_apic_id= + 1)]; =C2=A0 *bitmap =3D 1; =C2=A0 } =C2=A0 return true; --=C2=A0 2.7.4