From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A43FEC433F5 for ; Wed, 6 Apr 2022 07:11:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hvSjj09tzdJlpR3hSQY0g6G9y/2A2K8IHkw6jtTD1QE=; b=sFUWQMHIjJiNTD D2FRnIctdOqBO957rabCqxNX2wWUpmffFuoUCBUxQ8QiFTs4lvYPVxjQIxeHDYXICD1fVj9+D72ym X9Q4rQXnn2i9MRc9kdBQk7jCqxbhJvvk+iBgWY+OF7Tv70xuPXClkYoCZjXBRz0XQIbi0iADLB54O 9szLsHaoaWsR3P8MvI65roLEgXnBV7/afYozSfBS+oHom4OA7k7/arMD4ODZOSYIiiEuYt3ApFW6x bbYvmlIHt/QWHpiTgPKGqtyY9thNtRcmNCiXzmmrSbR/7FiOSTMdVHlyHIO47cGPtjToHjeeQWiif 4sEtlBZ/AqcJqFePhokA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nbzo5-004MUE-Cz; Wed, 06 Apr 2022 07:10:21 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nbznv-004MRR-Ry for linux-arm-kernel@lists.infradead.org; Wed, 06 Apr 2022 07:10:13 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 10DF261A0D; Wed, 6 Apr 2022 07:10:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70572C385A1; Wed, 6 Apr 2022 07:10:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649229010; bh=mVDxM1dhB2/8ewK05J3b9YYTZKETXEF2oeIq+WeG7ts=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qGMMpaXEavl0KV7Z8YOSFB4sNhaYoJN9i5O6BOQlrMIQJeBWgfvLPNVT16518VZ0H eziDsVpB/4jisIBDK/DBJ4ykhVqLfFF8aO+wz0k2ZZNVCJy581ufQ602aYNU3xHL// 438BBSNm9LPtZrwrGnrE+/Xc/BL1XamZb7VBtlN9F7VLFLP99vBJMDjz6SgGChS4M9 tz4ojrRVfa6TCB3TdCUU/ftWmQs02uXAfNbeVsYOHO/fs19bYKc+9gEu7RaBtbn2RZ 0VQHKIS/WPB8a//i/2jaZClivO/TCmhXloamwrV7+kJN1gLakoVRRsZOX2BNG91U5j vmiU/kMGjqlsA== Received: from ip-185-104-136-29.ptr.icomera.net ([185.104.136.29] helo=billy-the-mountain.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nbznr-0025gP-LZ; Wed, 06 Apr 2022 08:10:07 +0100 Date: Wed, 06 Apr 2022 08:10:00 +0100 Message-ID: <87fsmqvgaf.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, Peter Shier , Ricardo Koller , Reiji Watanabe , Paolo Bonzini , Sean Christopherson , stable@kernel.org Subject: Re: [PATCH v2 1/3] KVM: Don't create VM debugfs files outside of the VM directory In-Reply-To: <20220404182119.3561025-2-oupton@google.com> References: <20220404182119.3561025-1-oupton@google.com> <20220404182119.3561025-2-oupton@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.104.136.29 X-SA-Exim-Rcpt-To: oupton@google.com, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, linux-arm-kernel@lists.infradead.org, pshier@google.com, ricarkol@google.com, reijiw@google.com, pbonzini@redhat.com, seanjc@google.com, stable@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220406_001012_058238_447ADD3C X-CRM114-Status: GOOD ( 29.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Oliver, On Mon, 04 Apr 2022 19:21:17 +0100, Oliver Upton wrote: > > Unfortunately, there is no guarantee that KVM was able to instantiate a > debugfs directory for a particular VM. To that end, KVM shouldn't even > attempt to create new debugfs files in this case. If the specified > parent dentry is NULL, debugfs_create_file() will instantiate files at > the root of debugfs. > > For arm64, it is possible to create the vgic-state file outside of a > VM directory, the file is not cleaned up when a VM is destroyed. > Nonetheless, the corresponding struct kvm is freed when the VM is > destroyed. > > Nip the problem in the bud for all possible errant debugfs file > creations by initializing kvm->debugfs_dentry to -ENOENT. In so doing, > debugfs_create_file() will fail instead of creating the file in the root > directory. > > Cc: stable@kernel.org > Fixes: 929f45e32499 ("kvm: no need to check return value of debugfs_create functions") > Signed-off-by: Oliver Upton > --- > virt/kvm/kvm_main.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index 70e05af5ebea..04a426e65cb8 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -932,7 +932,7 @@ static void kvm_destroy_vm_debugfs(struct kvm *kvm) > int kvm_debugfs_num_entries = kvm_vm_stats_header.num_desc + > kvm_vcpu_stats_header.num_desc; > > - if (!kvm->debugfs_dentry) > + if (!IS_ERR(kvm->debugfs_dentry)) > return; Shouldn't this condition be inverted? It certainly looks odd. > > debugfs_remove_recursive(kvm->debugfs_dentry); > @@ -955,6 +955,12 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int fd) > int kvm_debugfs_num_entries = kvm_vm_stats_header.num_desc + > kvm_vcpu_stats_header.num_desc; > > + /* > + * Force subsequent debugfs file creations to fail if the VM directory > + * is not created. > + */ > + kvm->debugfs_dentry = ERR_PTR(-ENOENT); > + > if (!debugfs_initialized()) > return 0; > > @@ -5479,7 +5485,7 @@ static void kvm_uevent_notify_change(unsigned int type, struct kvm *kvm) > } > add_uevent_var(env, "PID=%d", kvm->userspace_pid); > > - if (kvm->debugfs_dentry) { > + if (!IS_ERR(kvm->debugfs_dentry)) { > char *tmp, *p = kmalloc(PATH_MAX, GFP_KERNEL_ACCOUNT); > > if (p) { Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel