From patchwork Sat Apr 2 17:40:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12799392 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 E6F1AC433F5 for ; Sat, 2 Apr 2022 17:42:24 +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:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=MjoCjizv8UEei5J+58AvStOPk9fZg7Im9qqGdmNRMXE=; b=mjf2Vv6OKxihRpO0cFVJmSiIBM 9NwRt4FBOAzuXs2YPVisoIkBcDsFKZPjgyLG+fLgEZqoIXXkGOk5kiasIuy5xTQN7oaEGDdTmXf7o mikp9bsSocIVJC6+8MDOBmf/gldnJ9jyCAYVIaMkz8VVdDpjejg9VEsSSY04Zp6TzYp/hNnARDZMw usKtzdBYKSgXfRTPzuVl3TPdoqxY1VfQzv6ReYE2dzJUATuceAm/8B6dT2YfhToAFofqOeB0UiwMV 0ycFoZRImyUQ00DdMob3BBXSaWeYj1K0PKp+6dHYRYaYxfjjBYTbae2K0L+CVUeQsC0lGVTSrnfI1 F4Dn8xPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nahkV-009jkQ-UC; Sat, 02 Apr 2022 17:41:20 +0000 Received: from mail-io1-xd4a.google.com ([2607:f8b0:4864:20::d4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nahk5-009jZD-7i for linux-arm-kernel@lists.infradead.org; Sat, 02 Apr 2022 17:40:54 +0000 Received: by mail-io1-xd4a.google.com with SMTP id d19-20020a0566022bf300b00645eba5c992so3638954ioy.4 for ; Sat, 02 Apr 2022 10:40:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=EDhTuekQtNdm8MWzZ4rgwl9Zuy6sown5y5t0K60oNeM=; b=B8kXE1B9TLeU0fkKkRjLEwnu0j64XSm51isipBSezaI+aW4AtZHnIwm8TGZj11qhjH fZQIml2v0tbIQEfE+Rdi8YKENmjgZx3JLnbDQpunt+Lhb02W6Vt4aMuEdjjmWuAMIpU/ qpWP9KDaobTe+W3uOxEt+HSwNp7VpmQMyoKm+GSu+CZFLH6hjzjaKFfyU2AcF0kukXvm QDYThdKrd3I540B7S51JbBoxsphYIIH++HAYKwcqXN8Ak3NZOiSQbOk768apsr0G4RTv RVSLI2Pn5gd7HrzXW15CZPCcJCKrOG3MkeCDtxEhDwRuVNo6aCWkbdOKa9xeJ/7BVvad afww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=EDhTuekQtNdm8MWzZ4rgwl9Zuy6sown5y5t0K60oNeM=; b=rc9KEVHKfoiGe5EAk03km2VnlJXuvjKe3Ahn5xztTAHy5bDj1he+kmBMq+ilS+VUXZ SGlPLRBzUpKct5nSv53JpHVhkp1UCTCd/Wa59kBQIrsIgIhAxRRWcCmqvKa/Kpt0RX2O hZBrPBEggIpVjKJV1Pe/xjD8UIbKb7WtBnKuvEZ3+13n6BFkrZMjSK0CitNd0ojT46So OEcRXPIrJr0sUZJA5KsM8Z27Hbxgrm/h7fAhcM4RrUAgjltst2AqJBRAo7Zk8Dk7rq1R sPAh8pVgAMghy7PSSTHO7nhn8LHsnnAnZJbx0uJBUQAOWe9zDzDuzGSGb/X5xPVO9/KD W13g== X-Gm-Message-State: AOAM533XsoGc/ci9R0nXgOBqzNVKPm0rqdKEEpyLGo5qTFaJh5PpWt/4 DgPuVe6/5Sifvd0kOK9Adkr98gInthA= X-Google-Smtp-Source: ABdhPJwx6B48zoyhRzOI+UWoY4wiun1eWGRgsGjvJOKksNdUx4f7qTvuv/CNaHpOREGjQo9q8Bk2CyZ29n4= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a05:6602:2c8b:b0:649:e67c:9202 with SMTP id i11-20020a0566022c8b00b00649e67c9202mr2148843iow.75.1648921250592; Sat, 02 Apr 2022 10:40:50 -0700 (PDT) Date: Sat, 2 Apr 2022 17:40:42 +0000 In-Reply-To: <20220402174044.2263418-1-oupton@google.com> Message-Id: <20220402174044.2263418-3-oupton@google.com> Mime-Version: 1.0 References: <20220402174044.2263418-1-oupton@google.com> X-Mailer: git-send-email 2.35.1.1094.g7c7d902a7c-goog Subject: [PATCH 2/4] KVM: Only log about debugfs directory collision once From: Oliver Upton To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, Peter Shier , Ricardo Koller , Reiji Watanabe , Paolo Bonzini , Sean Christopherson , Oliver Upton , stable@kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220402_104053_315044_EF56C584 X-CRM114-Status: GOOD ( 12.27 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In all likelihood, a debugfs directory name collision is the result of a userspace bug. If userspace closes the VM fd without releasing all references to said VM then the debugfs directory is never cleaned. Even a ratelimited print statement can fill up dmesg, making it particularly annoying for the person debugging what exactly went wrong. Furthermore, a userspace that wants to be a nuisance could clog up the logs by deliberately holding a VM reference after closing the VM fd. Dial back logging to print at most once, given that userspace is most likely to blame. Leave the statement in place for the small chance that KVM actually got it wrong. Cc: stable@kernel.org Fixes: 85cd39af14f4 ("KVM: Do not leak memory for duplicate debugfs directories") Signed-off-by: Oliver Upton --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 69c318fdff61..38b30bd60f34 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -959,7 +959,7 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int fd) mutex_lock(&kvm_debugfs_lock); dent = debugfs_lookup(dir_name, kvm_debugfs_dir); if (dent) { - pr_warn_ratelimited("KVM: debugfs: duplicate directory %s\n", dir_name); + pr_warn_once("KVM: debugfs: duplicate directory %s\n", dir_name); dput(dent); mutex_unlock(&kvm_debugfs_lock); return 0;