Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: xiaoqiang zhao <zhaoxiaoqiang007@gmail.com>
To: Dongliang Mu <mudongliangabcd@gmail.com>,
	Johannes Berg <johannes@sipsolutions.net>,
	Kalle Valo <kvalo@codeaurora.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Luca Coelho <luciano.coelho@intel.com>,
	Ilan Peer <ilan.peer@intel.com>
Cc: syzbot+1638e7c770eef6b6c0d0@syzkaller.appspotmail.com,
	Johannes Berg <johannes.berg@intel.com>,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cfg80211: free the object allocated in wiphy_apply_custom_regulatory
Date: Fri, 23 Jul 2021 17:18:33 +0800	[thread overview]
Message-ID: <6fa2aecc-ab64-894d-77c2-0a19b524cc03@gmail.com> (raw)
In-Reply-To: <20210723050919.1910964-1-mudongliangabcd@gmail.com>



在 2021/7/23 13:09, Dongliang Mu 写道:
> The commit beee24695157 ("cfg80211: Save the regulatory domain when
> setting custom regulatory") forgets to free the newly allocated regd
> object.
> 
> Fix this by freeing the regd object in the error handling code and
> deletion function - mac80211_hwsim_del_radio.
> 
> Reported-by: syzbot+1638e7c770eef6b6c0d0@syzkaller.appspotmail.com
> Fixes: beee24695157 ("cfg80211: Save the regulatory domain when setting custom regulatory")
> Signed-off-by: Dongliang Mu <mudongliangabcd@gmail.com>
> ---
>  drivers/net/wireless/mac80211_hwsim.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
> index ffa894f7312a..20b870af6356 100644
> --- a/drivers/net/wireless/mac80211_hwsim.c
> +++ b/drivers/net/wireless/mac80211_hwsim.c
> @@ -3404,6 +3404,8 @@ static int mac80211_hwsim_new_radio(struct genl_info *info,
>  	debugfs_remove_recursive(data->debugfs);
>  	ieee80211_unregister_hw(data->hw);
>  failed_hw:
> +	if (param->regd)
> +		kfree_rcu(get_wiphy_regdom(data->hw->wiphy));
>  	device_release_driver(data->dev);

hw->wiphy->regd may be NULL if previous reg_copy_regd failed, so how about:
if (hw->wiphy->regd)
	rcu_free_regdom(get_wiphy_regdom(hw->wiphy))	

>  failed_bind:
>  	device_unregister(data->dev);
> @@ -3454,6 +3456,8 @@ static void mac80211_hwsim_del_radio(struct mac80211_hwsim_data *data,
>  {
>  	hwsim_mcast_del_radio(data->idx, hwname, info);
>  	debugfs_remove_recursive(data->debugfs);
> +	if (data->regd)
> +		kfree_rcu(get_wiphy_regdom(data->hw->wiphy));
this is not correct, because ieee80211_unregister_hw below will free
data->hw_wiphy->regd
>  	ieee80211_unregister_hw(data->hw);
>  	device_release_driver(data->dev);
>  	device_unregister(data->dev);
> 

  parent reply	other threads:[~2021-07-23  9:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-23  5:09 Dongliang Mu
2021-07-23  5:16 ` Dongliang Mu
2021-07-23  8:37 ` Johannes Berg
2021-07-23  9:13   ` Dongliang Mu
2021-07-23  9:18     ` Johannes Berg
2021-07-23  9:30       ` Dongliang Mu
2021-07-23  9:42         ` Johannes Berg
2021-07-23  9:59           ` Dongliang Mu
2021-07-23  9:18 ` xiaoqiang zhao [this message]
2021-07-23  9:25   ` Dongliang Mu
2021-07-23  9:36     ` xiaoqiang zhao
2021-07-23  9:44       ` Dongliang Mu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6fa2aecc-ab64-894d-77c2-0a19b524cc03@gmail.com \
    --to=zhaoxiaoqiang007@gmail.com \
    --cc=davem@davemloft.net \
    --cc=ilan.peer@intel.com \
    --cc=johannes.berg@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luciano.coelho@intel.com \
    --cc=mudongliangabcd@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=syzbot+1638e7c770eef6b6c0d0@syzkaller.appspotmail.com \
    --subject='Re: [PATCH] cfg80211: free the object allocated in wiphy_apply_custom_regulatory' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).