[PATCH] Fix BSS age underflow

chaitanya.mgit at gmail.com chaitanya.mgit at gmail.com
Mon Jan 9 12:09:10 PST 2023

From: Krishna T <krishna.t at nordicsemi.no>

While checking for stale BSSes, the current time is used as a basis and
then based on age the stale check time is calculated, but if this is
done too early in the boot and if either BOOTTIME/MONOTONIC (the one
Zephyr uses by default) are used then the stale check time underflows
and goes to future causing active BSS entries in the scan to be treated
as stale and flushed.

Fix this by adding a check before calculating stale time and ignore this
check till the system reaches the BSS expiration time (this would never
happen with REALTIME clock).

Signed-off-by: Krishna T <krishna.t at nordicsemi.no>
Signed-off-by: Sridhar Nuvusetty <sridhar.nuvusetty at nordicsemi.no>
 wpa_supplicant/bss.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/wpa_supplicant/bss.c b/wpa_supplicant/bss.c
index e13783ce1..65b58bd79 100644
--- a/wpa_supplicant/bss.c
+++ b/wpa_supplicant/bss.c
@@ -936,6 +936,10 @@ void wpa_bss_flush_by_age(struct wpa_supplicant *wpa_s, int age)
+	if (t.sec < age)
+		return; /* avoid underflow */
 	t.sec -= age;
 	dl_list_for_each_safe(bss, n, &wpa_s->bss, struct wpa_bss, list) {

More information about the Hostap mailing list