Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[connman] Upgrade upstream WiFi plugin to latest. Fixes JB#62992 #86

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

LaakkonenJussi
Copy link
Contributor

No description provided.

photoninger and others added 17 commits November 29, 2024 16:05
subject_match, altsubject_match, domain_suffix_match, domain_match
they are used for 802.1X aka. enterprise-wpa to check the
authentication server's certificate in order to prevent MITM attacks
using a valid certificate issued by the same root-CA as configured by
CACertFile.

More details at
https://w1.fi/cgit/hostap/plain/wpa_supplicant/wpa_supplicant.conf
wpa_supplicant is able to offload the 4-way handshake into the driver.
In this case the 4WAY_HANDSHAKE state is skipped and therefore the
current mechanism to detect a wrong password doesn't work any more. This
patch extends the detection mechanism to also work with the offloading
feature. The status code 16 is relatively generic, so this can lead to
false positives.
Cisco wireless controllers seem to send the disconnect code 1
sometimes. It could be a very dirty way to get the client moving to a
different AP.

Anyway, the '1' case was added as precaution and doesn't have any real
bug report behind it. So let's drop it as we had two independent
reports that ConnMan is not doing the right thing.
For Broadcom BCM4356 chipset with brcmfmac driver, the IFF_LOWER_UP flag
did not always change state in wifi_newlink() but remained set when
changing from STA mode to AP mode. This resulted in handle_tethering()
not being called to add the wireless interface to the tether bridge.

To resolve the issue, always call handle_tethering() as long as the
IFF_LOWER_UP flag is set instead of only when IFF_LOWER_UP changes
from unset to set. The handle_tethering() function already has checks
in place to avoid adding the wireless interface to the tether bridge
more than once.
When the BSS expiration age is under the long scanning interval, the
list of available networks will periodically lose the unconnected (but
still present) ones, and only be repopulated after next scan.

Setting the BSS expiration age to match the long scanning interval
prevents this undesirable behaviour.
Before being able to connect to a new network, finish disconnecting
the old connection. The wifi->network object can change while the
disconnect_callback is scheduled.
Check the involved network validity in disconnect callback, to avoid
side effects, as crashing, when processing an already released one.

Fixes: dd86f09 ("wifi: Always disconnect connection completely")
To avoid staying stuck in "Operation aborted" error state when
connecting, the disconnecting status shall be reset by each disconnect
callback, whatever network is involved, even if not previously
connected.

Fixes: dd86f09 ("wifi: Always disconnect connection completely")
g_memdup got marked as depricated in favor for g_memdup2 since GLib
v2.68 which is the very same version g_memdup2 was introduced. We
don't want to increase the minium GLib version to latest greatest
hence open code this function.
Implement WPA3-SAE authentication on connman side using wpa_supplicant
backend.

Initially based on Tizen project:

  https://review.tizen.org/git/?p=platform/upstream/connman.git
This commit adds support for WPA3-Personal transition mode, which
supports both WPA2-Personal (PSK) and WPA3-Personal (SAE).

Based on the AP accepted key management protocols, connman configures
wpa_supplicant as follows:

* WPA3-Personal-only mode: key_mgmt="SAE" ; ieee80211w=2
* WPA3-Personal transition mode: key_mgmt="SAE WPA-PSK" ; ieee80211w=1
In ssid_init(), the pointer members of GSupplicantSSID *ssid was
initialised to point to members of a connman_network, which get
freed and replaced, causing ssid's pointers to point to freed heap
memory. To mitigate this, these members are duplicated and then
freed and along with ssid when no longer needed.
On WPA3-SAE authentication, wpa_supplicant goes directly from
authenticating to disconnected state if the key was invalid.

The above is currently not handled and the `connect-failed` error is
reported on such cases. In order to make the client agent prompt for a
new password, we need to handle this transition and report the
`invalid-key` error.
The bug frequently causes junk being written to the
Tethering.Identifier and Tethering.Passphrase entries in the settings
file. This in turn prevents Connman from starting up at all the next
time it is run.

To reproduce with connmanctl, use the following commands:

    enable wifi
    tether wifi on MyNetwork ThePassphrase
    tether wifi off

Then have a look at the settings file.

Disabling tethering causes a call of remove_ssid() from
interface_select_network_result() in gsupplicant/supplicant.c, which
frees the SSID and passphrase strings of the given GSupplicantSSID
structure (originally initialized by the wifi plugin). These strings,
however, are shared with a connman_technology structure, and they are
accessed in technology_save() (called indirectly from set_property()
in technology.c) after they have been freed.

To fix this bug, the affected strings are copied into the
GSupplicantSSID structure instead of simply assigning them. We make
sure (1) to free them in case supplicant didn't take the
GSupplicantSSID structure due to an error, and (2) to avoid double
frees in ap_create_callback() and sta_remove_callback().

Originally, there were two GSupplicantSSID instances in the wifi
plugin: one for the supplicant, and one stored in the wifi_data's
tethering_param structure. The latter, however, was never used, so
this commit removes its allocation to avoid a new memory leak, to save
memory, and to generally avoid confusion.

The bug fixed by this commit was introduced in 481d08f.
A GSupplicantSSID instance was leaked in ssid_ap_init() in case
connman_technology_get_wifi_tethering() didn't succeed.
@LaakkonenJussi LaakkonenJussi changed the title WIP: Jb62571 WIP: [connman] Upgrade upstream WiFi plugin to latest. Fixes JB#62992 Dec 17, 2024
@LaakkonenJussi LaakkonenJussi changed the title WIP: [connman] Upgrade upstream WiFi plugin to latest. Fixes JB#62992 [connman] Upgrade upstream WiFi plugin to latest. Fixes JB#62992 Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants