Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp637380ybl; Fri, 6 Dec 2019 03:54:31 -0800 (PST) X-Google-Smtp-Source: APXvYqwOxt9fZ6/VS6bX/VbjpaThEhdxYSwMbi0ftX8IFWeSNw5h+wQo/pmrRcswbsBs6Uhmnqaw X-Received: by 2002:a05:6830:22e6:: with SMTP id t6mr11132238otc.244.1575633271759; Fri, 06 Dec 2019 03:54:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575633271; cv=none; d=google.com; s=arc-20160816; b=yk66Qs5G5dMqiC4TiqX3MF9mNF1XXmgNnix+YHPeZaMJ9WuUSk698oJJM4ed9HqWgv NsOAGRnbJ93CNrIFPRt/o2gncCXF6Dgn+DIY7YOgMeiWW+MY7KIywho1ZEaul7yCOvky EM+L8dhcYYmme0WGSIAejjOofiP/msxmKLp2Q5DWMTTKfXSSokCO4JZG+PN/uJx0dvcG 0oNrBg45MQKxfCoHxcJBzEjjjAPAuykr/n+PRZjgMdHDeQRYJnzZItEDBZyWfODujMwD 4tl9E5DIQFCYYhFOZZQJQb3ypwo5upV+gQ8ivupy1wqKC+4NwrWUlZiqEDtA9rFrVqyC JVYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:cc:from:date:content-transfer-encoding:mime-version :subject:to; bh=g4DBW6pXeJHetkDjR41WMF9dBXSrkgd3/LXXY6d2bOE=; b=tvCbLRXR9dKhvfq2400lqwCzIf5oaaVfgF/b3DasBDgyhQf0awK5BrWYlBKAmiK3wQ k0jY8TXJrZD5ujcQQGVcX0ARIIbm69SMwbuzX5bY28YqcvofJuLkWnITE5BeVoFYW64o lfx4FRYtA000l0EGJ70whYITUObjxW432VGoTPWTTagrR9W0IUq5Jc5FDZcxhITshmka RWYv60+b9/OkG1nOvGFVdrIVj6GQV+L7BnfkW20vmo5W59m6EMrtnDlp+DWeycwVa663 e1I8i6fqDb45AA2QyruLy2Z4un2ED8vMRSWwOeCJpD3aowNwGfhXT+YX0Kr/U0dH7m2i 3gsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i140si7110128oib.90.2019.12.06.03.54.18; Fri, 06 Dec 2019 03:54:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726242AbfLFLxt (ORCPT + 99 others); Fri, 6 Dec 2019 06:53:49 -0500 Received: from inca-roads.misterjones.org ([213.251.177.50]:48713 "EHLO inca-roads.misterjones.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726116AbfLFLxt (ORCPT ); Fri, 6 Dec 2019 06:53:49 -0500 Received: from www-data by cheepnis.misterjones.org with local (Exim 4.80) (envelope-from ) id 1idCAz-00025P-1c; Fri, 06 Dec 2019 12:53:37 +0100 To: linmiaohe Subject: Re: [PATCH] KVM: vgic: Fix potential double free dist->spis in =?UTF-8?Q?=5F=5Fkvm=5Fvgic=5Fdestroy=28=29?= X-PHP-Originating-Script: 0:main.inc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 06 Dec 2019 11:53:36 +0000 From: Marc Zyngier Cc: , , , , , , , , , , , , , , , In-Reply-To: <1574923128-19956-1-git-send-email-linmiaohe@huawei.com> References: <1574923128-19956-1-git-send-email-linmiaohe@huawei.com> Message-ID: X-Sender: maz@kernel.org User-Agent: Roundcube Webmail/0.7.2 X-SA-Exim-Connect-IP: X-SA-Exim-Rcpt-To: linmiaohe@huawei.com, pbonzini@redhat.com, rkrcmar@redhat.com, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, christoffer.dall@arm.com, catalin.marinas@arm.com, eric.auger@redhat.com, gregkh@linuxfoundation.org, will@kernel.org, andre.przywara@arm.com, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-11-28 06:38, linmiaohe wrote: > From: Miaohe Lin > > In kvm_vgic_dist_init() called from kvm_vgic_map_resources(), if > dist->vgic_model is invalid, dist->spis will be freed without set > dist->spis = NULL. And in vgicv2 resources clean up path, > __kvm_vgic_destroy() will be called to free allocated resources. > And dist->spis will be freed again in clean up chain because we > forget to set dist->spis = NULL in kvm_vgic_dist_init() failed > path. So double free would happen. > > Signed-off-by: Miaohe Lin > --- > virt/kvm/arm/vgic/vgic-init.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/virt/kvm/arm/vgic/vgic-init.c > b/virt/kvm/arm/vgic/vgic-init.c > index 53e3969dfb52..c17c29beeb72 100644 > --- a/virt/kvm/arm/vgic/vgic-init.c > +++ b/virt/kvm/arm/vgic/vgic-init.c > @@ -171,6 +171,7 @@ static int kvm_vgic_dist_init(struct kvm *kvm, > unsigned int nr_spis) > break; > default: > kfree(dist->spis); > + dist->spis = NULL; > return -EINVAL; > } > } Applied, thanks. M. -- Jazz is not dead. It just smells funny...