U30 SAE offload: a hotspot that cannot start goes back to WPA2, and what the offload really is

A BSS with u30_sae_offload=1 that could not start stayed down at every boot: after
mu300-update (it keeps /etc/config and replaces the packages, and the stock wpad refuses
a configuration with a key it does not know), when the firmware refuses the vendor
command, or in a mode the patch rejects. On a device reached only over its hotspot that
left USB as the only way in.

openwrt-wifi-sae-guard does nothing unless a wifi-iface carries the option. Before the
first wifi up (mu300-hw) it looks whether the installed hostapd has the option; about two
minutes after boot (mu300-post, after its retry) whether the access point is ENABLED. If
not, the BSS becomes psk2 with the same passphrase, the file as it was is kept in
/etc/mu300/wireless.sae-offload, and mu300-wifi logs one error line. A hotspot that is
off on purpose (disabled, Wi-Fi client, scan mode, the Wi-Fi key) is left alone.

Review, in docs/U30AIR-SAE.md and FINDINGS 80: the driver sends the firmware the
passphrase only (the group is parsed and never counted, an ACT of 0xffffffff is its
"not set"), the gate is the option plus the firmware's soft-AP WPA3 capability and not
the device, which kernels have run it (7.2.9), where the passphrase and the PMK travel,
what hostapd no longer does. A probe for the open PMK-provenance finding in the handoff.
The wiki says the hotspot is WPA2.

Tests: the guard under dash, bash and busybox ash with stub uci/ubus; with
MU300_WRT_IMAGE the hostapd configuration wifi-scripts write for the opt-in and for the
fallback (the fallback is the stock WPA2 configuration).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVN2zDgf76kMDVSuWhHPUE
This commit is contained in:
Abdurrahman Kaan DikeçandClaude Opus 5.5 committed 2026-10-13 09:57:35 +03:00
1 parent 3ec2539226
commit d45cd211f7
9 files changed
+463 -5

No files matched your search

+33 -1
View File
@@ -125,7 +125,7 @@ what replaced it. The table below gives each section's state.
| 57 | A 64 GB unit whose partition table has `userdata` filling the disk, and no way to make room from Windows (#32) | current (fixed; unit tests against a table built from #9's figures, not measured on a device) |
| 58 | A service's own error in an HTTP 200 answer to the SMS webhook: a KEY=VALUE check of the answer; a button that clears the delivery log (#171) | current (unit tests; measured on the U30 Air against a fake webhook, not against the real services) |
| 60 | `/run` takes files from every user: the daemons' directories there are checked, and a squatted name is put out of the way (review of #145/#149) | current (fixed for mu300-atd and mu300-voice, F50-B on 5.4 and 7.2.10); `/run` itself is still 1777 |
| 80 | WPA3 on the U30 Air's access point: the SC2355 firmware does SAE itself (PR #74, Snrat) | experimental, opt-in; PMK provenance open |
| 80 | WPA3 on the U30 Air's access point: the SC2355 firmware does SAE itself (PR #74, Snrat) | experimental, opt-in build recipe (7.2.9 only); PMK provenance open; the WPA2 fallback not yet run on a device |
## Hardware and firmware facts
@@ -4830,6 +4830,16 @@ showed, on one U30 Air (OpenWrt 25.12.5, Linux 7.2.9):
firmware answers each association with the derived PMK and PMKID as a trailing vendor element in the
`NEW_STATION` IE buffer: EID 221, length 52, prefix `40:45:da:04`, then 32 + 16 bytes. Hunting-and-pecking,
group 19 only; H2E-only clients and other groups untested.
* **Only the passphrase reaches the firmware.** `vendor_set_sae_password` (`sc2355/vendor.c`) stores the group and
never increments `group_count`, so `vendor_softap_convert_para` writes no group TLV; and it writes the ACT TLV only
when `setting->act != -1`, which `0xffffffff` is not. `CMD_SET_SAE_PARAM` therefore carries the entry, the
passphrase and the end marker: group 19 and the anti-clogging threshold are the firmware's defaults, and hostapd's
`sae_groups` and `sae_anti_clogging_threshold` do nothing in this mode. Left as it is: sending a group list the
firmware has never been given is a change nobody has measured.
* **The gate is the option and a firmware capability, not the device.** The driver answers the vendor command with
`-ENOTSUPP` unless the firmware reports `SPRD_EXTEND_SOATAP_WPA3`. The F50 has the same chip and driver; what its
firmware reports is not known. The command exists in the 5.4 vendor driver as well as in the mainline port;
only 7.2.9 has run it.
* **The PMK arrives in a client-controlled buffer.** The driver passes `evt_new_station.ie` straight through as
`assoc_req_ies` (`sc2355/cmdevt.c` -> `common/report.c`), the same bytes that carry the station's own IEs. The
parser accepts exactly one trailing element and rejects any second marker, which only holds if the firmware
@@ -4844,9 +4854,31 @@ showed, on one U30 Air (OpenWrt 25.12.5, Linux 7.2.9):
untouched, the generated `hostapd-phy0.conf` has no `sae`/`u30_sae` key, a WPA2 client is back 32 s after the
package swap, the VPN stays up. The mode needs pure SAE, `ieee80211w=2`, `sae_pwe=0` and PMKSA caching, and a
BSS with the option and any other mode fails closed (`Failed to set beacon parameters`, AP-DISABLED).
In the patch every new path starts from `u30_sae_offload` (the configuration check, the firmware request, the
key import); the one line that is not behind it replaces hostapd's debug hex dump of the association IEs with their
length. OpenWrt's wifi-scripts turn the documented UCI settings into `wpa_key_mgmt=SAE`, `ieee80211w=2`,
`sae_pwe=0`, `u30_sae_offload=1` and `wpa_passphrase` (no `sae_password`, which the patch refuses), checked with
the 25.12.5 scripts in a container.
* **A second BSS with the option, added live, took the radio down (2026-10-12).** `wifi reload` with a new
`wifi-iface` (`encryption sae`, `ieee80211w 2`, `sae_pwe 0`, `u30_sae_offload=1`) next to the WPA2 hotspot: both
SSIDs disappeared and did not come back within ten minutes. The device could only be reached over that hotspot,
so the cause is not known yet (hostapd gives the whole phy up when one BSS fails to set up; the earlier maintainer
test used a separate BSS with r6 and a full `wifi down/up`). Enable the option on a device you can reach another
way, and with a full `wifi down; wifi up`, never `wifi reload`.
Snrat's r9 refuses a second BSS when the configuration is loaded (`U30 SAE: supports a single BSS only`); on his
device, with `logread -f` over USB, the refusal still took the running WPA2 BSS down with it through netifd's
reload. The cause of the r8 outage itself was never captured.
* **A hotspot that could not start stayed down at every boot; now it goes back to WPA2 (2026-10-13).** Three roads
to it: `mu300-update` keeps `/etc/config` and replaces the packages, and the stock wpad refuses a configuration with
a key it does not know; the firmware refuses the vendor command; the patch rejects the mode.
`openwrt-wifi-sae-guard` (does nothing without the option) looks before the first `wifi up` whether the installed
hostapd has the option, and about two minutes after boot whether the access point is `ENABLED`; if not, the BSS
becomes `psk2` with the same passphrase, the file as it was is kept in `/etc/mu300/wireless.sae-offload`, and
`mu300-wifi` logs one error line. WPA2 because hostapd's own SAE cannot work on this driver (first point). Unit
tests only (stub `uci`/`ubus`, dash, bash, busybox ash); not yet run on a device.
* **Built, 2026-10-13:** `sprd_wlan_combo` with these removals for 7.2.10 and 6.18.56 (with `wcn_bsp`; the five touched
files warn only where the vendor's code always did, none of the removed format strings is in the module);
for 5.4 the twelve `wlan_combo-*.patch` apply in the build's order on the pristine vendor driver and all 69 objects
compile (the module was not linked: ThinLTO wants to write next to the kernel's objects). The hostapd patch applies
with GNU patch after OpenWrt 25.12.5's own patches on `ca266cc2` (BSD patch rejects the `ap_config.c` hunk, which
has no leading context: build in the SDK, not on macOS).
+15 -2
View File
@@ -114,5 +114,18 @@ authentication bypass should be made solely from a failed client connection.
The outstanding boundary and its detailed validation are being handed back
to the maintainer. No controlled-frame or authentication-manipulation test
implementation is included in this contribution. Keep PR #74 on hold until
the maintainer has resolved and reviewed that part.
implementation is included in this contribution. PR #74 was continued as #165;
this finding is open in both, and the mode stays an opt-in experiment until
it is resolved.
A first probe that needs no new interface, only a Linux client whose frames can
be shaped (a mac80211 card with wpa_supplicant): add a PMKSA of your own choice
for the access point (`wpa_cli pmksa_add`), so the client skips SAE and sends
Open System authentication with that PMKID, and append the matching
`dd 34 40 45 da 04 <PMK> <PMKID>` element to the association request
(`wpa_cli vendor_elem_add 13 ...`; it has to be the last element of the frame,
check with a capture). If the firmware refuses the association, or
appends its own element (two markers, rejected by the parser), the simplest
form of the bypass is closed on this firmware. If the client completes the
four-way handshake without knowing the passphrase, the bypass is real and the
mode must not be used. Either result goes into FINDINGS 80.
+97
View File
@@ -9,6 +9,99 @@ recipe (`openwrt/build-u30-sae.sh`, `MU300_SAE_APK_DIR` for `build-rootfs.sh`)
and does nothing until `u30_sae_offload=1` is set on a BSS. Nothing changes for
a device that does not opt in on both counts.
## What the offload is, and what it is not (maintainer review, 2026-10-13)
- **Where SAE runs.** In the SC2355 firmware, on every kernel: the driver registers
the access point with the SME in the firmware, so hostapd never sees an
authentication frame. Nothing in this branch changes what the driver or the
firmware does; the only code that turns the mode on is the hostapd patch, in
userspace. It uses two things the vendor driver already had: vendor command OUI
`0x001374`, subcommand 43 (`vendor_set_sae_password` in `sc2355/vendor.c`, which
sends `CMD_SET_SAE_PARAM` to the chip) and the IE buffer of the `NEW_STATION` event.
- **Kernels.** One driver source serves 5.4 (the vendor tree plus
`kernel/patches/wlan_combo-*.patch`) and 6.18/7.2 (`upstream/modules/sprd_wlan_combo`),
and the vendor command is in both. Measured only on 7.2.9. On 5.4 and 6.18 the
driver builds with these changes and the option has never been run.
- **Devices.** The switch is the option, not a check of the device. The driver
refuses the vendor command unless the firmware reports soft-AP WPA3
(`SPRD_EXTEND_SOATAP_WPA3`); hostapd then logs `U30 SAE: firmware configuration
failed`, the access point does not start, and the guard below puts WPA2 back.
The F50 has the same chip and driver; whether its firmware reports the capability
is not known, nobody has tried.
- **What the password request really carries: the passphrase, nothing else.** The
driver parses the group attribute and never counts it (`group_count` stays 0 in
`vendor_set_sae_password`), so no group reaches the firmware; and an ACT of
`0xffffffff` is the driver's "not set" (`setting->act != -1`), so no
anti-clogging threshold is sent either. Group 19 and the anti-clogging behaviour
are the firmware's own defaults. hostapd's `sae_groups` and
`sae_anti_clogging_threshold` have no effect in this mode.
- **What hostapd still does:** validation of the RSN element, the four-way handshake
(with the imported PMK), mandatory PMF, group key handling.
**What it no longer does:** the SAE exchange itself: commit and
confirm, anti-clogging, group negotiation, the choice between hunting-and-pecking
and H2E. The firmware does hunting-and-pecking only; how well it resists the
timing attacks on that method (Dragonblood) is unknown, the firmware is closed.
- **Other clients and modes.** A WPA2 client cannot join such a BSS: the patch
accepts pure SAE with required PMF only, and refuses WPA2/WPA3 mixed mode, optional
PMF and a second BSS when the configuration is loaded. The Wi-Fi client (uplink)
mode is not touched: joining a WPA3-only network still does not work
([FINDINGS](FINDINGS.md) 14b).
- **Where the secrets go.** The passphrase: `/etc/config/wireless` and the generated
`/var/run/hostapd-phy0.conf` (as with WPA2), then one netlink vendor command, a
copy on the kernel's stack and heap that the driver does not wipe, and
`CMD_SET_SAE_PARAM` over PCIe into the chip's memory. The PMK comes back with every
association, in the `NEW_STATION` event, through nl80211 into hostapd's PMKSA
cache. With this branch's module and package pair none of it is written to a log
(see "Protocol integration").
- **Downgrade.** None over the air on such a BSS: pure SAE, PMF required, no
transition mode. The guard below is a downgrade made on the device itself, and it
is logged as an error.
## When the access point cannot start: the way back
Until 2026-10-13 a BSS with the option that could not start stayed down, at every
boot, and a device reached only over its hotspot had no way in but USB. Three roads
lead there: an update (`mu300-update` keeps `/etc/config` and replaces the packages:
the stock `wpad-basic-mbedtls` does not know `u30_sae_offload` and refuses the whole
configuration), a firmware that refuses the vendor command, and a configuration the
patch rejects (mixed mode, optional PMF, a second BSS).
`/opt/mu300/bin/openwrt-wifi-sae-guard` is in every OpenWrt image and does nothing
unless a `wifi-iface` has `u30_sae_offload=1` in its `hostapd_bss_options`:
- **At boot, before the first `wifi up`** (`mu300-hw`): the installed hostapd does
not have the option (its name is not in the binary). The option is taken out
before hostapd ever sees it.
- **About two minutes after boot** (`mu300-post`, after its one `wifi up` retry and
a further 60 s of waiting, long enough for automatic channel selection): the
access point is still not `ENABLED` in `ubus call hostapd.wlan0 get_status`.
In both cases the BSS becomes `encryption psk2` with the same passphrase,
`ieee80211w` and `sae_pwe` are deleted, the file as it was is kept in
`/etc/mu300/wireless.sae-offload` (root only), and `logread` has one line from
`mu300-wifi`: `WPA3 hotspot (U30 SAE offload): ... The hotspot is back on WPA2 with
the same password`. WPA2 and not hostapd's own SAE: without the offload a WPA3-only
BSS on this driver lets nobody in. The price is the one WPA3 was chosen to avoid:
a captured WPA2 handshake can be attacked offline, so use a long passphrase.
What this means in practice:
- **If the hotspot is gone after a change, reboot and wait three minutes.** It comes
back as WPA2. The guard acts at boot only; a change made live that takes the
access point down leaves it down until the reboot.
- It leaves a hotspot alone that is off on purpose: a disabled `wifi-iface` or
radio, the Wi-Fi client or its scan mode, the Wi-Fi key's "hotspot off".
- To go back to the offload afterwards: fix the cause, then
`cp /etc/mu300/wireless.sae-offload /etc/config/wireless` and the full restart
below.
- **Over USB** (always works, and the only place to read the log of a hotspot that is
down): `ssh root@192.168.78.1`, then `logread -e 'U30 SAE' -e mu300-wifi -e hostapd`.
By hand, the same as the guard:
`uci del_list wireless.ap0.hostapd_bss_options='u30_sae_offload=1'; uci set wireless.ap0.encryption=psk2; uci -q delete wireless.ap0.ieee80211w; uci -q delete wireless.ap0.sae_pwe; uci commit wireless; wifi down; /etc/init.d/wpad restart; wifi up`.
The guard is tested with stub `uci`/`ubus` under dash, bash and busybox ash
(`tests/test_u30_sae.py`); it has not run on a device yet.
## Outstanding PMK trust boundary (why this stays experimental)
Independent review in [PR #74](https://github.com/dikeckaan/mu300-linux/pull/74#issuecomment-6106003178)
@@ -54,6 +147,8 @@ kernel NEW_STATION event as a trailing vendor IE: EID 221, length 52, prefix
`40:45:da:04`. Only one complete trailing element is accepted, only when the
opt-in is enabled and firmware setup succeeded on a pure SAE/fullmac BSS.
Malformed/duplicate/truncated metadata is rejected by a length-bounded parser.
An association without an accepted element gets no PMK at all, and the four-way
handshake then fails as it does with the stock hostapd.
The key goes to the normal PMKSA/authenticator path; normal RSN validation,
four-way handshake MIC checks and required PMF remain in place. The metadata
needs a trustworthy firmware origin; the current shared IE buffer does not
@@ -76,6 +171,8 @@ also requires PMKSA caching: leave `disable_pmksa_caching=0` (the default).
The helper now checks this before sending the firmware password request and
reports the unsupported configuration. Removing the offload option restores
the normal configuration path.
A hotspot that stays down this way comes back as WPA2 after a reboot
(see "When the access point cannot start" above).
This experiment supports **one enabled AP BSS per radio**. Do not add a
second SAE test SSID next to a WPA2 hotspot. The driver interface-combination
+2
View File
@@ -19,6 +19,8 @@ hw_bringup() {
# cfg80211 looked for regulatory.db before the rootfs was mounted; load it now so hostapd sees the country rules
/opt/mu300/bin/regdb-load >>/tmp/mu300-wifi-start.log 2>&1
/opt/mu300/bin/openwrt-wifi-config >>/tmp/mu300-wifi-start.log 2>&1
# a WPA3 hotspot with the U30 SAE offload (opt-in, docs/U30AIR-SAE.md) on a hostapd that does not have it: WPA2
/opt/mu300/bin/openwrt-wifi-sae-guard precheck >>/tmp/mu300-wifi-start.log 2>&1
# the U30 Air's NFC tag: the hotspot's name and password, if that is what it holds (see mu300-nfc)
[ "$(/opt/mu300/bin/mu300-device)" = u30air ] && /opt/mu300/bin/mu300-nfc sync >/tmp/mu300-nfc.log 2>&1
# apply the country before netifd starts hostapd, otherwise 5 GHz channels are still NO-IR under world rules
+2 -1
View File
@@ -36,8 +36,9 @@ start_service() {
procd_set_param env PATH="$PATH"
procd_close_instance
# the SC2355 sometimes refuses the first IFF_UP (EIO); if the AP did not come up, try once more
# (a WPA3 hotspot with the U30 SAE offload that still is not up then goes back to WPA2: openwrt-wifi-sae-guard)
procd_open_instance wifiretry
procd_set_param command /bin/sh -c "sleep 45; [ -e /sys/class/net/wlan0 ] || exit 0; ubus call hostapd.wlan0 get_status >/dev/null 2>&1 || { logger -t mu300-post 'AP not up, retrying'; wifi up; sleep 15; }; /opt/mu300/bin/mu300-led wifi sync"
procd_set_param command /bin/sh -c "sleep 45; [ -e /sys/class/net/wlan0 ] || exit 0; ubus call hostapd.wlan0 get_status >/dev/null 2>&1 || { logger -t mu300-post 'AP not up, retrying'; wifi up; sleep 15; }; /opt/mu300/bin/openwrt-wifi-sae-guard verify; /opt/mu300/bin/mu300-led wifi sync"
procd_close_instance
# a newer release: a note at login (/etc/profile.d/mu300-update.sh) and in mu300-toolkit, nothing installed
procd_open_instance updatenotice
+81
View File
@@ -0,0 +1,81 @@
#!/bin/sh
# OpenWrt only: the way back from the U30 Air's firmware SAE offload (docs/U30AIR-SAE.md, FINDINGS 80), for a device
# whose hotspot is the only way in. Does nothing unless a wifi-iface carries "u30_sae_offload=1" in its
# hostapd_bss_options, which no image sets.
# openwrt-wifi-sae-guard precheck at boot, before the first "wifi up" (mu300-hw): the installed hostapd does not
# know the option - the stock wpad after mu300-update, which keeps /etc/config and
# replaces the packages - and would refuse the whole configuration
# openwrt-wifi-sae-guard verify after boot (mu300-post, after its one retry): the access point is still not up
# (the firmware refused the vendor command, a mode the patch rejects, a second BSS)
# Either way the hotspot goes back to WPA2 with the same password, the option is taken out, the settings it had are
# kept in /etc/mu300/wireless.sae-offload, and one line in the log says so. WPA2 and not hostapd's own SAE: on this
# driver the firmware does the SAE exchange, so a WPA3 hotspot without the offload lets nobody in (FINDINGS 80).
# The passphrase is then open to an offline guess from a captured WPA2 handshake, which WPA3 was chosen to prevent:
# that is the price of a device that can be reached, and why the line is logged as an error.
# (MU300_SYSROOT, MU300_SAE_WAIT: for tests/)
R=${MU300_SYSROOT:-}
WAIT=${MU300_SAE_WAIT:-60}
[ -f "$R/etc/openwrt_release" ] || exit 0
sections() { # the wifi-ifaces with the option, one name per line
uci -q show wireless | sed -n "s/^wireless\.\([^.=]*\)\.hostapd_bss_options=.*'u30_sae_offload=1'.*/\1/p"
}
enabled() { # an access point netifd would start
[ "$(uci -q get "wireless.$1.disabled")" != 1 ] || return 1
[ "$(uci -q get "wireless.$(uci -q get "wireless.$1.device").disabled")" != 1 ] || return 1
case $(uci -q get "wireless.$1.mode") in ap|'') return 0 ;; esac
return 1
}
ap_up() {
ifn=$(uci -q get "wireless.$1.ifname"); ifn=${ifn:-wlan0}
ubus -t 5 call "hostapd.$ifn" get_status 2>/dev/null | grep -q '"status": *"ENABLED"'
}
off_on_purpose() { # the radio is a Wi-Fi client, in scan mode, or the Wi-Fi key turned the hotspot off
[ -e "$R/run/mu300-wifi-client.active" ] || [ -e "$R/run/mu300-wifi-scan-mode" ] ||
[ -e "$R/run/mu300/power/hotspot-off" ]
}
fall_back() { # fall_back REASON SECTION...
reason=$1; shift
mkdir -p "$R/etc/mu300"
( umask 077; cat "$R/etc/config/wireless" > "$R/etc/mu300/wireless.sae-offload" ) 2>/dev/null
for s in "$@"; do
uci -q del_list "wireless.$s.hostapd_bss_options=u30_sae_offload=1"
uci -q set "wireless.$s.encryption=psk2"
uci -q delete "wireless.$s.ieee80211w"
uci -q delete "wireless.$s.sae_pwe"
done
uci commit wireless
msg="WPA3 hotspot (U30 SAE offload): $reason. The hotspot is back on WPA2 with the same password; the settings it had are in /etc/mu300/wireless.sae-offload"
echo "$msg" >&2
logger -t mu300-wifi -p daemon.err "$msg" 2>/dev/null || true
}
all=$(sections)
[ -n "$all" ] || exit 0
case ${1:-} in
precheck)
hostapd=$R/usr/sbin/hostapd
[ -e "$hostapd" ] || hostapd=$R/usr/sbin/wpad
[ -e "$hostapd" ] || exit 0
grep -q u30_sae_offload "$hostapd" && exit 0
# shellcheck disable=SC2086
fall_back "the installed hostapd does not have it" $all ;;
verify)
n=0
while :; do
off_on_purpose && exit 0
failed=
for s in $all; do enabled "$s" && ! ap_up "$s" && failed="$failed $s"; done
[ -n "$failed" ] || exit 0
[ "$n" -lt "$WAIT" ] || break
sleep 5; n=$((n + 5))
done
# shellcheck disable=SC2086
fall_back "the access point did not start" $failed
# a full restart, as every change of this mode needs (docs/U30AIR-SAE.md)
wifi down >/dev/null 2>&1
[ ! -x "$R/etc/init.d/wpad" ] || "$R/etc/init.d/wpad" restart >/dev/null 2>&1
wifi up >/dev/null 2>&1 ;;
*) echo "usage: $0 precheck|verify" >&2; exit 2 ;;
esac
exit 0
+1
View File
@@ -48,6 +48,7 @@ macOS and Windows (`.github/workflows/tests.yml`).
| `test_usb_management.py` | the panel's USB management (`device-usb`, K7, K8, D12): role switch, host mode, NIC reattachment, the USB network mode file `boot/init` applies on the next boot |
| `test_traffic.py` | `mu300-traffic` (the mobile data count): the first reading is a base, a reboot, a re-created interface or a lower counter counts the new counters once, another interface is only a base; midnight splits by time in local days, a clock jump does not stretch an interval, a DST change keeps every byte; bytes wait for NTP and are dated by uptime (an earlier boot's go to the day NTP comes); billing cycles (reset day 31, February, leap years), `used` and `clear`; the cap's warning and the cut (once per cycle, again after a reboot, a hand-made override kept, restored at the next cycle or a higher cap; OpenWrt and Ubuntu); the service's save at SIGTERM, one instance, a stale lock |
| `test_wifi_channels.py` | the hotspot never on a DFS channel (FINDINGS 42): `lib/wifi-channels.sh` (the country table, a DFS channel replaced with one line why, `auto`, widths), `hotspot-start`'s hostapd configuration (stub `iw`), `openwrt-wifi-config` and `mu300-wifi-band` on OpenWrt (stub `uci`), how the build applies `openwrt/patches/wifi-scripts-no-dfs.patch`; with `MU300_WRT_IMAGE` (an OpenWrt 25.12 arm64 docker image, e.g. `mu300-openwrt-base:25.12.5`) the patched wifi-scripts of the feed and the hostapd configuration they generate for a fake wiphy |
| `test_u30_sae.py` | the opt-in U30 Air SAE offload (FINDINGS 80): the trailer parser compiled from the hostapd patch (every truncation, duplicate and stray markers, random input, with UBSan where the compiler has it), the patch's configuration check and firmware request against fake driver calls, `openwrt/build-u30-sae.sh` with a stub SDK, the driver sources without the key and payload dumps, `openwrt-wifi-sae-guard` (stub `uci`/`ubus`: nothing without the option, WPA2 again when hostapd lacks it or the access point does not start, a hotspot that is off on purpose left alone); with `MU300_WRT_IMAGE` the hostapd configuration wifi-scripts write for the opt-in and for the fallback |
| `test_wifi.py` | `wifi-start` loads the WCN modules without `modules.dep` (K55); `mu300-hw` restarts the AP once the country is live (K15) |
| `test_early_replay_hook.py` | the early hook that replays the LuCI plugin's saved locks before the radio comes on (K65): its place in `mobile-data` |
| `test_unisoc_plugin.py` | the plugin's portable adapter boundary (K81): the custom AT backend contract, `--available` sends nothing, `boot-replay` (zero AT traffic when disabled, late replay, the early window), `lock replay early` restores every saved lock without `SFUN` |
+228 -1
View File
@@ -1,4 +1,5 @@
"""Compile the actual metadata parser from the hostapd patch, with malformed IE input."""
import json
import random
import os
import shutil
@@ -8,7 +9,7 @@ import tempfile
import unittest
from pathlib import Path
from helpers import TOP, ShellTest
from helpers import BIN, TOP, ShellTest
PATCH = TOP / 'openwrt/patches/hostapd/990-u30-sae-offload.patch'
@@ -256,6 +257,232 @@ int main(void) {
self.assertEqual(r.returncode, 0, r.stderr)
UCI = r"""
[ "$1" = -q ] && shift
f=$STUBLOG/uci.state
case "$1" in
show) cat "$f" ;;
get) v=$(sed -n "s/^$2='\(.*\)'$/\1/p" "$f" | head -n1); [ -n "$v" ] || exit 1; echo "$v"; exit 0 ;;
set) k=${2%%=*}; grep -v "^$k=" "$f" > "$f.n"; echo "$k='${2#*=}'" >> "$f.n"; mv "$f.n" "$f" ;;
delete) grep -v "^$2=" "$f" > "$f.n"; mv "$f.n" "$f" ;;
del_list) k=${2%%=*}; sed -e "/^$k=/s/ *'${2#*=}'//" -e "/^$k=\$/d" "$f" > "$f.n"; mv "$f.n" "$f" ;;
commit) ;;
esac
[ "$1" = show ] || echo "$*" >> "$STUBLOG/uci.log"
exit 0
"""
# what `uci show wireless` prints for the documented opt-in (docs/U30AIR-SAE.md), with a synthetic passphrase
SAE_STATE = """wireless.radio0=wifi-device
wireless.radio0.band='5g'
wireless.ap0=wifi-iface
wireless.ap0.device='radio0'
wireless.ap0.mode='ap'
wireless.ap0.ifname='wlan0'
wireless.ap0.ssid='MU300-TEST'
wireless.ap0.encryption='sae'
wireless.ap0.key='synthetic-test-password'
wireless.ap0.ieee80211w='2'
wireless.ap0.sae_pwe='0'
wireless.ap0.hostapd_bss_options='max_listen_interval=10' 'u30_sae_offload=1'
"""
WPA2_STATE = """wireless.radio0=wifi-device
wireless.ap0=wifi-iface
wireless.ap0.device='radio0'
wireless.ap0.mode='ap'
wireless.ap0.ifname='wlan0'
wireless.ap0.encryption='psk2'
wireless.ap0.key='synthetic-test-password'
"""
class SaeGuard(ShellTest):
"""openwrt-wifi-sae-guard: a hotspot that cannot start with the offload goes back to WPA2; nothing else moves."""
GUARD = BIN / 'openwrt-wifi-sae-guard'
def setUp(self):
super().setUp()
self.root = self.tmp / 'root'
for d in ('etc/mu300', 'etc/config', 'etc/init.d', 'usr/sbin', 'run/mu300/power'):
(self.root / d).mkdir(parents=True)
(self.root / 'etc/openwrt_release').write_text('DISTRIB_ID=OpenWrt\n')
(self.root / 'etc/config/wireless').write_text('the file as it was\n')
wpad = self.root / 'etc/init.d/wpad'
wpad.write_text('#!/bin/sh\necho "wpad $*" >> "$STUBLOG/wifi.log"\n')
wpad.chmod(0o755)
self.hostapd(patched=True)
self.stub('uci', UCI)
# the access point is up from the Nth question on ($STUBLOG/ap-after), never without that file
self.stub('ubus', 'echo "$*" >> "$STUBLOG/ubus.log"\n'
'[ "$(wc -l < "$STUBLOG/ubus.log")" -ge "$(cat "$STUBLOG/ap-after" 2>/dev/null || echo 9999)" ]'
' || exit 4\nprintf \'{\\n\\t"status": "ENABLED",\\n\\t"freq": 5180\\n}\\n\'')
self.stub('wifi', 'echo "wifi $*" >> "$STUBLOG/wifi.log"')
self.stub('logger', 'echo "$*" >> "$STUBLOG/logger.log"')
self.stub('sleep', 'echo "$*" >> "$STUBLOG/sleep.log"')
def hostapd(self, patched):
# the option's name is in the binary that parses it; the stock wpad has no such string
(self.root / 'usr/sbin/hostapd').write_bytes(
b'\x7fELF\x00sae_pwe\x00' + (b'u30_sae_offload\x00' if patched else b'') + b'sae_confirm_immediate\x00')
def run_guard(self, shell, mode, state, up_after=None):
(self.tmp / 'uci.state').write_text(state)
for f in ('uci.log', 'ubus.log', 'wifi.log', 'logger.log', 'sleep.log', 'ap-after'):
(self.tmp / f).unlink(missing_ok=True)
(self.root / 'etc/mu300/wireless.sae-offload').unlink(missing_ok=True)
if up_after:
(self.tmp / 'ap-after').write_text(str(up_after))
r = self.script(shell, self.GUARD, mode, MU300_SYSROOT=self.root, MU300_SAE_WAIT=10)
self.assertEqual(r.returncode, 0, r.stderr)
return r
def log(self, name):
p = self.tmp / name
return p.read_text().splitlines() if p.exists() else []
def assertUntouched(self, r, state):
self.assertEqual(r.stderr, '')
self.assertEqual((self.tmp / 'uci.state').read_text(), state)
self.assertEqual([c for c in self.log('uci.log') if not c.startswith('get ')], [])
self.assertEqual(self.log('wifi.log') + self.log('logger.log'), [])
self.assertFalse((self.root / 'etc/mu300/wireless.sae-offload').exists())
def assertWpa2(self, r, reason):
state = (self.tmp / 'uci.state').read_text()
self.assertIn("wireless.ap0.encryption='psk2'\n", state)
self.assertIn("wireless.ap0.key='synthetic-test-password'\n", state)
# only this option leaves the list
self.assertIn("wireless.ap0.hostapd_bss_options='max_listen_interval=10'\n", state)
for gone in ('u30_sae_offload', 'ieee80211w', 'sae_pwe'):
self.assertNotIn(gone, state)
self.assertEqual(self.log('uci.log')[-1], 'commit wireless')
self.assertIn(reason, r.stderr)
self.assertIn('back on WPA2 with the same password', r.stderr)
self.assertNotIn('synthetic-test-password', r.stderr + '\n'.join(self.log('logger.log')))
self.assertEqual(len(self.log('logger.log')), 1)
self.assertIn('-p daemon.err', self.log('logger.log')[0])
saved = self.root / 'etc/mu300/wireless.sae-offload'
self.assertEqual(saved.read_text(), 'the file as it was\n')
self.assertEqual(saved.stat().st_mode & 0o077, 0)
def test_without_the_option_nothing_is_asked_or_changed(self):
for shell in self.each_shell():
for mode in ('precheck', 'verify'):
self.hostapd(patched=False)
r = self.run_guard(shell, mode, WPA2_STATE)
self.assertUntouched(r, WPA2_STATE)
self.assertEqual(self.log('uci.log') + self.log('ubus.log') + self.log('sleep.log'), [])
def test_not_openwrt(self):
(self.root / 'etc/openwrt_release').unlink()
self.hostapd(patched=False)
for shell in self.each_shell():
self.assertUntouched(self.run_guard(shell, 'precheck', SAE_STATE), SAE_STATE)
def test_precheck_keeps_a_hostapd_that_has_the_option(self):
for shell in self.each_shell():
self.assertUntouched(self.run_guard(shell, 'precheck', SAE_STATE), SAE_STATE)
def test_precheck_stock_hostapd_after_an_update(self):
self.hostapd(patched=False)
for shell in self.each_shell():
r = self.run_guard(shell, 'precheck', SAE_STATE)
self.assertWpa2(r, 'the installed hostapd does not have it')
# mu300-hw brings Wi-Fi up right after; the client mode's disabled access point is repaired too
self.assertEqual(self.log('wifi.log'), [])
r = self.run_guard(shell, 'precheck', SAE_STATE + "wireless.ap0.disabled='1'\n")
self.assertWpa2(r, 'the installed hostapd does not have it')
def test_verify_access_point_up(self):
for shell in self.each_shell():
self.assertUntouched(self.run_guard(shell, 'verify', SAE_STATE, up_after=1), SAE_STATE)
self.assertEqual(self.log('ubus.log'), ['-t 5 call hostapd.wlan0 get_status'])
# automatic channel selection takes half a minute: up on a later look is up
self.assertUntouched(self.run_guard(shell, 'verify', SAE_STATE, up_after=3), SAE_STATE)
self.assertEqual(self.log('sleep.log'), ['5', '5'])
def test_verify_access_point_never_up(self):
for shell in self.each_shell():
r = self.run_guard(shell, 'verify', SAE_STATE)
self.assertWpa2(r, 'the access point did not start')
self.assertEqual(self.log('sleep.log'), ['5', '5'])
self.assertEqual(self.log('wifi.log'), ['wifi down', 'wpad restart', 'wifi up'])
def test_verify_leaves_a_hotspot_that_is_off_on_purpose(self):
for shell in self.each_shell():
for state in (SAE_STATE + "wireless.ap0.disabled='1'\n", SAE_STATE + "wireless.radio0.disabled='1'\n",
SAE_STATE.replace("mode='ap'", "mode='sta'")):
self.assertUntouched(self.run_guard(shell, 'verify', state), state)
for marker in ('run/mu300-wifi-client.active', 'run/mu300-wifi-scan-mode', 'run/mu300/power/hotspot-off'):
(self.root / marker).write_text('')
self.assertUntouched(self.run_guard(shell, 'verify', SAE_STATE), SAE_STATE)
(self.root / marker).unlink()
def test_boot_calls_it_before_wifi_up_and_after_the_retry(self):
hw = (TOP / 'openwrt/overlay/etc/init.d/mu300-hw').read_text()
self.assertLess(hw.index('openwrt-wifi-config'), hw.index('openwrt-wifi-sae-guard precheck'))
self.assertLess(hw.index('openwrt-wifi-sae-guard precheck'), hw.index('wifi down'))
post = (TOP / 'openwrt/overlay/etc/init.d/mu300-post').read_text()
self.assertLess(post.index("'AP not up, retrying'; wifi up"), post.index('openwrt-wifi-sae-guard verify'))
@unittest.skipUnless(os.environ.get('MU300_WRT_IMAGE') and shutil.which('docker'),
'MU300_WRT_IMAGE (an OpenWrt 25.12 arm64 docker image) not set')
class SaeWifiScripts(unittest.TestCase):
"""OpenWrt's wifi-scripts for a fake wiphy (as test_wifi_channels): the hostapd configuration of the documented
opt-in, and of what openwrt-wifi-sae-guard leaves behind."""
def test_hostapd_config_of_the_opt_in_and_of_the_fallback(self):
import test_wifi_channels as channels
fake = channels.WifiScriptsInOpenWrt
opt_in = {'encryption': 'sae', 'ieee80211w': '2', 'sae_pwe': '0',
'hostapd_bss_options': ['u30_sae_offload=1']}
cases = {'stock': {}, 'opt-in': opt_in, 'fallback': {'encryption': 'psk2', 'hostapd_bss_options': []}}
with tempfile.TemporaryDirectory() as d:
d = Path(d)
(d / 'cases').mkdir()
(d / 'out').mkdir()
for name, iface in cases.items():
data = fake.data(36, 'VHT80')
data['interfaces']['ap0']['config'].update(iface)
(d / 'cases' / f'{name}.wiphy.json').write_text(json.dumps(fake.wiphy(False, {})))
(d / 'cases' / f'{name}.data.json').write_text(json.dumps(data))
script = r"""
mkdir -p /var/lock /var/run /tmp /fake/wifi
apk update >/dev/null && apk add wifi-scripts >/dev/null 2>&1 || exit 1
sed -e "s/^export function wiphy_info(phy) {/function nl_wiphy_info(phy) {/" /usr/share/ucode/wifi/common.uc > /fake/wifi/common.uc
grep -q "^function nl_wiphy_info" /fake/wifi/common.uc || exit 1
echo "export function wiphy_info(phy) { return json(fs.readfile(getenv(\"FAKE_WIPHY\"))); };" >> /fake/wifi/common.uc
for f in /t/cases/*.data.json; do
n=$(basename "$f" .data.json)
FAKE_DATA=$f FAKE_WIPHY=/t/cases/$n.wiphy.json FAKE_CC=CN \
ucode -L "/fake/*.uc" -L "/usr/share/ucode/*.uc" /fx/run.uc > /t/out/$n.conf 2>&1 || echo "rc=$?" >> /t/out/$n.conf
done
"""
r = subprocess.run(['docker', 'run', '--rm', '--platform', 'linux/arm64',
'-v', f'{channels.FIXTURES}:/fx:ro', '-v', f'{d}:/t',
os.environ['MU300_WRT_IMAGE'], '/bin/sh', '-c', script],
capture_output=True, text=True, timeout=900)
self.assertEqual(r.returncode, 0, r.stdout + r.stderr)
def conf(name):
text = (d / 'out' / f'{name}.conf').read_text()
self.assertNotIn('rc=', text, name)
return dict(l.split('=', 1) for l in text.splitlines() if '=' in l and not l.startswith('#'))
c = conf('opt-in')
self.assertEqual((c['wpa_key_mgmt'], c['ieee80211w'], c['sae_pwe'], c['u30_sae_offload']),
('SAE', '2', '0', '1'))
# the patch reads the passphrase from wpa_passphrase and refuses a BSS with sae_password entries
self.assertEqual(c['wpa_passphrase'], '12345678')
self.assertNotIn('sae_password', c)
# the hotspot of the images, and the guard's fallback: the same WPA2 configuration, no key of the offload
stock, back = conf('stock'), conf('fallback')
self.assertEqual(stock, back)
self.assertEqual(back['wpa_key_mgmt'], 'WPA-PSK')
self.assertNotIn('u30_sae_offload', back)
self.assertNotIn('sae_pwe', back)
class DriverPrivacy(unittest.TestCase):
def body(self, path, name):
source = (TOP / 'upstream/modules/sprd_wlan_combo' / path).read_text()
+4
View File
@@ -12,6 +12,10 @@ network), not both at the same time. The hotspot is the default.
* By default it uses the **name and password copied from Android** (the installer asks). Without that, a random
password is generated and shown at login.
* Wi-Fi clients and USB clients share one LAN, so they can see each other and the device.
* The hotspot is **WPA2**. WPA3 is not in the images: on this chip the firmware does the WPA3 exchange itself, and the
only way to use it is an experimental build of your own for the U30 Air on OpenWrt, with an open security question
([U30AIR-SAE.md](https://github.com/dikeckaan/mu300-linux/blob/main/docs/U30AIR-SAE.md)). Choosing WPA3 in LuCI
on a normal image gives a hotspot that nothing can join.
### Change the name, password or band