Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6959804rwn; Tue, 13 Sep 2022 11:28:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5dy2WwcxU+rtCKmoN7KIJQKe0jmTiUVPPrDrzAiOzfdBt+tChbQEPHsMRny5+vE1QXScub X-Received: by 2002:a17:90a:6a83:b0:200:9da5:d0e7 with SMTP id u3-20020a17090a6a8300b002009da5d0e7mr533493pjj.187.1663093719345; Tue, 13 Sep 2022 11:28:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663093719; cv=none; d=google.com; s=arc-20160816; b=OBYO41cZ1QRVDQVGjNvouMov0Ff56IK+m6Am/Yl/Lyzd09ZhMBoUUA0AGaueQQ0hrZ 9ShiV+eaMrlcLYJp6FqsEmSzj5Bvwat4nV3bej2GzPdkW/xJI0SC2QQkfxQeak2KsBPr 5wY9JRSpGACXQqq1h4GX2n50X/k9YHHghzj93PsxxVw/E3o8Qy94pwB4zYxlCL8CW2p1 Uxk/HXLMXkl5CPUTvfNXTn5yxlsAlW9I8BbrmU2eD8a2QUY/91YZdqqQC+Smcbf6ySnG 0OjRbgV5/A0pvHiA4ncr5JK0J0iuIjFP4O0HDWMtcGrUp1Ij7vXlbrQ/EbM3uYp3UCv8 s7Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=5bwtqtp6PJfttZvCLxCl1n6K+88dKkhKG6FejOezXrM=; b=TWUdkIUwegkdgi0+43Qu0UCah4QpjvxYAgemeiHLKMBbKWu/R8hGB8RiDl9ae+bIZl BqhZRYuqyGsso6cYCFmtkzmQPc9BP635bju+Xw7gMZ2sxeqkdNgDqH6a+8gCw8qul4UQ 9XTWCuaQUPfDnj5cIKuc8nV+QP96MccluzeAuJR9/LexEyu7Tp/WVLhYbMItXrep/Ifk mXgZPAkPC105OrUHhO+eOVEnTAC0NlbHSMl3hk7ObRRHiG/VJzK/0eVLmpTcOzi9MOcI 4NOsi/jFQsC8QIK4RvXaLxayTrCuAB+nEB1H7FqX0MfY1WW55yqqTs7+9r3MdgZE2DVW s+OA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=JZRCVyn8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s6-20020a056a0008c600b005408882cbbcsi12466538pfu.380.2022.09.13.11.28.27; Tue, 13 Sep 2022 11:28:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=JZRCVyn8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231776AbiIMR4Y (ORCPT + 99 others); Tue, 13 Sep 2022 13:56:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229990AbiIMRz4 (ORCPT ); Tue, 13 Sep 2022 13:55:56 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D9646FA25; Tue, 13 Sep 2022 09:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=5bwtqtp6PJfttZvCLxCl1n6K+88dKkhKG6FejOezXrM=; b=JZRCVyn8It0XZ6n9xg+mNMZ0PJ sO11Lg+9TW1Yz0MnDrjvBYNmcYzFyaR9khLCw2uxiP/XkWVP8MFKsjDOxHYBxZbQTeyXuiChBpjim qT67E5ilPvyYWqV49KMHsvfwuphgb6zYhxbONUHl0HJpuW0ElEmqSBCFOSIWg8G18ARcyab/GqITL mDi2zVCJjY7nphWLa0cI3yx6zt7ObdKaZK7cxxFo7JCAHaaO2l+zyPbnmZU3WQX2W2Kv+16pKzsbm YGf6ezr97eC+ZSmCgM+YhsbI7dTp2NAngLheZqr91wJJQ+OpztYRf8VMTuLKg5xkrZA78MDmY9neY D2wJLDgw==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:34298) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oY9CT-0003Jh-HK; Tue, 13 Sep 2022 17:55:55 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1oY9CS-0000pS-Et; Tue, 13 Sep 2022 17:55:52 +0100 Date: Tue, 13 Sep 2022 17:55:52 +0100 From: "Russell King (Oracle)" To: Greg Kroah-Hartman Cc: mw@semihalf.com, linux-kernel@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, stable Subject: Re: [PATCH net] net: mvpp2: debugfs: fix memory leak when using debugfs_lookup() Message-ID: References: <20220902134111.280657-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220902134111.280657-1-gregkh@linuxfoundation.org> Sender: Russell King (Oracle) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 02, 2022 at 03:41:11PM +0200, Greg Kroah-Hartman wrote: > When calling debugfs_lookup() the result must have dput() called on it, > otherwise the memory will leak over time. Fix this up to be much > simpler logic and only create the root debugfs directory once when the > driver is first accessed. That resolves the memory leak and makes > things more obvious as to what the intent is. To clarify a bit more on the original patch rather than one of the backported stable patches of this. This patch introduces a bug, whereby if the driver is a module, and is inserted, binds to a device, then is removed and re-inserted, mvpp2_root will be NULL on the first call to mvpp2_dbgfs_init(), so we will attempt to call debugfs_create_dir(). However, the directory was already previously created, so this will fail, and mvpp2_root will be the EEXIST error pointer. Since we never clean up this directory, the original code does NOT result in a memory leak - since the increase in refcount caused by debugfs_lookup() has absolutely no effect - because we never remove this directory once it's been created. If the driver /did/ remove the directory when the module is removed, then yes, maybe there's an argument for this fix. However, as things currently stand, this is in no way a fix, but actually introduces a debugfs regression. Please can the change be reverted in mainline and all stable trees. Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!