Linux wireless drivers development
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: linux-wireless@vger.kernel.org
Subject: Re: [RFC PATCH 03/12] wifi: mac80211: implement lockless beacon updates
Date: Fri, 09 Oct 2026 18:05:27 +0200	[thread overview]
Message-ID: <20c60c055382b8c1cb7e147b7af25d5dd270d59c.camel@sipsolutions.net> (raw)
In-Reply-To: <20261004234504.dc783ba26923.Icfbcd157ac2bdeccfcc74a9f4c3997d3010ec0a9@changeid>

On Sun, 2026-10-04 at 23:40 +0200, Johannes Berg wrote:
> The regular beacon update can no longer reliably access
> the old beacon across the allocation (or we'd have to do
> all those atomically), so if userspace does both at the
> same time, we may send a corrupt beacon due to min() in
> the copy. This won't happen with hostapd even if it were
> to race, since it always sends both head and tail.

Heh. Aloka got really lucky, I went to rebase this now and it conflicts
pretty badly - not just patch wise but semantically - with the MBSSID
old beacon data fix.

This should never happen, but if a normal locked update is running while
an unlocked update replaces the beacon (including head, tail and mbssid
data), then the locked update cannot use the old beacon head, tail or
mbssid data at the same time, it might go away concurrently.

For the head/tail I basically said above that doesn't matter, we'll send
garbage if hostapd is causing garbage (just use whichever head/tail we
find, min() on the size); for the MBSSID data that doesn't really work,
the MBSSID fix said:

    Hostapd passes two Beacon templates to kernel for CSA and CCA -
    (1) beacon_csa/beacon_color_change used during the countdown.
    (2) beacon_after/beacon_next used after the countdown completes.
    Hostapd relies on the kernel to include the old MBSSID elements
    while sending beacon_csa/beacon_color_change templates to the
    driver.

So ... where does that leave us here.

I think the only good solution is to say this race will never happen
anyway, hostapd clearly won't do update-beacon and set-beacon at the
same time for the same interface. But we have to protect memory safety
in the kernel anyway.

So I think I'll change this to track "is a locked beacon update in
progress", and then an unlocked beacon update just returns -EAGAIN if it
finds (under the spinlock) that to be true. Presumably that'll never
happen, but if it does then it'll be correct. It also means that
unlocked beacon updates always have to come with their own MBSSID data.

johannes

  reply	other threads:[~2026-10-09 16:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-04 21:40 [RFC PATCH 00/12] wifi: AP side locking improvements Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 01/12] wifi: mac80211: protect AP template pointers with a spinlock Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 02/12] wifi: nl80211: add NL80211_CMD_UPDATE_BEACON Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 03/12] wifi: mac80211: implement lockless beacon updates Johannes Berg
2026-10-09 16:05   ` Johannes Berg [this message]
2026-10-04 21:40 ` [RFC PATCH 04/12] wifi: mac80211_hwsim: support " Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 05/12] wifi: cfg80211: make cookie counter atomic Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 06/12] wifi: nl80211: allow mgmt frame TX without wiphy mutex Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 07/12] wifi: mac80211: refactor mgmt frames TX Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 08/12] wifi: mac80211: implement mgmt_tx_unlocked() Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 09/12] wifi: mac80211: don't require wiphy mutex for probe_peer Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 10/12] wifi: nl80211: probe peers without wiphy mutex Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 11/12] wifi: mac80211: don't require wiphy mutex for control port TX Johannes Berg
2026-10-04 21:40 ` [RFC PATCH 12/12] wifi: nl80211: transmit control port frames without wiphy mutex Johannes Berg
2026-10-05  8:43 ` [RFC PATCH 00/12] wifi: AP side locking improvements Johannes Berg
2026-10-06  2:05 ` Jeff Johnson
2026-10-06  7:14   ` Johannes Berg
2026-10-06  7:55     ` Johannes Berg

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=20c60c055382b8c1cb7e147b7af25d5dd270d59c.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox