From patchwork Tue Jun 2 14:48:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 49402 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 964DD20BD1 for ; Tue, 2 Jun 2015 14:51:56 +0000 (UTC) Received: by labc7 with SMTP id c7sf14294099lab.1 for ; Tue, 02 Jun 2015 07:51: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=nKjqHCqR8dvXhtFr/lvAgHS41a8p55dwOMMRPYfnrCAUyGea9S6cbgH//+/8Jt3wi6 1rJDZqHvgqxDbhmvXY7IJA0FDh4keEnSH9il41QmHmU0zpvVn5vnZif2LC3S8Wic8JGV pkaR0Klxh6Q408Jw9D7dXnWfLyQ8G+sKGAoJIStkOlJgrmfWsDWEZbmrAdHl8XmdQshw LOnJX/Z154WlI0tE6AschHqJE0MOc/XkC1z/+jcTmWnwwrBN+GenBE9poj1NN1bINdWc uVNkuPvcAAcMMtrZTIfy4g6k87pscjNu20svQX/eR/BF9tpxw59JwHftMAKS5FWT17Re 3PSw== X-Gm-Message-State: ALoCoQnRvwbFX02fmpftk0J8o3g0Taost3faCuFXe3W/FsndEwR4bvZi3QPxeUdFQOoJKd1Kg2Ke X-Received: by 10.180.105.67 with SMTP id gk3mr16765097wib.4.1433256715462; Tue, 02 Jun 2015 07:51:55 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.22.10 with SMTP id z10ls800480lae.24.gmail; Tue, 02 Jun 2015 07:51:55 -0700 (PDT) X-Received: by 10.112.145.132 with SMTP id su4mr25959255lbb.85.1433256715293; Tue, 02 Jun 2015 07:51:55 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id wc1si15287400lbb.66.2015.06.02.07.51.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jun 2015 07:51:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbcue7 with SMTP id ue7so106113754lbc.0 for ; Tue, 02 Jun 2015 07:51:55 -0700 (PDT) X-Received: by 10.152.37.228 with SMTP id b4mr4221751lak.117.1433256715202; Tue, 02 Jun 2015 07:51: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.108.230 with SMTP id hn6csp3130032lbb; Tue, 2 Jun 2015 07:51:54 -0700 (PDT) X-Received: by 10.68.246.1 with SMTP id xs1mr13129647pbc.53.1433256713306; Tue, 02 Jun 2015 07:51:53 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id po1si26750474pac.52.2015.06.02.07.51.52; Tue, 02 Jun 2015 07:51:53 -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 S1759122AbbFBOvw (ORCPT + 2 others); Tue, 2 Jun 2015 10:51:52 -0400 Received: from mail-ob0-f179.google.com ([209.85.214.179]:36202 "EHLO mail-ob0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758949AbbFBOvv (ORCPT ); Tue, 2 Jun 2015 10:51:51 -0400 Received: by obbea2 with SMTP id ea2so129525831obb.3 for ; Tue, 02 Jun 2015 07:51:51 -0700 (PDT) X-Received: by 10.60.85.39 with SMTP id e7mr22906393oez.81.1433256711116; Tue, 02 Jun 2015 07:51:51 -0700 (PDT) Received: from localhost ([167.160.116.34]) by mx.google.com with ESMTPSA id m19sm9621815oik.5.2015.06.02.07.51.48 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 02 Jun 2015 07:51: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 27/32] arm/arm64: KVM: Don't allow creating VCPUs after vgic_initialized Date: Tue, 2 Jun 2015 22:48:22 +0800 Message-Id: <1433256507-7856-28-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1433256507-7856-1-git-send-email-shannon.zhao@linaro.org> References: <1433256507-7856-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.217.169 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;