From patchwork Sun Apr 23 17:09:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9695029 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F0F4A60245 for ; Sun, 23 Apr 2017 17:13:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB24D26530 for ; Sun, 23 Apr 2017 17:13:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0145265B9; Sun, 23 Apr 2017 17:13:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6889F26530 for ; Sun, 23 Apr 2017 17:13:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163051AbdDWRNF (ORCPT ); Sun, 23 Apr 2017 13:13:05 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:35234 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162532AbdDWRKz (ORCPT ); Sun, 23 Apr 2017 13:10:55 -0400 Received: by mail-wm0-f48.google.com with SMTP id w64so46382487wma.0 for ; Sun, 23 Apr 2017 10:10:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XrbzKHlvRPN05/NTWTrdMWue/DTmgPqQnIrbdyxQ3Vk=; b=L1BFNAu1L3nT4wf+hAWpp8WqII74JYaXleQ+I7lc7QIYtbiVwJgVXgbbiRQttr1wBN IiKeKLHlUlKBPTIZPafcFci8nIxDRsr9M5qXyio5r7AzNhvh6kz9Dyor1dj+oIqNougE 0jlhikHyDTTfe+mr7J5jBACFdNVZ5mGQT56uE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XrbzKHlvRPN05/NTWTrdMWue/DTmgPqQnIrbdyxQ3Vk=; b=qBosN0paSwUifp/kg9PqHUAW+J9oRpCotxex26HQDsPadc1eCXfqJbViHWhJb0O549 xJVUpwsIfFH7/y84CIrUbopJ9Ns9sX8M/WoD3y/BfsB/Nu5cnbhqj83Y+ETxkshKf12v uog22PnQscgL3jM8mRTn21xlNNw25l6g4wfboz7rl5YrMDoKHE02Y1EA27lpw6YujO/n 38xjTx9B0uM/vD5g8wMlvS0rXZmtfMiVXbvdp0XWpI1Wfi+WZw+3pBfQDfEWqts5vDqt 5lZ8YBeM8l+rPZpxAoC6cRvdjfkfV5BvGANLmXQYhHyJ/MulLTYRAS/cmt08crR23b+N j0yQ== X-Gm-Message-State: AN3rC/7zMUZyZqhhRL/sjHsjhcCXH3yGiqaxv/ZjDnNdS2FbmXPKvgE0 6IvX3zDgqkiqFmkk X-Received: by 10.80.180.136 with SMTP id w8mr144132edd.112.1492967454317; Sun, 23 Apr 2017 10:10:54 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id 58sm2803521edz.2.2017.04.23.10.10.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 23 Apr 2017 10:10:53 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Christoffer Dall Subject: [PULL 77/79] KVM: arm/arm64: vgic-v3: Fix off-by-one LR access Date: Sun, 23 Apr 2017 19:09:27 +0200 Message-Id: <20170423170929.27334-78-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170423170929.27334-1-cdall@linaro.org> References: <20170423170929.27334-1-cdall@linaro.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc Zyngier When iterating over the used LRs, be careful not to try to access an unused LR, or even an unimplemented one if you're unlucky... Reviewed-by: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Christoffer Dall --- virt/kvm/arm/hyp/vgic-v3-sr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/arm/hyp/vgic-v3-sr.c b/virt/kvm/arm/hyp/vgic-v3-sr.c index 91922c1..bce6037 100644 --- a/virt/kvm/arm/hyp/vgic-v3-sr.c +++ b/virt/kvm/arm/hyp/vgic-v3-sr.c @@ -143,7 +143,7 @@ void __hyp_text __vgic_v3_save_state(struct kvm_vcpu *vcpu) val = read_gicreg(ICH_VTR_EL2); nr_pri_bits = vtr_to_nr_pri_bits(val); - for (i = 0; i <= used_lrs; i++) { + for (i = 0; i < used_lrs; i++) { if (cpu_if->vgic_elrsr & (1 << i)) cpu_if->vgic_lr[i] &= ~ICH_LR_STATE; else