Hi,
> -----Original Message-----
> From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> Sent: Friday, January 28, 2022 5:53 AM
> To: Pkshih <pkshih@realtek.com>
> Cc: linux-wireless@vger.kernel.org; tony0620emma@gmail.com; kvalo@codeaurora.org;
> johannes@sipsolutions.net; netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Neo Jou
> <neojou@gmail.com>; Jernej Skrabec <jernej.skrabec@gmail.com>; Ed Swierk <eswierk@gh.st>
> Subject: Re: [PATCH v3 0/8] rtw88: prepare locking for SDIO support
>
> Hi Ping-Ke,
>
> On Mon, Jan 24, 2022 at 3:59 AM Pkshih <pkshih@realtek.com> wrote:
[...]
> >
> > To avoid this, we can add a flag to struct rtw_vif, and set this flag
> > when ::remove_interface. Then, only collect vif without this flag into list
> > when we use iterate_actiom().
> >
> > As well as ieee80211_sta can do similar fix.
> >
I would prefer my method that adds a 'bool disabled' flag to struct rtw_vif/rtw_sta
and set it when ::remove_interface/::sta_remove. Then rtw_iterate_stas() can
check this flag to decide whether does thing or not.
[...]
>
> For the sta use-case I thought about adding a dedicated rwlock
> (include/linux/rwlock.h) for rtw_dev->mac_id_map.
> rtw_sta_{add,remove} would take a write-lock.
> rtw_iterate_stas() takes the read-lock (the lock would be acquired
> before calling into ieee80211_iterate_...). Additionally
> rtw_iterate_stas() needs to check if the station is still valid
> according to mac_id_map - if not: skip/ignore it for that iteration.
> This could be combined with your
> 0001-rtw88-use-atomic-to-collect-stas-and-does-iterators.patch.
Using a 'disabled' flag within rtw_vif/rtw_sta will be intuitive and
better than bitmap of mac_id_map. Please reference my mention above.
>
> For the interface use-case it's not clear to me how this works at all.
> rtw_ops_add_interface() has (in a simplified view):
> u8 port = 0;
> // the port variable is never changed
> rtwvif->port = port;
> rtwvif->conf = &rtw_vif_port[port];
> rtw_info(rtwdev, "start vif %pM on port %d\n", vif->addr, rtwvif->port);
> How do multiple interfaces (vifs) work in rtw88 if the port is always
> zero? Is some kind of tracking of the used ports missing (similar to
> how we track the used station IDs - also called mac_id - in
> rtw_dev->mac_id_map)?
The port should be allocated dynamically if we support two or more vifs.
We have internal tree that is going to support p2p by second vif.
Ping-Ke
Hi Ping-Ke, On Fri, Jan 28, 2022 at 1:51 AM Pkshih <pkshih@realtek.com> wrote: [...] > > > > > > > To avoid this, we can add a flag to struct rtw_vif, and set this flag > > > when ::remove_interface. Then, only collect vif without this flag into list > > > when we use iterate_actiom(). > > > > > > As well as ieee80211_sta can do similar fix. > > > > > I would prefer my method that adds a 'bool disabled' flag to struct rtw_vif/rtw_sta > and set it when ::remove_interface/::sta_remove. Then rtw_iterate_stas() can > check this flag to decide whether does thing or not. That would indeed be a very straight forward approach and easy to read. In net/mac80211/iface.c there's some cases where after drv_remove_interface() (which internally calls our .remove_interface op) will kfree the vif (sdata). Doesn't that then result in a use-after-free if we rely on a boolean within rtw_vif? [...] > > For the interface use-case it's not clear to me how this works at all. > > rtw_ops_add_interface() has (in a simplified view): > > u8 port = 0; > > // the port variable is never changed > > rtwvif->port = port; > > rtwvif->conf = &rtw_vif_port[port]; > > rtw_info(rtwdev, "start vif %pM on port %d\n", vif->addr, rtwvif->port); > > How do multiple interfaces (vifs) work in rtw88 if the port is always > > zero? Is some kind of tracking of the used ports missing (similar to > > how we track the used station IDs - also called mac_id - in > > rtw_dev->mac_id_map)? > > The port should be allocated dynamically if we support two or more vifs. > We have internal tree that is going to support p2p by second vif. I see, thanks for clarifying this! Best regards, Martin
Hi, On Sun, 2022-01-30 at 22:40 +0100, Martin Blumenstingl wrote: > > On Fri, Jan 28, 2022 at 1:51 AM Pkshih <pkshih@realtek.com> wrote: > [...] > > > > To avoid this, we can add a flag to struct rtw_vif, and set this flag > > > > when ::remove_interface. Then, only collect vif without this flag into list > > > > when we use iterate_actiom(). > > > > > > > > As well as ieee80211_sta can do similar fix. > > > > > > > > I would prefer my method that adds a 'bool disabled' flag to struct rtw_vif/rtw_sta > > and set it when ::remove_interface/::sta_remove. Then rtw_iterate_stas() can > > check this flag to decide whether does thing or not. > That would indeed be a very straight forward approach and easy to read. > In net/mac80211/iface.c there's some cases where after > drv_remove_interface() (which internally calls our .remove_interface > op) will kfree the vif (sdata). Doesn't that then result in a > use-after-free if we rely on a boolean within rtw_vif? The rtw_vif is drv_priv of ieee80211_vif, and they will be freed at the same time. We must set 'bool disabled' after holding rtwdev->mutex lock, and check this flag in iterator of ieee80211_iterate_active_interfaces_atomic() to contruct a list of vif. That means we never access this flag out of rtwdev->mutx or iterator. Does it make sense? -- Ping-Ke
© 2016 - 2026 Red Hat, Inc.