Skip to contentSkip to conversation

wifi: mac80211: make rate u32 in sta_set_rate_info_rx()

PATCH In review Shayne Chen 3 participants 3 messages Feb 9, 2023 – Feb 15, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: mac80211: make rate u32 in sta_set_rate_info_rx()

The value of last_rate in ieee80211_sta_rx_stats is degraded from u32 to u16 after being assigned to rate variable, which causes information loss in STA_STATS_FIELD_TYPE and later bitfields.

---
 net/mac80211/sta_info.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/sta_info.c +1 -1
index 27c737fe7fb8..bd532d3f925d 100644
@@ -2418,7 +2418,7 @@ static void sta_stats_decode_rate(struct ieee80211_local *local, u32 rate,
 
 static int sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo)
 {
-	u16 rate = READ_ONCE(sta_get_last_rx_stats(sta)->last_rate);
+	u32 rate = READ_ONCE(sta_get_last_rx_stats(sta)->last_rate);
 
 	if (rate == STA_STATS_RATE_INVALID)
 		return -EINVAL;
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

Il 09/02/23 12:06, Shayne Chen ha scritto:

Quoted 5 lines

The value of last_rate in ieee80211_sta_rx_stats is degraded from u32 to u16 after being assigned to rate variable, which causes information loss in STA_STATS_FIELD_TYPE and later bitfields.

In struct ieee80211_sta_rx_stats, last_rate is u32, hence this local rate must be u32, or information loss may happen. Agreed.

Quoted 18 lines
---
  net/mac80211/sta_info.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/sta_info.c +1 -1
index 27c737fe7fb8..bd532d3f925d 100644
@@ -2418,7 +2418,7 @@ static void sta_stats_decode_rate(struct ieee80211_local *local, u32 rate,
 
  static int sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo)
  {
-	u16 rate = READ_ONCE(sta_get_last_rx_stats(sta)->last_rate);
+	u32 rate = READ_ONCE(sta_get_last_rx_stats(sta)->last_rate);
 
  	if (rate == STA_STATS_RATE_INVALID)
  		return -EINVAL;
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Shayne Chen

Il 09/02/23 12:06, Shayne Chen ha scritto:

Quoted 5 lines

The value of last_rate in ieee80211_sta_rx_stats is degraded from u32 to u16 after being assigned to rate variable, which causes information loss in STA_STATS_FIELD_TYPE and later bitfields.

In struct ieee80211_sta_rx_stats, last_rate is u32, hence this local rate must be u32, or information loss may happen. Agreed.

P.S.: Sorry for sending twice, the first one got out of the wrong mailbox.

Quoted 18 lines
---
  net/mac80211/sta_info.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/sta_info.c +1 -1
index 27c737fe7fb8..bd532d3f925d 100644
@@ -2418,7 +2418,7 @@ static void sta_stats_decode_rate(struct ieee80211_local *local, u32 rate,
 
  static int sta_set_rate_info_rx(struct sta_info *sta, struct rate_info *rinfo)
  {
-	u16 rate = READ_ONCE(sta_get_last_rx_stats(sta)->last_rate);
+	u32 rate = READ_ONCE(sta_get_last_rx_stats(sta)->last_rate);
 
  	if (rate == STA_STATS_RATE_INVALID)
  		return -EINVAL;