From patchwork Tue Jun 30 10:49:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 50465 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8C601229DF for ; Tue, 30 Jun 2015 10:51:44 +0000 (UTC) Received: by wian6 with SMTP id n6sf4114890wia.2 for ; Tue, 30 Jun 2015 03:51:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=KmdodKQEepopy5NoNElAgmGSayR8SJbEon0Xeh7NSEs=; b=hZ9nG5Mv5P9ljv+/q2w49MCXi+weyXVRuUz+ZxxpB4+XxoS7ecE9khCwyz+sAH4yrC d+1U54rkniJeelpRIzz8r7GSPtdJE+E1JkWQagFy1HIaWAi8g++0EFdt7HNTCpSmrtxL Be4Z0hhzdbq/t2ubS4ZPSN/BjkN1+AIt6wfvS+dZVVdPNIHDS3FAu+dIfkVM/bo0gtvv gjhr8Z3XEUj/dMIBr6xx3O7FnWevVMJX6Fjf9hrT+DgqrHsDa7BbTC9U6DTsGU9s88RL VWWerYAKm1cuOXRGZUPxCtzN6V+/6A1ErnVsZRMWyuxLTrFobM81jKnMKwgJeGgCCerK ZM6Q== X-Gm-Message-State: ALoCoQmpjGn3htNB3FAi7bAVjWQX5jQmUFRGcCfXnUmYMokt3mFxMo4Yye0DjigAs+P+8jr9qvG3 X-Received: by 10.112.13.200 with SMTP id j8mr13717653lbc.14.1435661503740; Tue, 30 Jun 2015 03:51:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.203.136 with SMTP id kq8ls28201lac.32.gmail; Tue, 30 Jun 2015 03:51:43 -0700 (PDT) X-Received: by 10.152.180.197 with SMTP id dq5mr19073543lac.104.1435661503520; Tue, 30 Jun 2015 03:51:43 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id g1si37794840lbs.32.2015.06.30.03.51.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jun 2015 03:51:43 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by lagc2 with SMTP id c2so8112883lag.3 for ; Tue, 30 Jun 2015 03:51:43 -0700 (PDT) X-Received: by 10.112.93.37 with SMTP id cr5mr19121833lbb.106.1435661503268; Tue, 30 Jun 2015 03:51:43 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp2353469lbb; Tue, 30 Jun 2015 03:51:42 -0700 (PDT) X-Received: by 10.70.48.229 with SMTP id p5mr42783475pdn.78.1435661498825; Tue, 30 Jun 2015 03:51:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lj11si69631040pab.25.2015.06.30.03.51.38; Tue, 30 Jun 2015 03:51:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752859AbbF3Kva (ORCPT + 2 others); Tue, 30 Jun 2015 06:51:30 -0400 Received: from mail-pd0-f171.google.com ([209.85.192.171]:36859 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752822AbbF3KvW (ORCPT ); Tue, 30 Jun 2015 06:51:22 -0400 Received: by pdcu2 with SMTP id u2so4334440pdc.3 for ; Tue, 30 Jun 2015 03:51:22 -0700 (PDT) X-Received: by 10.68.68.203 with SMTP id y11mr42628511pbt.63.1435661482329; Tue, 30 Jun 2015 03:51:22 -0700 (PDT) Received: from localhost ([120.136.36.232]) by mx.google.com with ESMTPSA id pj6sm40147834pac.18.2015.06.30.03.51.19 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 30 Jun 2015 03:51:20 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, christoffer.dall@linaro.org, shannon.zhao@linaro.org Subject: [PATCH for 3.14.y stable 17/22] arm/arm64: KVM: Don't allow creating VCPUs after vgic_initialized Date: Tue, 30 Jun 2015 18:49:05 +0800 Message-Id: <1435661350-8060-18-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1435661350-8060-1-git-send-email-shannon.zhao@linaro.org> References: <1435661350-8060-1-git-send-email-shannon.zhao@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shannon.zhao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Christoffer Dall commit 716139df2517fbc3f2306dbe8eba0fa88dca0189 upstream. When the vgic initializes its internal state it does so based on the number of VCPUs available at the time. If we allow KVM to create more VCPUs after the VGIC has been initialized, we are likely to error out in unfortunate ways later, perform buffer overflows etc. Acked-by: Marc Zyngier Reviewed-by: Eric Auger Signed-off-by: Christoffer Dall Signed-off-by: Shannon Zhao --- arch/arm/kvm/arm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 039df03..2e74a61 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -220,6 +220,11 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id) int err; struct kvm_vcpu *vcpu; + if (irqchip_in_kernel(kvm) && vgic_initialized(kvm)) { + err = -EBUSY; + goto out; + } + vcpu = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL); if (!vcpu) { err = -ENOMEM;