mac80211: do not call rate control .tx_status before .rate_init
PATCH 1/1 mac80211: do not call rate control .tx_status before .rate_init
Most rate control implementations assume .get_rate and .tx_status are only called once the per-station data has been fully initialized. minstrel_ht crashes if this assumption is violated.
--- net/mac80211/rate.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/mac80211/rate.h +1 -1
@@ -37,7 +37,7 @@ static inline void rate_control_tx_status(struct ieee80211_local *local,struct ieee80211_sta *ista = &sta->sta;void *priv_sta = sta->rate_ctrl_priv; -if (!ref) +if (!ref || !test_sta_flag (sta,WLAN_STA_RATE_CONTROL ))return ; ref->ops->tx_status (ref->priv, sband, ista, priv_sta, skb);
Signature · 1 line
1.7.3.2
Quoted 15 lines · Felix Fietkau
Most rate control implementations assume .get_rate and .tx_status are only called once the per-station data has been fully initialized.
minstrel_htcrashes if this assumption is violated.Signed-off-by Felix Fietkau <[email protected]>Tested-by Arend van Spriel <[email protected]>--- net/mac80211/rate.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)net/mac80211/rate.h +0
-0
net/mac80211/rate.h static inline void rate_control_tx_status(struct ieee80211_local *local, · line 43
Quoted 8 lines
net/mac80211/rate.h +1
-1@@ -37,7 +37,7 @@ static inline void rate_control_tx_status(struct ieee80211_local *local,struct ieee80211_sta *ista = &sta->sta;void *priv_sta = sta->rate_ctrl_priv; -if (!ref) +if (!ref || !test_sta_flag (sta,WLAN_STA_RATE_CONTROL ))return ; ref->ops->tx_status (ref->priv, sband, ista, priv_sta, skb);
Any reason not to apply this for 3.3? Or stable?
John
Signature · 2 lines
John W. Linville Someday the world will need a hero, and you [email protected] might be all we have. Be ready.
Quoted 19 lines · John W. Linville
Quoted 18 lines · Felix Fietkau
Most rate control implementations assume .get_rate and .tx_status are only called once the per-station data has been fully initialized.
minstrel_htcrashes if this assumption is violated.Signed-off-by Felix Fietkau <[email protected]>Tested-by Arend van Spriel <[email protected]>--- net/mac80211/rate.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)net/mac80211/rate.h +0
-0@@ -37,7 +37,7 @@ static inline void rate_control_tx_status(struct ieee80211_local *local,struct ieee80211_sta *ista = &sta->sta;void *priv_sta = sta->rate_ctrl_priv;
Quoted 7 lines
net/mac80211/rate.h static inline void rate_control_tx_status(struct ieee80211_local *local, · line 43
Quoted 5 lines
net/mac80211/rate.h +1
-1-if (!ref) +if (!ref || !test_sta_flag (sta,WLAN_STA_RATE_CONTROL ))return ; ref->ops->tx_status (ref->priv, sband, ista, priv_sta, skb);Any reason not to apply this for 3.3? Or stable?
I think 3.3 doesn't have that sta flag, the issue was probably introduced with the 3.4 changes.
I don't remember something like this appearing in earlier versions.
- Felix
Quoted 24 lines · Felix Fietkau
Quoted 23 lines · John W. Linville
Quoted 22 lines · Felix Fietkau
Most rate control implementations assume .get_rate and .tx_status are only called once the per-station data has been fully initialized.
minstrel_htcrashes if this assumption is violated.Signed-off-by Felix Fietkau <[email protected]>Tested-by Arend van Spriel <[email protected]>--- net/mac80211/rate.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)net/mac80211/rate.h +1
-1@@ -37,7 +37,7 @@ static inline void rate_control_tx_status(struct ieee80211_local *local,struct ieee80211_sta *ista = &sta->sta;void *priv_sta = sta->rate_ctrl_priv; -if (!ref) +if (!ref || !test_sta_flag (sta,WLAN_STA_RATE_CONTROL ))return ;
Quoted 6 lines
Quoted 3 lines
net/mac80211/rate.h static inline void rate_control_tx_status(struct ieee80211_local *local, · line 43
Quoted 1 line
net/mac80211/rate.h +0
-0ref->ops->tx_status (ref->priv, sband, ista, priv_sta, skb);Any reason not to apply this for 3.3? Or stable?
I think 3.3 doesn't have that sta flag, the issue was probably introduced with the 3.4 changes.
I don't remember something like this appearing in earlier versions.
Cool, thanks.
Signature · 2 lines
John W. Linville Someday the world will need a hero, and you [email protected] might be all we have. Be ready.
Quoted 30 lines · On Wed, 8 Feb 2012 14:44:54 -0500 "John W. Linville" <[email protected]>…
Quoted 29 lines · Felix Fietkau
Quoted 28 lines · John W. Linville
Quoted 24 lines · Felix Fietkau
Most rate control implementations assume .get_rate and .tx_status are only called once the per-station data has been fully initialized.
minstrel_htcrashes if this assumption is violated.Signed-off-by Felix Fietkau <[email protected]>Tested-by Arend van Spriel <[email protected]>--- net/mac80211/rate.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)net/mac80211/rate.h +0
-0@@ -37,7 +37,7 @@ static inline voidrate_control_tx_status(struct
ieee80211_local*local, structieee80211_sta*ista =&sta->sta; void*priv_sta=sta->rate_ctrl_priv;net/mac80211/rate.h +1
-1-if (!ref) +if (!ref || !test_sta_flag (sta,WLAN_STA_RATE_CONTROL ))return ; ref->ops->tx_status(ref->priv, sband, ista, priv_sta,Quoted 1 line
skb);
Any reason not to apply this for 3.3? Or stable?
Quoted 5 lines
Quoted 3 lines
I think 3.3 doesn't have that sta flag, the issue was probably introduced with the 3.4 changes.
I don't remember something like this appearing in earlier versions.Cool, thanks.
I believe 3.3 is affected. At least it looks like the Fedora bug 768639
(https://bugzilla.redhat.com/show_bug.cgi?id=768639) is caused by calling .tx_status at a wrong time. Fedora kernels use compat-wireless-3.3. I'm going to test the bleeding edge compat-wireless with the patch by Felix to see if it fixes things.
The lack of the WLAN_STA_RATE_CONTROL flag doesn't mean that the old behavior was correct. The flag was introduced to correct that behavior.
The oldest report is dated 2011-12-17 and it's about Linux 3.2.0-rc5 with compat-wireless-2011-12-01.
Signature · 2 lines
Regards, Pavel Roskin
Quoted 45 lines · Pavel Roskin
Quoted 30 lines · On Wed, 8 Feb 2012 14:44:54 -0500 "John W. Linville" <[email protected]>…
Quoted 29 lines · Felix Fietkau
Quoted 28 lines · John W. Linville
Quoted 24 lines · Felix Fietkau
Most rate control implementations assume .get_rate and .tx_status are only called once the per-station data has been fully initialized.
minstrel_htcrashes if this assumption is violated.Signed-off-by Felix Fietkau <[email protected]>Tested-by Arend van Spriel <[email protected]>--- net/mac80211/rate.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)net/mac80211/rate.h +0
-0@@ -37,7 +37,7 @@ static inline voidrate_control_tx_status(struct
ieee80211_local*local, structieee80211_sta*ista =&sta->sta; void*priv_sta=sta->rate_ctrl_priv;net/mac80211/rate.h +1
-1-if (!ref) +if (!ref || !test_sta_flag (sta,WLAN_STA_RATE_CONTROL ))return ; ref->ops->tx_status(ref->priv, sband, ista, priv_sta,Quoted 1 line
skb);
Any reason not to apply this for 3.3? Or stable?
Quoted 5 lines
Quoted 3 lines
I think 3.3 doesn't have that sta flag, the issue was probably introduced with the 3.4 changes.
I don't remember something like this appearing in earlier versions.Cool, thanks.
I believe 3.3 is affected. At least it looks like the Fedora bug 768639
(https://bugzilla.redhat.com/show_bug.cgi?id=768639) is caused by calling .tx_status at a wrong time. Fedora kernels use compat-wireless-3.3. I'm going to test the bleeding edge compat-wireless with the patch by Felix to see if it fixes things.
Quoted 5 lines
The lack of the
WLAN_STA_RATE_CONTROLflag doesn't mean that the old behavior was correct. The flag was introduced to correct that behavior.The oldest report is dated 2011-12-17 and it's about Linux 3.2.0-rc5 with compat-wireless-2011-12-01.
Only .get_rate and .tx_status are affected, wireless-testing commit e1936e9407138b483e6d1332dd944afec8131f30 adds one of the checks, and my commit adds the other. Maybe John could merge those two to 3.3.
- Felix
John W. Linville
Tested-by Arend van SprielQuoted 46 lines · Felix Fietkau
Quoted 45 lines · Pavel Roskin
Quoted 30 lines · On Wed, 8 Feb 2012 14:44:54 -0500 "John W. Linville" <[email protected]>…
Quoted 29 lines · Felix Fietkau
Quoted 28 lines · John W. Linville
Quoted 24 lines · Felix Fietkau
Most rate control implementations assume .get_rate and .tx_status are only called once the per-station data has been fully initialized.
minstrel_htcrashes if this assumption is violated.Signed-off-by Felix Fietkau <[email protected]>Tested-by Arend van Spriel <[email protected]>--- net/mac80211/rate.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)net/mac80211/rate.h +0
-0@@ -37,7 +37,7 @@ static inline voidrate_control_tx_status(struct
ieee80211_local*local, structieee80211_sta*ista =&sta->sta; void*priv_sta=sta->rate_ctrl_priv;net/mac80211/rate.h +1
-1-if (!ref) +if (!ref || !test_sta_flag (sta,WLAN_STA_RATE_CONTROL ))return ; ref->ops->tx_status(ref->priv, sband, ista, priv_sta,Quoted 1 line
skb);
Any reason not to apply this for 3.3? Or stable?
Quoted 5 lines
Quoted 3 lines
I think 3.3 doesn't have that sta flag, the issue was probably introduced with the 3.4 changes.
I don't remember something like this appearing in earlier versions.Cool, thanks.
I believe 3.3 is affected. At least it looks like the Fedora bug 768639
(https://bugzilla.redhat.com/show_bug.cgi?id=768639) is caused by calling .tx_status at a wrong time. Fedora kernels use compat-wireless-3.3. I'm going to test the bleeding edge compat-wireless with the patch by Felix to see if it fixes things.
Quoted 8 lines
Quoted 5 lines
The lack of the
WLAN_STA_RATE_CONTROLflag doesn't mean that the old behavior was correct. The flag was introduced to correct that behavior.The oldest report is dated 2011-12-17 and it's about Linux 3.2.0-rc5 with compat-wireless-2011-12-01.
Only .get_rate and .tx_status are affected, wireless-testing commit
e1936e9407138b483e6d1332dd944afec8131f30adds one of the checks, and my commit adds the other. Maybe John could merge those two to 3.3.
At least one of them will cause some merge issues. Can someone try the attached patches to verify that they actually fix a real problem in 3.3?
Thanks!
John
Signature · 2 lines
John W. Linville Someday the world will need a hero, and you [email protected] might be all we have. Be ready.
Quoted 1 line
From
e11d0ade78b05641b969cb434680711ff04a159bMon Sep 17 00:00:00 2001
From: Johannes Berg <[email protected]>
Date: Fri, 20 Jan 2012 13:55:23 +0100
Subject: [PATCH 1/2] mac80211: call rate control only after init
There are situations where we don't have the
necessary rate control information yet for
station entries, e.g. when associating. This
currently doesn't really happen due to the
dummy station handling; explicitly disabling
rate control when it's not initialised will
allow us to remove dummy stations.
--- net/mac80211/debugfs_sta.c | 4 ++-- net/mac80211/rate.c | 2 +- net/mac80211/rate.h | 1 + net/mac80211/sta_info.h | 2 ++ 4 files changed, 6 insertions(+), 3 deletions(-)
net/mac80211/debugfs_sta.c +2 -2
@@ -63,14 +63,14 @@ static ssize_t sta_flags_read(struct file *file, char __user *userbuf, test_sta_flag(sta, WLAN_STA_##flg) ? #flg "\n" : ""int res =scnprintf (buf,sizeof (buf), -"%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s" , +"%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s" ,TEST (AUTH ),TEST (ASSOC ),TEST (PS_STA ),TEST (PS_DRIVER ),TEST (AUTHORIZED ),TEST (SHORT_PREAMBLE ),TEST (WME ),TEST (WDS ),TEST (CLEAR_PS_FILT ),TEST (MFP ),TEST (BLOCK_BA ),TEST (PSPOLL ),TEST (UAPSD ),TEST (SP ),TEST (TDLS_PEER ), -TEST (TDLS_PEER_AUTH )); +TEST (TDLS_PEER_AUTH ),TEST (RATE_CONTROL ));#undef TESTreturn simple_read_from_buffer (userbuf, count, ppos, buf, res); }
net/mac80211/rate.c +1 -1
@@ -336,7 +336,7 @@ void rate_control_get_rate(struct ieee80211_sub_if_data *sdata,int i;u32 mask; -if (sta) { +if (sta &&test_sta_flag (sta,WLAN_STA_RATE_CONTROL )) { ista = &sta->sta; priv_sta = sta->rate_ctrl_priv; }
net/mac80211/rate.h +1 -0
@@ -62,6 +62,7 @@ static inline void rate_control_rate_init(struct sta_info *sta) sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; ref->ops->rate_init (ref->priv, sband, ista, priv_sta); +set_sta_flag (sta,WLAN_STA_RATE_CONTROL ); } static inline void rate_control_rate_update(struct ieee80211_local *local,
net/mac80211/sta_info.h +2 -0
@@ -52,6 +52,7 @@* @WLAN_STA_SP: Station is in a service period, so don't try to * reply to other uAPSD trigger frames or PS-Poll. * @WLAN_STA_4ADDR_EVENT: 4-addr event was already sent for this frame. +* @WLAN_STA_RATE_CONTROL: rate control was initialized for this station. */ enum ieee80211_sta_info_flags {WLAN_STA_AUTH ,
@@ -71,6 +72,7 @@ enum ieee80211_sta_info_flags {WLAN_STA_UAPSD ,WLAN_STA_SP ,WLAN_STA_4ADDR_EVENT , + WLAN_STA_RATE_CONTROL, }; enum ieee80211_sta_state {
Signature · 1 line
1.7.4.4
Quoted 1 line
From
ecdf3e49fd8bcb6c09adf2558f6508f928e35af0Mon Sep 17 00:00:00 2001
From: Felix Fietkau <[email protected]>
Date: Wed, 8 Feb 2012 19:17:11 +0100
Subject: [PATCH 2/2] mac80211: do not call rate control .tx_status before
.rate_init
Most rate control implementations assume .get_rate and .tx_status are only called once the per-station data has been fully initialized. minstrel_ht crashes if this assumption is violated.
--- net/mac80211/rate.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/mac80211/rate.h +1 -1
@@ -41,7 +41,7 @@ static inline void rate_control_tx_status(struct ieee80211_local *local,struct ieee80211_sta *ista = &sta->sta;void *priv_sta = sta->rate_ctrl_priv; -if (!ref) +if (!ref || !test_sta_flag (sta,WLAN_STA_RATE_CONTROL ))return ; ref->ops->tx_status (ref->priv, sband, ista, priv_sta, skb);
Signature · 1 line
1.7.4.4
Quoted 56 lines · John W. Linville
Quoted 46 lines · Felix Fietkau
Quoted 45 lines · Pavel Roskin
Quoted 30 lines · On Wed, 8 Feb 2012 14:44:54 -0500 "John W. Linville" <[email protected]>…
Quoted 29 lines · Felix Fietkau
Quoted 28 lines · John W. Linville
Quoted 24 lines · Felix Fietkau
Most rate control implementations assume .get_rate and .tx_status are only called once the per-station data has been fully initialized.
minstrel_htcrashes if this assumption is violated.Signed-off-by Felix Fietkau <[email protected]>Tested-by Arend van Spriel <[email protected]>--- net/mac80211/rate.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)net/mac80211/rate.h +0
-0@@ -37,7 +37,7 @@ static inline voidrate_control_tx_status(struct
ieee80211_local*local, structieee80211_sta*ista =&sta->sta; void*priv_sta=sta->rate_ctrl_priv;net/mac80211/rate.h +1
-1-if (!ref) +if (!ref || !test_sta_flag (sta,WLAN_STA_RATE_CONTROL ))return ; ref->ops->tx_status(ref->priv, sband, ista, priv_sta,Quoted 1 line
skb);
Any reason not to apply this for 3.3? Or stable?
Quoted 5 lines
Quoted 3 lines
I think 3.3 doesn't have that sta flag, the issue was probably introduced with the 3.4 changes.
I don't remember something like this appearing in earlier versions.Cool, thanks.
I believe 3.3 is affected. At least it looks like the Fedora bug 768639
(https://bugzilla.redhat.com/show_bug.cgi?id=768639) is caused by calling .tx_status at a wrong time. Fedora kernels use compat-wireless-3.3. I'm going to test the bleeding edge compat-wireless with the patch by Felix to see if it fixes things.Quoted 8 lines
Quoted 5 lines
The lack of the
WLAN_STA_RATE_CONTROLflag doesn't mean that the old behavior was correct. The flag was introduced to correct that behavior.The oldest report is dated 2011-12-17 and it's about Linux 3.2.0-rc5 with compat-wireless-2011-12-01.
Only .get_rate and .tx_status are affected, wireless-testing commit
e1936e9407138b483e6d1332dd944afec8131f30adds one of the checks, and my commit adds the other. Maybe John could merge those two to 3.3.
Quoted 7 lines
At least one of them will cause some merge issues. Can someone try the attached patches to verify that they actually fix a real problem in 3.3?
Thanks!
John
Hi John,
This patch fixes NULL deref issue I found and bisected in wireless-testing earlier this week (see [1]). I don't think gives a problem with 3.3 at the moment.
Gr. AvS
[1] http://www.spinics.net/lists/linux-wireless/msg84575.html
Quoted 3 lines · On Thu, 09 Feb 2012 01:51:51 +0100 Felix Fietkau <[email protected]> wrote:
Only .get_rate and .tx_status are affected, wireless-testing commit
e1936e9407138b483e6d1332dd944afec8131f30adds one of the checks, and my commit adds the other. Maybe John could merge those two to 3.3.
I ran the "affected" laptop with ath9k rate control overnight with compat-wireless-2012-02-06 and both patches. As strange as it is, I still got a pair of "-1 events" less than a millisecond apart. It took 18433 seconds (about 4 hours) to reproduce.
I wish I put more instrumentation into the ath9k rate control code. I absolutely didn't expect the issue to stay.
I tried to find a way to reproduce the "-1 event" quickly, I even put the laptop in a microwave oven while running flood ping to the router. Too bad, nothing interesting happened.
The full kernel log is attached. Also, I'm getting "ath: Failed to stop TX DMA, queues=0x001!"; it wasn't there with compat-wireless 3.3.
It looks like the issue with ath9k rate control is separate and I have no standing (as lawyers would say) with regard to the already committed patches.
Signature · 2 lines
Regards, Pavel Roskin
Quoted 3 lines · Pavel Roskin
I tried to find a way to reproduce the "-1 event" quickly, I even put the laptop in a microwave oven while running flood ping to the router. Too bad, nothing interesting happened.
Switch it on, the oven that is!