From patchwork Thu Apr 30 09:25:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 47794 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 35D562121F for ; Thu, 30 Apr 2015 09:31:49 +0000 (UTC) Received: by wizk4 with SMTP id k4sf2988438wiz.2 for ; Thu, 30 Apr 2015 02:31:48 -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=8TKE1Gq/XrK8D5GDTUH7W8wz0dDXOtunRlsZ4FTk7j0=; b=J0+6kl4tBLsCYNUdfbWi2hIOUzk8hT+/e1tqeyjTclNBMNgO6E4WJKnXFDzphdB6nG RqRTDXAd2LDYpqU3gE2PTbJkMhnexY5TW8gYk6icJVdTQB3otRHVOKWXYbquIvvZbfcJ 3Jhh1MGPXmi51ly3+6bZGniJdlgoINofREdcPCUVlr/ntn3yAO3Iz97YgKn9esRBsSeH uQHvgtmm4cJrcKVMFQtKeAuE1O97DT0MYKUyNNtbKt3/6JdubRGftUtte05qCS3fXiHF KE0RHaNd87/boEi8svlFy27L4Y3aaOv7VZFCA+6xMt95jLhhlnInqoYKWvJiz7cNbTpo mZZw== X-Gm-Message-State: ALoCoQkK64dyqYjUASYhlQjpROD8if6s0Xcbpt/ZHWJul28pkUOukkQaEaYYldKEYr9+r326S251 X-Received: by 10.194.236.230 with SMTP id ux6mr2011573wjc.5.1430386308558; Thu, 30 Apr 2015 02:31:48 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.65 with SMTP id c1ls329180lae.46.gmail; Thu, 30 Apr 2015 02:31:48 -0700 (PDT) X-Received: by 10.112.130.129 with SMTP id oe1mr2927384lbb.37.1430386308425; Thu, 30 Apr 2015 02:31:48 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id k7si1353522lbj.50.2015.04.30.02.31.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Apr 2015 02:31:48 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbcga7 with SMTP id ga7so39971779lbc.1 for ; Thu, 30 Apr 2015 02:31:48 -0700 (PDT) X-Received: by 10.112.163.168 with SMTP id yj8mr3031756lbb.36.1430386308317; Thu, 30 Apr 2015 02:31:48 -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 l1csp2997898lbt; Thu, 30 Apr 2015 02:31:47 -0700 (PDT) X-Received: by 10.70.87.231 with SMTP id bb7mr6545501pdb.70.1430385940346; Thu, 30 Apr 2015 02:25:40 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nf2si2640288pbc.149.2015.04.30.02.25.39; Thu, 30 Apr 2015 02:25:40 -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 S1750866AbbD3JZc (ORCPT + 2 others); Thu, 30 Apr 2015 05:25:32 -0400 Received: from ip4-83-240-67-251.cust.nbox.cz ([83.240.67.251]:52997 "EHLO ip4-83-240-18-248.cust.nbox.cz" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751362AbbD3JZO (ORCPT ); Thu, 30 Apr 2015 05:25:14 -0400 Received: from ku by ip4-83-240-18-248.cust.nbox.cz with local (Exim 4.85) (envelope-from ) id 1YnkiW-0005Pd-FS; Thu, 30 Apr 2015 11:25:12 +0200 From: Jiri Slaby To: stable@vger.kernel.org Cc: Christoffer Dall , Shannon Zhao , Jiri Slaby Subject: [patch added to the 3.12 stable tree] arm/arm64: KVM: Don't allow creating VCPUs after vgic_initialized Date: Thu, 30 Apr 2015 11:25:06 +0200 Message-Id: <1430385911-20480-58-git-send-email-jslaby@suse.cz> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1430385911-20480-1-git-send-email-jslaby@suse.cz> References: <1430385911-20480-1-git-send-email-jslaby@suse.cz> 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: patch@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.217.177 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 This patch has been added to the 3.12 stable tree. If you have any objections, please let us know. =============== 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 Signed-off-by: Jiri Slaby --- 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 d1c5946e33a2..86dee11838ab 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;