]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: mac80211: use jiffies_delta_to_msecs() for sta_info inactive times
authorNicolas Cavallari <nicolas.cavallari@green-communications.fr>
Tue, 3 Mar 2026 16:06:39 +0000 (17:06 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 6 Mar 2026 10:06:27 +0000 (11:06 +0100)
Inactive times of around 0xffffffff milliseconds have been observed on
an ath9k device on ARM.  This is likely due to a memory ordering race in
the jiffies_to_msecs(jiffies - last_active()) calculation causing an
overflow when the observed jiffies is below ieee80211_sta_last_active().

Use jiffies_delta_to_msecs() instead to avoid this problem.

Fixes: 7bbdd2d98797 ("mac80211: implement station stats retrieval")
Signed-off-by: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>
Link: https://patch.msgid.link/20260303161701.31808-1-nicolas.cavallari@green-communications.fr
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/sta_info.c

index 6dc22f1593be418554ef3e7df960f686807f1168..dd51a578fbc5c0ff11eabf76e4feef22065b8eab 100644 (file)
@@ -2782,7 +2782,9 @@ static void sta_set_link_sinfo(struct sta_info *sta,
        }
 
        link_sinfo->inactive_time =
-               jiffies_to_msecs(jiffies - ieee80211_sta_last_active(sta, link_id));
+               jiffies_delta_to_msecs(jiffies -
+                                      ieee80211_sta_last_active(sta,
+                                                                link_id));
 
        if (!(link_sinfo->filled & (BIT_ULL(NL80211_STA_INFO_TX_BYTES64) |
                                    BIT_ULL(NL80211_STA_INFO_TX_BYTES)))) {
@@ -3015,7 +3017,8 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,
        sinfo->connected_time = ktime_get_seconds() - sta->last_connected;
        sinfo->assoc_at = sta->assoc_at;
        sinfo->inactive_time =
-               jiffies_to_msecs(jiffies - ieee80211_sta_last_active(sta, -1));
+               jiffies_delta_to_msecs(jiffies -
+                                      ieee80211_sta_last_active(sta, -1));
 
        if (!(sinfo->filled & (BIT_ULL(NL80211_STA_INFO_TX_BYTES64) |
                               BIT_ULL(NL80211_STA_INFO_TX_BYTES)))) {