Skip to contentSkip to conversation

mac80211/minstrel: fix NULL pointer dereference issue

PATCH Applied Felix Fietkau 4 participants 6 messages Jul 15, 2013 – Jul 16, 2013 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac80211/minstrel: fix NULL pointer dereference issue

When priv_sta == NULL, mi->prev_sample is dereferenced too early. Move the assignment further down, after the rate_control_send_low call.

---
 net/mac80211/rc80211_minstrel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/mac80211/rc80211_minstrel.c +2 -1
index ac7ef54..e6512e2 100644
@@ -290,7 +290,7 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta,
 	struct minstrel_rate *msr, *mr;
 	unsigned int ndx;
 	bool mrr_capable;
-	bool prev_sample = mi->prev_sample;
+	bool prev_sample;
 	int delta;
 	int sampling_ratio;
 
@@ -314,6 +314,7 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta,
 			(mi->sample_count + mi->sample_deferred / 2);
 
 	/* delta < 0: no sampling required */
+	prev_sample = mi->prev_sample;
 	mi->prev_sample = false;
 	if (delta < 0 || (!mrr_capable && prev_sample))
 		return;
Signature · 1 line
1.8.0.2
#1 lore raw
Quoted 6 lines · Felix Fietkau

When priv_sta == NULL, mi->prev_sample is dereferenced too early. Move the assignment further down, after the rate_control_send_low call.

Why should this be marked for stable?

It's a local reference only, it's not used.

It's like suggesting that all the initialized
automatics should not be set until after
rate_control_set_low is called.

Quoted 25 lines
---
 net/mac80211/rc80211_minstrel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/mac80211/rc80211_minstrel.c +2 -1
index ac7ef54..e6512e2 100644
@@ -290,7 +290,7 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta,
 	struct minstrel_rate *msr, *mr;
 	unsigned int ndx;
 	bool mrr_capable;
-	bool prev_sample = mi->prev_sample;
+	bool prev_sample;
 	int delta;
 	int sampling_ratio;
 
@@ -314,6 +314,7 @@ minstrel_get_rate(void *priv, struct ieee80211_sta *sta,
 			(mi->sample_count + mi->sample_deferred / 2);
 
 	/* delta < 0: no sampling required */
+	prev_sample = mi->prev_sample;
 	mi->prev_sample = false;
 	if (delta < 0 || (!mrr_capable && prev_sample))
 		return;
#2 lore raw
Quoted 8 lines · Joe Perches
Quoted 6 lines · Felix Fietkau

When priv_sta == NULL, mi->prev_sample is dereferenced too early. Move the assignment further down, after the rate_control_send_low call.

Quoted 7 lines

Why should this be marked for stable?

It's a local reference only, it's not used.

It's like suggesting that all the initialized
automatics should not be set until after
rate_control_set_low is called.

mi is set to priv_sta. It can be NULL. The case of priv_sta==NULL is caught by rate_control_send_low and causes it to bail out.

- Felix

#3 lore raw
Quoted 4 lines · Felix Fietkau
Quoted 3 lines · Joe Perches
Quoted 2 lines · Felix Fietkau

When priv_sta == NULL, mi->prev_sample is dereferenced too early. Move the assignment further down, after the rate_control_send_low call.

[]

Quoted 2 lines

mi is set to priv_sta. It can be NULL. The case of priv_sta==NULL is caught by rate_control_send_low and causes it to bail out.

OK, thanks.

maintainer Applied
#5 lore raw
In reply to Felix Fietkau
Quoted 2 lines · Felix Fietkau

When priv_sta == NULL, mi->prev_sample is dereferenced too early. Move the assignment further down, after the rate_control_send_low call.

Applied.

johannes