From: Grant Erickson <gerickson@nuovations.com>
To: connman@lists.linux.dev
Cc: Jussi Laakkonen <jussi.laakkonen@jolla.com>
Subject: [PATCH 0/2] Fix a regulatory domain use-after-free on device power-on.
Date: Sat, 24 Oct 2026 10:50:31 -0700 [thread overview]
Message-ID: <cover.1792863816.git.gerickson@nuovations.com> (raw)
Since fe9307c987a0 ("device: Setup regdom when powering up to maintain
consistency"), powering on a Wi-Fi device reapplies the technology's
stored regulatory domain by passing 'technology->regdom' itself down to
wpa_supplicant. gsupplicant keeps that pointer, without copying it,
until the asynchronous 'Country' property set completes, and then hands
it back to the callback, which reaches 'connman_technology_regdom_notify'.
That function frees 'technology->regdom' and then duplicates 'alpha2'
from the string it has just freed.
On a 32-bit ARM device whose regulatory domain is set from the cellular
network by the oFono plugin, connmand built with AddressSanitizer aborts
on every Wi-Fi 'connmanctl disable' followed by 'connmanctl enable':
ERROR: AddressSanitizer: heap-use-after-free on address 0x75324210
READ of size 3 at 0x75324210 thread T0
0x75324210 is located 0 bytes inside of 3-byte region
freed by thread T0 here:
#1 connman_technology_regdom_notify src/technology.c:299
#2 __connman_technology_notify_regdom_by_device src/technology.c:1150
#3 connman_device_regdom_notify src/device.c:1101
#4 wifi_regdom_callback plugins/wifi.c:2060
#5 country_result gsupplicant/supplicant.c:3715
#6 property_set_reply gsupplicant/dbus.c:359
The read, from gdb at the abort, is the 'g_strdup' at
src/technology.c:300, in the same call. The request that carried the
pointer came from 'connman_device_set_powered', by way of
'connman_device_set_regdom', 'wifi_set_regdom' and
'g_supplicant_interface_set_country'.
Patch 1 is the fix: gsupplicant owns a copy of 'alpha2' for the life of
each 'Country' set request. That also covers two related cases in which
the string is freed by a call other than the one that reads it: a new
regulatory domain arriving, through 'connman_technology_set_regdom',
while a power-on request is outstanding; and the timezone module, which
frees its 'alpha2' right after passing it to
'connman_technology_set_regdom'.
Patch 2 makes 'connman_technology_regdom_notify' safe when 'alpha2' is
the technology's own 'regdom'. On its own, it stops the crash above but
not those two cases, so it is defense-in-depth rather than an
alternative to patch 1.
Grant Erickson (2):
gsupplicant: Own a copy of 'alpha2' for the life of a 'Country' set.
technology: Make 'connman_technology_regdom_notify' alias-safe.
gsupplicant/supplicant.c | 9 ++++++---
src/technology.c | 9 ++++++++-
2 files changed, 14 insertions(+), 4 deletions(-)
--
2.52.0
next reply other threads:[~2026-10-24 17:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-24 17:50 Grant Erickson [this message]
2026-10-24 17:50 ` [PATCH 1/2] gsupplicant: Own a copy of 'alpha2' for the life of a 'Country' set Grant Erickson
2026-10-24 17:50 ` [PATCH 2/2] technology: Make 'connman_technology_regdom_notify' alias-safe Grant Erickson
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=cover.1792863816.git.gerickson@nuovations.com \
--to=gerickson@nuovations.com \
--cc=connman@lists.linux.dev \
--cc=jussi.laakkonen@jolla.com \
/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