Skip to contentSkip to conversation

mac80211: add check on hw->max_signal value on ieee80211_register_hw

PATCH Applied andrea merello 3 participants 3 messages Jan 19, 2014 – Jan 21, 2014 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac80211: add check on hw->max_signal value on ieee80211_register_hw

When IEEE80211_HW_SIGNAL_UNSPEC is set, mac80211 will perform a division by max_signal in ieee80211_bss_info_update. If max_signal is not properly set by the driver (for example it is zero) this leads to a divide error and crash.
Thanks to Larry Finger, who pointed me to this.
This patch adds in ieee80211_register_hw one more check to detect this condition and eventually returns -EINVAL, as already done for other checks already performed there.

---
 net/mac80211/main.c | 3 +++
 1 file changed, 3 insertions(+)
net/mac80211/main.c +3 -0
index d767cfb..913307a 100644
@@ -758,6 +758,9 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
 	     local->hw.offchannel_tx_hw_queue >= local->hw.queues))
 		return -EINVAL;
 
+	if (hw->flags & IEEE80211_HW_SIGNAL_UNSPEC && hw->max_signal <= 0)
+		return -EINVAL;
+
 #ifdef CONFIG_PM
 	if (hw->wiphy->wowlan && (!local->ops->suspend || !local->ops->resume))
 		return -EINVAL;
Signature · 1 line
1.8.3.2
maintainer Applied
#1 lore raw
Quoted 8 lines · andrea merello

When IEEE80211_HW_SIGNAL_UNSPEC is set, mac80211 will perform a division by max_signal in ieee80211_bss_info_update. If max_signal is not properly set by the driver (for example it is zero) this leads to a divide error and crash.
Thanks to Larry Finger, who pointed me to this.
This patch adds in ieee80211_register_hw one more check to detect this condition and eventually returns -EINVAL, as already done for other checks already performed there.

Applied.

johannes

#2 lore raw
In reply to andrea merello

net/mac80211/main.c int ieee80211_register_hw(struct ieee80211_hw *hw) · line 763

Quoted 5 lines · andrea merello

+ if (hw->flags &
IEEE80211_HW_SIGNAL_UNSPEC && hw->max_signal <= 0)

net/mac80211/main.c +2 -0
+               return -EINVAL;
+

Should we add a check for > 100 as well, similar to cfg?