Skip to content

Commit e8fa86b

Browse files
martinwilligregkh
authored andcommitted
wifi: mac80211_hwsim: Limit destroy_on_close radio removal to netgroup
[ Upstream commit c74619e ] hwsim radios marked destroy_on_close are removed when the Netlink socket that created them is closed. As the portid is not unique across network namespaces, closing a socket in one namespace may remove radios in another if it has the destroy_on_close flag set. Instead of matching the network namespace, match the netgroup of the radio to limit radio removal to those that have been created by the closing Netlink socket. The netgroup of a radio identifies the network namespace it was created in, and matching on it removes a destroy_on_close radio even if it has been moved to another namespace. Fixes: 100cb9f ("mac80211_hwsim: Allow managing radios from non-initial namespaces") Signed-off-by: Martin Willi <martin@strongswan.org> Link: https://patch.msgid.link/20251103082436.30483-1-martin@strongswan.org Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent c43fe48 commit e8fa86b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/net/wireless/virtual/mac80211_hwsim.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6411,14 +6411,15 @@ static struct genl_family hwsim_genl_family __ro_after_init = {
64116411
.n_mcgrps = ARRAY_SIZE(hwsim_mcgrps),
64126412
};
64136413

6414-
static void remove_user_radios(u32 portid)
6414+
static void remove_user_radios(u32 portid, int netgroup)
64156415
{
64166416
struct mac80211_hwsim_data *entry, *tmp;
64176417
LIST_HEAD(list);
64186418

64196419
spin_lock_bh(&hwsim_radio_lock);
64206420
list_for_each_entry_safe(entry, tmp, &hwsim_radios, list) {
6421-
if (entry->destroy_on_close && entry->portid == portid) {
6421+
if (entry->destroy_on_close && entry->portid == portid &&
6422+
entry->netgroup == netgroup) {
64226423
list_move(&entry->list, &list);
64236424
rhashtable_remove_fast(&hwsim_radios_rht, &entry->rht,
64246425
hwsim_rht_params);
@@ -6443,7 +6444,7 @@ static int mac80211_hwsim_netlink_notify(struct notifier_block *nb,
64436444
if (state != NETLINK_URELEASE)
64446445
return NOTIFY_DONE;
64456446

6446-
remove_user_radios(notify->portid);
6447+
remove_user_radios(notify->portid, hwsim_net_get_netgroup(notify->net));
64476448

64486449
if (notify->portid == hwsim_net_get_wmediumd(notify->net)) {
64496450
printk(KERN_INFO "mac80211_hwsim: wmediumd released netlink"

0 commit comments

Comments
 (0)