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] [thread-next>] [day] [month] [year] [list]
Message-ID: <523bb16608f48852b180121696d31cf82fb55484.camel@realtek.com>
Date:   Thu, 9 Jun 2022 02:55:01 +0000
From:   Ping-Ke Shih <pkshih@...ltek.com>
To:     "s.hauer@...gutronix.de" <s.hauer@...gutronix.de>,
        "linux-wireless@...r.kernel.org" <linux-wireless@...r.kernel.org>
CC:     "johannes@...solutions.net" <johannes@...solutions.net>,
        "kernel@...gutronix.de" <kernel@...gutronix.de>,
        "neojou@...il.com" <neojou@...il.com>,
        "kvalo@...nel.org" <kvalo@...nel.org>,
        "tony0620emma@...il.com" <tony0620emma@...il.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "martin.blumenstingl@...glemail.com" 
        <martin.blumenstingl@...glemail.com>,
        "linux@...i-kroll.de" <linux@...i-kroll.de>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [PATCH v2 05/10] rtw88: iterate over vif/sta list non-atomically

On Mon, 2022-05-30 at 15:54 +0200, Sascha Hauer wrote:
> The driver uses ieee80211_iterate_active_interfaces_atomic()
> and ieee80211_iterate_stations_atomic() in several places and does
> register accesses in the iterators. This doesn't cope with upcoming
> USB support as registers can only be accessed non-atomically.
> 
> Split these into a two stage process: First use the atomic iterator
> functions to collect all active interfaces or stations on a list, then
> iterate over the list non-atomically and call the iterator on each
> entry.
> 
> Signed-off-by: Sascha Hauer <s.hauer@...gutronix.de>
> Suggested-by: Pkshih <pkshih@...ltek.com>
> ---
> 
> Notes:
>     Changes since v1:
>     - Change subject
>     - Add some lockdep_assert_held(&rtwdev->mutex);
>     - make locally used functions static
>     - Add comment how &rtwdev->mutex protects us from stations/interfaces
>       being deleted between collecting them and iterating over them.
> 
>  drivers/net/wireless/realtek/rtw88/phy.c  |   6 +-
>  drivers/net/wireless/realtek/rtw88/ps.c   |   2 +-
>  drivers/net/wireless/realtek/rtw88/util.c | 103 ++++++++++++++++++++++
>  drivers/net/wireless/realtek/rtw88/util.h |  12 ++-
>  4 files changed, 116 insertions(+), 7 deletions(-)
> 
> 

[...]

> +
> +struct rtw_vifs_entry {
> +	struct list_head list;
> +	struct ieee80211_vif *vif;
> +	u8 mac[ETH_ALEN];
> +};
> +
> +struct rtw_iter_vifs_data {
> +	struct rtw_dev *rtwdev;
> +	struct list_head list;
> +};
> +
> +void rtw_collect_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)

You do this change in patch "rtw88: Add common USB chip support".
Please move to here.

-void rtw_collect_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)
+static void rtw_collect_vif_iter(void *data, u8 *mac, struct ieee80211_vif *vif)

> +{
> +	struct rtw_iter_vifs_data *iter_stas = data;
> +	struct rtw_vifs_entry *vifs_entry;
> +
> +	vifs_entry = kmalloc(sizeof(*vifs_entry), GFP_ATOMIC);
> +	if (!vifs_entry)
> +		return;
> +
> +	vifs_entry->vif = vif;
> +	ether_addr_copy(vifs_entry->mac, mac);
> +	list_add_tail(&vifs_entry->list, &iter_stas->list);
> +}
> +
> +void rtw_iterate_vifs(struct rtw_dev *rtwdev,
> +		      void (*iterator)(void *data, u8 *mac,
> +				       struct ieee80211_vif *vif),
> +		      void *data)
> +{
> +	struct rtw_iter_vifs_data iter_data;
> +	struct rtw_vifs_ent

[...]

> diff --git a/drivers/net/wireless/realtek/rtw88/util.h b/drivers/net/wireless/realtek/rtw88/util.h
> index 0c23b5069be0b..dc89655254002 100644
> --- a/drivers/net/wireless/realtek/rtw88/util.h
> +++ b/drivers/net/wireless/realtek/rtw88/util.h
> @@ -7,9 +7,6 @@
>  
>  struct rtw_dev;
>  
> -#define rtw_iterate_vifs(rtwdev, iterator, data)                               \
> -	ieee80211_iterate_active_interfaces(rtwdev->hw,                        \
> -			IEEE80211_IFACE_ITER_NORMAL, iterator, data)
>  #define rtw_iterate_vifs_atomic(rtwdev, iterator, data)                        \
>  	ieee80211_iterate_active_interfaces_atomic(rtwdev->hw,                 \
>  			IEEE80211_IFACE_ITER_NORMAL, iterator, data)

After read Martin's patches, I think we can review all places where use
_aotmic version of vif and sta, even we don't really meet problem for now.
Then, use non-atomic version if possible.

Ping-Ke


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ