Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2500062imm; Mon, 24 Sep 2018 05:31:46 -0700 (PDT) X-Google-Smtp-Source: ACcGV618JfRCvSY8YRCrrxOKM6CYlvfU1GBsRNTvn0dr2r8+bZgkzACpfR0R0JCF/NZgHontye7E X-Received: by 2002:a63:cc4f:: with SMTP id q15-v6mr9312254pgi.217.1537792306794; Mon, 24 Sep 2018 05:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537792306; cv=none; d=google.com; s=arc-20160816; b=Mi2fd7XXJf4wjth+mdCp6e6S+JZe/a89nSr/alqrH2iwc/2z5oLLTEHMu4rBLAdQJx KW0q/qaCwZMdahYLYIDrSJJd233qDrLJIwDNh8MS06rwe295a+4XEWsuUpvLD63BgESz marMAazs37RovAYfCLZTBVqmG1/WSLCdrUrDkEou3YKYAbl8ND5JyWQLHfHVhJOmKtNO ZCqJS1026B1CiEVyBubrCOl/fgoJUAqyln5MhbOmJS3asbCh2QgwPbWKZntdFV5urdYB fFhjTE48yss6kjOnK56CItegoHiMr/A3mcTlWRB1JMOVAriHilztLqGgXOTQ6uYN3hgm XqSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=uGl+Rs63JecGIrZlXTq+UbC0hU0LZW+UP3jRL4ms4dw=; b=MNvbexHWe/qhd3BX0RZS77Yph1qRCWVZKGHCwL0HIBjZospIJpW1Qki/brbfBTL78k 9TmrIgtD0KiE08s5hrYDLVjrx6UZ3A6QE3789i1fRyjEkW5TH6p4qF9425o7XO4Xm/2Z qInAuQI1dcZ/c++pNeBqwV8OziYhCo4wLV5fw5lu8AqUsucq9Ljq5FOpg1roTja3JNVS 8xNYPpDV9BOjdwTALFyi9W92NLrSmOoTYG30LViLNvE4YJODbZ55CU5KG23NNClSTrbc cFziZ3Nxji7fqmFByze4Z+mEprZ0O6qqRKD364dThRlqALTEh7ifSj2Za0mEo8CrGnDR YpTA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d35-v6si33520082pla.116.2018.09.24.05.31.31; Mon, 24 Sep 2018 05:31:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387882AbeIXScY (ORCPT + 99 others); Mon, 24 Sep 2018 14:32:24 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57812 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733162AbeIXScY (ORCPT ); Mon, 24 Sep 2018 14:32:24 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 534071099; Mon, 24 Sep 2018 12:30:29 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Christoffer Dall , Marc Zyngier , kvmarm@lists.cs.columbia.edu, Sasha Levin Subject: [PATCH 4.18 063/235] KVM: arm/arm64: vgic: Fix possible spectre-v1 write in vgic_mmio_write_apr() Date: Mon, 24 Sep 2018 13:50:49 +0200 Message-Id: <20180924113111.438626086@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113103.999624566@linuxfoundation.org> References: <20180924113103.999624566@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mark Rutland [ Upstream commit 6b8b9a48545e08345b8ff77c9fd51b1aebdbefb3 ] It's possible for userspace to control n. Sanitize n when using it as an array index, to inhibit the potential spectre-v1 write gadget. Note that while it appears that n must be bound to the interval [0,3] due to the way it is extracted from addr, we cannot guarantee that compiler transformations (and/or future refactoring) will ensure this is the case, and given this is a slow path it's better to always perform the masking. Found by smatch. Signed-off-by: Mark Rutland Cc: Christoffer Dall Cc: Marc Zyngier Cc: kvmarm@lists.cs.columbia.edu Signed-off-by: Marc Zyngier Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- virt/kvm/arm/vgic/vgic-mmio-v2.c | 3 +++ 1 file changed, 3 insertions(+) --- a/virt/kvm/arm/vgic/vgic-mmio-v2.c +++ b/virt/kvm/arm/vgic/vgic-mmio-v2.c @@ -352,6 +352,9 @@ static void vgic_mmio_write_apr(struct k if (n > vgic_v3_max_apr_idx(vcpu)) return; + + n = array_index_nospec(n, 4); + /* GICv3 only uses ICH_AP1Rn for memory mapped (GICv2) guests */ vgicv3->vgic_ap1r[n] = val; }