From patchwork Thu Apr 30 12:12:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 47821 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E7C3E2121F for ; Thu, 30 Apr 2015 12:18:10 +0000 (UTC) Received: by layy10 with SMTP id y10sf15004214lay.0 for ; Thu, 30 Apr 2015 05:18:09 -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: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=mZ74kx8IzWR5xMPg/49oYdjdUrKO2RJuybGMdOMvz/Q=; b=lUK9DbJ7a9UBQAQWFIXImmckqVpyfFlGuSLH6utuOTfrxH7vp7L3cbzYLWUk2YhtAY WYmcQZBwRKT+AAzEDr1tW69d032e4edh1VZ8VERlADyLurpdXhWbMrjDsM+96nTgAui6 Mao5Zi5IqjVQgDw0Wu+Rvj5M5mLRI7V66T9nQfNoLoHYiRoTkCPv5/JzkaI54ZS+JUb4 sRS9O+bER6f8OMdvNHRSknV0IWgltewzFx4/1WE35MX8F3pawYLnNUHTL72mcoqhYWMD 4ohywhmiYBEfDMeQXpxlwJBTdeT+qy/hF9aP6oiotb6lLvUqc6KCu5RtAiyAnaZVgH9V pf6g== X-Gm-Message-State: ALoCoQkdl77ox/aZErF8OwNIdefmIWAo+MCt4ATiFmoAMllcWfURVkK4m3HRxnMT2rUrSjeDp7kK X-Received: by 10.180.97.9 with SMTP id dw9mr1603324wib.2.1430396289582; Thu, 30 Apr 2015 05:18:09 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.129 with SMTP id m1ls359007laf.76.gmail; Thu, 30 Apr 2015 05:18:09 -0700 (PDT) X-Received: by 10.152.88.46 with SMTP id bd14mr3509118lab.71.1430396289361; Thu, 30 Apr 2015 05:18:09 -0700 (PDT) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id wu8si1617608lac.157.2015.04.30.05.18.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Apr 2015 05:18:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by layy10 with SMTP id y10so42713071lay.0 for ; Thu, 30 Apr 2015 05:18:09 -0700 (PDT) X-Received: by 10.152.27.1 with SMTP id p1mr3525771lag.112.1430396289278; Thu, 30 Apr 2015 05:18:09 -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 l1csp3077437lbt; Thu, 30 Apr 2015 05:18:06 -0700 (PDT) X-Received: by 10.68.246.1 with SMTP id xs1mr7684018pbc.53.1430396266605; Thu, 30 Apr 2015 05:17:46 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rs11si3258820pab.141.2015.04.30.05.17.45; Thu, 30 Apr 2015 05:17:46 -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 S1751696AbbD3MOl (ORCPT + 2 others); Thu, 30 Apr 2015 08:14:41 -0400 Received: from ip4-83-240-67-251.cust.nbox.cz ([83.240.67.251]:53687 "EHLO ip4-83-240-18-248.cust.nbox.cz" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751471AbbD3MMf (ORCPT ); Thu, 30 Apr 2015 08:12:35 -0400 Received: from ku by ip4-83-240-18-248.cust.nbox.cz with local (Exim 4.85) (envelope-from ) id 1YnnKT-0008E8-Ik; Thu, 30 Apr 2015 14:12:33 +0200 From: Jiri Slaby To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Christoffer Dall , Shannon Zhao , Jiri Slaby Subject: [PATCH 3.12 58/63] arm/arm64: KVM: Don't allow creating VCPUs after vgic_initialized Date: Thu, 30 Apr 2015 14:12:27 +0200 Message-Id: <67ffa0e4618acd554a1c5a0fba54338e2bee0973.1430387326.git.jslaby@suse.cz> X-Mailer: git-send-email 2.3.5 In-Reply-To: <45aaf85687dd6ac119c55c5ec0dbe0bef0e62235.1430387326.git.jslaby@suse.cz> References: <45aaf85687dd6ac119c55c5ec0dbe0bef0e62235.1430387326.git.jslaby@suse.cz> In-Reply-To: References: 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.215.47 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 3.12-stable review patch. If anyone has any objections, please let me 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;