From patchwork Fri Apr 24 05:27:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47543 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4273A20553 for ; Fri, 24 Apr 2015 05:35:07 +0000 (UTC) Received: by lbcne10 with SMTP id ne10sf8860858lbc.1 for ; Thu, 23 Apr 2015 22:35:06 -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=jXkrbG9TPlU6E+ubwDrv2XyLK2jDQWEcvGtibhpTn6A=; b=eyyusLiKHzH3m4oaayzsDcE0LMw75XZUaC9mU2l3K24zRSy+/MFHt3Gm3rH8tvn7uq xoMunUY58GWsogTSFy7hh17p0prQfRjOKMe3DlnhdOejSbP8lVWkKWVU3plFW0jLBfFt lLHEtmHOfsIVc0zlGG0hG8UVqfDUzBhodJUoLBWenKfScZbQc3jHt1KCaLe85DYwuCQF jf7z2x20ryqfkVqaMGVi58wqfZ3M1m5ikEZkApZoNq/5R5upoa/qSdHDiRJdxJ77KNV8 oOehj4vvrYMHWOl0au44Wv6ZUqK8nyz6O9Cfj8ReQ6+wBM8avCSV+TI7/7xkVKfCz2vG 9Chg== X-Gm-Message-State: ALoCoQnMdkwcsmCUJ03Jxr0RPZl8m6hcVafTf1rHKkHDUW4XNhLIkBOmI5lF8orqFx9/Vz84v2zl X-Received: by 10.152.5.168 with SMTP id t8mr3217944lat.3.1429853706217; Thu, 23 Apr 2015 22:35:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.45.6 with SMTP id i6ls445034lam.10.gmail; Thu, 23 Apr 2015 22:35:05 -0700 (PDT) X-Received: by 10.152.5.170 with SMTP id t10mr5413692lat.43.1429853705946; Thu, 23 Apr 2015 22:35:05 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id jn4si7483237lbc.49.2015.04.23.22.35.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Apr 2015 22:35:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by labbd9 with SMTP id bd9so27592595lab.2 for ; Thu, 23 Apr 2015 22:35:05 -0700 (PDT) X-Received: by 10.152.4.137 with SMTP id k9mr5363781lak.29.1429853705859; Thu, 23 Apr 2015 22:35:05 -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 l1csp979011lbt; Thu, 23 Apr 2015 22:35:05 -0700 (PDT) X-Received: by 10.66.229.9 with SMTP id sm9mr11671994pac.1.1429853704114; Thu, 23 Apr 2015 22:35:04 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bd10si15800741pdb.178.2015.04.23.22.35.03; Thu, 23 Apr 2015 22:35:04 -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 S1754581AbbDXFfC (ORCPT + 2 others); Fri, 24 Apr 2015 01:35:02 -0400 Received: from mail-oi0-f51.google.com ([209.85.218.51]:35568 "EHLO mail-oi0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754579AbbDXFfB (ORCPT ); Fri, 24 Apr 2015 01:35:01 -0400 Received: by oign205 with SMTP id n205so32427612oig.2 for ; Thu, 23 Apr 2015 22:35:00 -0700 (PDT) X-Received: by 10.202.206.144 with SMTP id e138mr5549703oig.132.1429853700929; Thu, 23 Apr 2015 22:35:00 -0700 (PDT) Received: from localhost ([167.160.116.36]) by mx.google.com with ESMTPSA id my16sm6066191obc.25.2015.04.23.22.34.59 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 23 Apr 2015 22:35:00 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: jslaby@suse.cz, christoffer.dall@linaro.org, shannon.zhao@linaro.org Subject: [PATCH for 3.12.y stable 58/63] arm/arm64: KVM: Don't allow creating VCPUs after vgic_initialized Date: Fri, 24 Apr 2015 13:27:56 +0800 Message-Id: <1429853281-6136-59-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1429853281-6136-1-git-send-email-shannon.zhao@linaro.org> References: <1429853281-6136-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.48 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 d1c5946..86dee11 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -218,6 +218,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;