Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3762274imm; Mon, 18 Jun 2018 03:43:56 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLtPbHOODb49g8IVTHWyZUy+Fu2k6A7uIZMACLQQum3djpe1nx5Dj1v4+Jmh9bW/Tnoepks X-Received: by 2002:a63:42c7:: with SMTP id p190-v6mr10779451pga.142.1529318636519; Mon, 18 Jun 2018 03:43:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529318636; cv=none; d=google.com; s=arc-20160816; b=ioSm2S7BnKMx32C4XU5tL/+4CR56KR9wzG7CIxAelYmHMBIsSLcTdBO9pfi4b8minN uF96zDGZOQGV+i01D7Lmc3DH2vX6EbMw9apf6DedvkV9q6PY4poE2VgHlk5MA9FypIkW KIDiBscH0n+O2986Sun+SzPPbuawB5thT7W9QM4WinhS+XNvsS3srhHxZ1zuJLfj7X0D rHZc5O2MHz7yeYRd1dDGxOPIde3orAxNCcjnxj78YA422FPuuu3tpqCGClr80+cQDzqp qEI8GAvr6w+7qS1MQWgP9NnzBb7UuLvzFQdsYL52HPPD7ldEPxs9LS2pymjyV9ZqqEpc gb2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=DzpD+OIZKm3hTdfb52mu6NouBZ9zhPgusWSvkWuCh5U=; b=RNL6PHvyhZgE9o5vxuJ9+ZoizsKZD4vsW3Ub1c47MTPQGwhBgkInrrXzYNZd0TdL1P sK6XdEeDELnyl4kGJsA7X4HJP6aint3sFcxxTfzu22BbdyDMGfwU/uPJaM1a694gVqjp RPgzDh5UA3oLpbc8GTukIRbScEYa4DGmEIzCdOzly8rBuYk6PzaLb6XHp7z87RaFGig7 kWFubsjb/lAymdBNWJSvOayoC5C+WOuptOh9g7YMFd44IdB3vFMOwK6zjbHRx/SchD7z 6RwlIt4bPWdEQlOdlXSrEBOsKUQ7PFf48Fa6PffGq4+1t9ZyIDpc0BJLYKNe8BbOttP3 /Pig== 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 z13-v6si15145411plo.287.2018.06.18.03.43.43; Mon, 18 Jun 2018 03:43:56 -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 S964835AbeFRIT4 (ORCPT + 99 others); Mon, 18 Jun 2018 04:19:56 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:54968 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934933AbeFRITy (ORCPT ); Mon, 18 Jun 2018 04:19:54 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1CA99BAD; Mon, 18 Jun 2018 08:19:53 +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, Will Deacon , Sasha Levin Subject: [PATCH 4.16 107/279] KVM: arm/arm64: vgic: fix possible spectre-v1 in vgic_mmio_read_apr() Date: Mon, 18 Jun 2018 10:11:32 +0200 Message-Id: <20180618080613.251884990@linuxfoundation.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618080608.851973560@linuxfoundation.org> References: <20180618080608.851973560@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mark Rutland [ Upstream commit 5e1ca5e23b167987d5b6d8b08f2d5b7dd2d13f49 ] It's possible for userspace to control n. Sanitize n when using it as an array index. 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 Acked-by: Christoffer Dall Acked-by: Marc Zyngier Cc: kvmarm@lists.cs.columbia.edu Signed-off-by: Will Deacon Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- virt/kvm/arm/vgic/vgic-mmio-v2.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/virt/kvm/arm/vgic/vgic-mmio-v2.c +++ b/virt/kvm/arm/vgic/vgic-mmio-v2.c @@ -14,6 +14,8 @@ #include #include #include +#include + #include #include @@ -324,6 +326,9 @@ static unsigned long vgic_mmio_read_apr( if (n > vgic_v3_max_apr_idx(vcpu)) return 0; + + n = array_index_nospec(n, 4); + /* GICv3 only uses ICH_AP1Rn for memory mapped (GICv2) guests */ return vgicv3->vgic_ap1r[n]; }