From patchwork Mon May 4 01:52:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47980 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 153722121F for ; Mon, 4 May 2015 01:56:56 +0000 (UTC) Received: by wgtl5 with SMTP id l5sf41029834wgt.1 for ; Sun, 03 May 2015 18:56:55 -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=HuWwpLxIYhrKbSmSOq/WhhIqEyTbHpXk1HSALZ6DauCtEENjp5YAb4NgPMyTsYVORM f4FFMLdFdb0OeWbJIGyv/+hJ34Y5huGYhCCOVXtXcoJfC8MF7qhKrD6d6tMYf2Sc5KRE 9L9v2SGFB5azKLJuspb70S1hsGzgLBERXyyebnAsKSYFYBkNYxeibV/c3nLynjC+wJ1m U2fucQRTn3z8I0H+HjdTMi8KFOfYoezqB0jFmVd7RC1gW+Tb3Towiz+3ribX0q9v/u/v 8X60Wr5vbgJ6o1C1ntiH9Mktk9HWE9IwhlWVJDGOPs1zTdclo0+IRb7c/BW4ad45li6e +/mQ== X-Gm-Message-State: ALoCoQkuyYMd3x87Dqvch0KmbkO46XeH48GsYOMmACCTQoA0df4VzV8cFtJIwHSKA4CD3fsX3ONj X-Received: by 10.152.184.73 with SMTP id es9mr16976851lac.4.1430704615298; Sun, 03 May 2015 18:56:55 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.133 with SMTP id c5ls578230lac.68.gmail; Sun, 03 May 2015 18:56:55 -0700 (PDT) X-Received: by 10.152.184.101 with SMTP id et5mr17487677lac.43.1430704615141; Sun, 03 May 2015 18:56:55 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id n4si9109380laj.9.2015.05.03.18.56.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 May 2015 18:56:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by laat2 with SMTP id t2so95053791laa.1 for ; Sun, 03 May 2015 18:56:55 -0700 (PDT) X-Received: by 10.112.199.133 with SMTP id jk5mr9591224lbc.32.1430704615035; Sun, 03 May 2015 18:56:55 -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.67.65 with SMTP id l1csp1413315lbt; Sun, 3 May 2015 18:56:54 -0700 (PDT) X-Received: by 10.68.68.176 with SMTP id x16mr38139980pbt.95.1430704613270; Sun, 03 May 2015 18:56:53 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ix6si17838787pac.46.2015.05.03.18.56.52; Sun, 03 May 2015 18:56:53 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751975AbbEDB4w (ORCPT + 2 others); Sun, 3 May 2015 21:56:52 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:36023 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751977AbbEDB4v (ORCPT ); Sun, 3 May 2015 21:56:51 -0400 Received: by pabsx10 with SMTP id sx10so147796458pab.3 for ; Sun, 03 May 2015 18:56:51 -0700 (PDT) X-Received: by 10.66.141.202 with SMTP id rq10mr38767169pab.64.1430704611368; Sun, 03 May 2015 18:56:51 -0700 (PDT) Received: from localhost ([180.150.153.1]) by mx.google.com with ESMTPSA id eu5sm11015385pbb.44.2015.05.03.18.56.49 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 03 May 2015 18:56:49 -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 42/47] arm/arm64: KVM: Don't allow creating VCPUs after vgic_initialized Date: Mon, 4 May 2015 09:52:37 +0800 Message-Id: <1430704362-6292-43-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1430704362-6292-1-git-send-email-shannon.zhao@linaro.org> References: <1430704362-6292-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.43 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;