From patchwork Mon May 4 01:25:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47926 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DA49B20553 for ; Mon, 4 May 2015 01:27:40 +0000 (UTC) Received: by wghm4 with SMTP id m4sf40959176wgh.2 for ; Sun, 03 May 2015 18:27:40 -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=qCU2WF4ts3TsupRq8VzKeKJ3Z2sd19hNKSjlk7oUO+g=; b=R8NQNrVJuscScCFBYCLqCmgasCoY0vuBmPW4nSJ1NAT9u9b1ZM6OBb/DLm8tzVyvaP O0rQRESRVSFpGrB2Cn1xq24VDcsd12ybV6N0BlS2Gn59YKOwQOtFrEiNoWr5YtNQZqaZ 8z2CiwZgzlBUOL1x5Sk9mD8rLZOT1QEiBf4VnFqgiddPYyIa6wDcgUoxTkCn5PG2qGpm At/9DMUcpbkAxQ4MV/qkkxiF46uEbaYuQQZYbBcxyNZ4ei8Wd5WOAMo5ZLpD1VRzFj2c Gxkd8BO/zXYAHaoyR5eywlQ+n5l9xqAOBQqgcpz9vBDg35ntKI3t38O2EPN4iOk/7hAR 7VXQ== X-Gm-Message-State: ALoCoQkJOlt8k0Rz1VJbhNBJwzyWvR3fxTZxvvTorB10PUwk8fY8XbqPEfRvEdtR5jBS5OKjfhRn X-Received: by 10.152.203.233 with SMTP id kt9mr16903435lac.7.1430702860092; Sun, 03 May 2015 18:27:40 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.70 with SMTP id le6ls712190lac.50.gmail; Sun, 03 May 2015 18:27:39 -0700 (PDT) X-Received: by 10.112.171.68 with SMTP id as4mr17641605lbc.64.1430702859816; Sun, 03 May 2015 18:27:39 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id ay16si9070627lab.32.2015.05.03.18.27.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 May 2015 18:27:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by laat2 with SMTP id t2so94809764laa.1 for ; Sun, 03 May 2015 18:27:39 -0700 (PDT) X-Received: by 10.152.27.98 with SMTP id s2mr17666743lag.106.1430702859690; Sun, 03 May 2015 18:27:39 -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 l1csp1405967lbt; Sun, 3 May 2015 18:27:38 -0700 (PDT) X-Received: by 10.70.36.102 with SMTP id p6mr37645652pdj.18.1430702857162; Sun, 03 May 2015 18:27:37 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id es7si17680936pbd.123.2015.05.03.18.27.35; Sun, 03 May 2015 18:27:37 -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 S1751776AbbEDB1f (ORCPT + 2 others); Sun, 3 May 2015 21:27:35 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:35759 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751823AbbEDB1e (ORCPT ); Sun, 3 May 2015 21:27:34 -0400 Received: by pabtp1 with SMTP id tp1so147361323pab.2 for ; Sun, 03 May 2015 18:27:34 -0700 (PDT) X-Received: by 10.70.128.36 with SMTP id nl4mr38202133pdb.43.1430702854483; Sun, 03 May 2015 18:27:34 -0700 (PDT) Received: from localhost ([180.150.153.1]) by mx.google.com with ESMTPSA id bq3sm10983784pbd.24.2015.05.03.18.27.32 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 03 May 2015 18:27:33 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: sasha.levin@oracle.com, christoffer.dall@linaro.org, shannon.zhao@linaro.org Subject: [PATCH for 3.18.y stable 10/22] arm/arm64: KVM: Don't allow creating VCPUs after vgic_initialized Date: Mon, 4 May 2015 09:25:14 +0800 Message-Id: <1430702726-2056-11-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1430702726-2056-1-git-send-email-shannon.zhao@linaro.org> References: <1430702726-2056-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.51 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 448314b..546a12e 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -213,6 +213,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;