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
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <abd207fc649aa92bcac49f0d207ff2289e8d73ff.camel@sipsolutions.net>
Date:   Tue, 14 Feb 2023 10:58:11 +0100
From:   Johannes Berg <johannes@...solutions.net>
To:     shaozhengchao <shaozhengchao@...wei.com>,
        linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
        davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
        pabeni@...hat.com
Cc:     sara.sharon@...el.com, luciano.coelho@...el.com,
        weiyongjun1@...wei.com, yuehaibing@...wei.com
Subject: Re: [PATCH v2] wifi: mac80211: fix memory leak in
 ieee80211_register_hw()

On Sun, 2023-01-29 at 14:28 +0800, shaozhengchao wrote:
> 
> On 2023/1/18 17:45, Johannes Berg wrote:
> > On Fri, 2022-12-02 at 12:38 +0800, Zhengchao Shao wrote:
> > > 
> > > --- a/net/mac80211/main.c
> > > +++ b/net/mac80211/main.c
> > > @@ -1326,6 +1326,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
> > >   					      hw->rate_control_algorithm);
> > >   	rtnl_unlock();
> > >   	if (result < 0) {
> > > +		ieee80211_txq_teardown_flows(local);
> > >   		wiphy_debug(local->hw.wiphy,
> > >   			    "Failed to initialize rate control algorithm\n");
> > >   		goto fail_rate;
> > > @@ -1364,6 +1365,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
> > >   
> > >   		sband = kmemdup(sband, sizeof(*sband), GFP_KERNEL);
> > >   		if (!sband) {
> > > +			ieee80211_txq_teardown_flows(local);
> > >   			result = -ENOMEM;
> > >   			goto fail_rate;
> > >   		}
> > 
> > I don't understand - we have a fail_rate label here where we free
> > everything.
> > 
> > What if we get to fail_wiphy_register, don't we leak it in the same way?
> > 
> > johannes


> 	Thank you for your review. Sorry it took so long to reply. The
> fail_rate label does not release the resources applied for in the
> ieee80211_txq_setup_flows().  Or maybe I missed something?

That's my point though - if we "goto fail_ifa" or "goto
fail_wiphy_register", we have the same bug, no?

So shouldn't the patch simply be this:

diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 846528850612..a42d1f0ef7a5 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -1442,6 +1442,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
 	ieee80211_remove_interfaces(local);
 	rtnl_unlock();
  fail_rate:
+	ieee80211_txq_teardown_flows(local);
  fail_flows:
 	ieee80211_led_exit(local);
 	destroy_workqueue(local->workqueue);


johannes

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ