DEVELOPMENT UPDATE: Structural Upstream Fix & Formal C-Code Patch (Beyond Mitigation)
Following up on the v1.5.3 addon service mitigations (the LimitNOFILE=512 circuit breaker), we have successfully moved beyond temporary containment. By auditing ConnMan’s active repository source layers, we have isolated the exact code path responsible for the Wi-Fi specific resource aggregation.
The Root Cause: Structural Bypass inside plugins/wifi.c
When an out-of-band virtual interface (like our WireGuard tunnel) drops, ConnMan's wireless event pathway triggers interface_removed(). If the parent device linkage has already been decoupled during the routing shift, the function hits an early conditional exit check:
if (wifi == NULL || wifi->device == NULL) {
DBG("wifi interface already removed");
return; /* 🛑 THE STRUCTURAL HOLE: Early return bypasses object lifecycle teardown! */
}
Because of this premature return, the mandatory GLib unreferencing routines (g_supplicant_interface_cancel and g_supplicant_interface_set_data) are completely bypassed. This leaves the low-level netlink and event tracking sockets running infinitely inside the OS handle table, causing the 72+ FD leaks we captured earlier.
Upstream Git Patch Submitted
I have submitted a formal patch to the core mailing list ([email protected]) to separate the hardware link check from the memory lifecycle teardown, ensuring cleanup runs unconditionally:
From: Doemela <[email protected]>
Subject: [PATCH] plugins/wifi: Fix GSupplicantInterface socket leak on out-of-band drop
Signed-off-by: Doemela <[email protected]>
---
diff --git a/plugins/wifi.c b/plugins/wifi.c
index 9ce7b5a..bcf8321 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1014,14 +1014,16 @@ static void interface_removed(GSupplicantInterface *interface)
wifi = g_supplicant_interface_get_data(interface);
if (wifi != NULL && wifi->tethering == TRUE)
return;
- if (wifi == NULL || wifi->device == NULL) {
- DBG("wifi interface already removed");
- return;
- }
+ if (wifi != NULL && wifi->device != NULL) {
+ wifi->interface = NULL;
+ connman_device_set_powered(wifi->device, FALSE);
+ } else {
+ DBG("wifi device linkage missing, executing isolated interface cleanup");
+ }
- wifi->interface = NULL;
- connman_device_set_powered(wifi->device, FALSE);
+ g_supplicant_interface_set_data(interface, NULL);
+ g_supplicant_interface_cancel(interface);
}
Display More
Compiling Safely Across Your Custom LibreELEC Tree Targets
For anyone building custom distribution images, you can drop this patch file straight into packages/network/connman/patches/connman-999-fix-wifi-fd-leak.patch and rebuild your exact appliance tree environment cleanly:
For PC / Intel / AMD (Generic x86_64 Target):
PROJECT=Generic ARCH=x86_64 ./scripts/clean connman
PROJECT=Generic ARCH=x86_64 ./scripts/build connman
For Raspberry Pi 4 (32-bit ARM Target):
For Raspberry Pi 5 (64-bit AArch64 Target):
PROJECT=RPi ARCH=aarch64 ./scripts/clean connman
PROJECT=RPi ARCH=aarch64 ./scripts/build connman
The addon's built-in sandbox remains active to protect normal users, but this patch resolves the core issue at the operating system level.
Salute!