lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <CAPv3WKcF-EXAbBoLLZWSJWzutSicx9aNLgU1Ah+MU3WXKEic1A@mail.gmail.com> Date: Sun, 25 Sep 2022 09:55:10 +0200 From: Marcin Wojtas <mw@...ihalf.com> To: "Russell King (Oracle)" <linux@...linux.org.uk> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>, netdev@...r.kernel.org, linux-kernel@...r.kernel.org, "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, stable <stable@...nel.org> Subject: Re: [PATCH net] net: mvpp2: debugfs: fix problem with previous memory leak fix niedz., 25 wrz 2022 o 08:58 Russell King (Oracle) <linux@...linux.org.uk> napisał(a): > > On Sun, Sep 25, 2022 at 01:27:06AM +0200, Marcin Wojtas wrote: > > Hi Russell, > > > > czw., 22 wrz 2022 o 19:08 Marcin Wojtas <mw@...ihalf.com> napisał(a): > > > > > > Hi, > > > > > > Thank you both for the patches. > > > > > > > > > czw., 22 wrz 2022 o 18:05 Russell King (Oracle) > > > <linux@...linux.org.uk> napisał(a): > > > > > > > > On Wed, Sep 21, 2022 at 01:44:44PM +0200, Greg Kroah-Hartman wrote: > > > > > In commit fe2c9c61f668 ("net: mvpp2: debugfs: fix memory leak when using > > > > > debugfs_lookup()"), if the module is unloaded, the directory will still > > > > > be present if the module is loaded again and creating the directory will > > > > > fail, causing the creation of additional child debugfs entries for the > > > > > individual devices to fail. > > > > > > > > > > As this module never cleaned up the root directory it created, even when > > > > > loaded, and unloading/loading a module is not a normal operation, none > > > > > of would normally happen. > > > > > > > > > > To clean all of this up, use a tiny reference counted structure to hold > > > > > the root debugfs directory for the driver, and then clean it up when the > > > > > last user of it is removed from the system. This should resolve the > > > > > previously reported problems, and the original memory leak that > > > > > fe2c9c61f668 ("net: mvpp2: debugfs: fix memory leak when using > > > > > debugfs_lookup()") was attempting to fix. > > > > > > > > For the record... I have a better fix for this, but I haven't been able > > > > to get it into a state suitable for submission yet. > > > > > > > > http://www.home.armlinux.org.uk/~rmk/misc/mvpp2-debugfs.diff > > > > > > > > Not yet against the net tree. Might have time tomorrow to do that, not > > > > sure at the moment. Medical stuff is getting in the way. :( > > > > > > > > > > I'd lean towards this version - it is a bit more compact. I'll try to > > > test that tomorrow or during the weekend. > > > > > > > I improved the patch compile and work (tested on my CN913x board). > > Feel free to submit (if you wish, I can do it too - please let me know > > your preference): > > https://github.com/semihalf-wojtas-marcin/Linux-Kernel/commit/0abb75115ffb2772f595bb3346573e27e650018b > > I don't see what the compile fixes were in that - it looks like my patch I overlooked drivers/net/ethernet/marvell/mvpp2/mvpp2.h diff (I applied patch manually), but I double-checked and it was there, so you are right. > ported onto current -net. Obvious changes: Yes, it's applied on top of net/net-next. > > - moved mvpp2_dbgfs_exit() declaration from after mvpp2_dbgfs_cleanup() > to before. > - moved definition of mvpp2_root to the top of the file (as no effect > on the code.) These are irrelevant. The most important part was: --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -7714,8 +7714,8 @@ module_init(mvpp2_driver_init); static void __exit mvpp2_driver_exit(void) { - mvpp2_dbgfs_exit(); platform_driver_unregister(&mvpp2_driver); + mvpp2_dbgfs_exit(); } module_exit(mvpp2_driver_exit); Otherwise, I observed NULL-pointer dereference when mvpp2_remove()->mvpp2_dbgfs_cleanup(). > > and the change to port it: > > - dropped my mvpp2_dbgfs_init() hunk (because it's different in -net) > - removed static declaration of mvpp2_root in mvpp2_dbgfs_init() > > I'm not seeing any other changes. > > Note that Sasha has submitted a revert of Greg's original patch for > mainline, so my original patch should apply as-is if that revert > happens - and I don't see any compile issues with it. > Sure. In order to avoid misunderstandings, I stop here and leave the submission to you. Thanks, Marcin
Powered by blists - more mailing lists