Commit 3590eea4 authored by Ivo van Doorn's avatar Ivo van Doorn Committed by John W. Linville

rt2x00: Validate MCS on RX path

Similar to the PLCP signal and bitrates values,
we should validate the MCS value from the RX descriptor
before sending it to mac80211.
Signed-off-by: default avatarIvo van Doorn <IvDoorn@gmail.com>
Acked-by: default avatarHelmut Schaa <helmut.schaa@googlemail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent cdfd2c5c
...@@ -432,36 +432,44 @@ static int rt2x00lib_rxdone_read_signal(struct rt2x00_dev *rt2x00dev, ...@@ -432,36 +432,44 @@ static int rt2x00lib_rxdone_read_signal(struct rt2x00_dev *rt2x00dev,
struct ieee80211_supported_band *sband; struct ieee80211_supported_band *sband;
const struct rt2x00_rate *rate; const struct rt2x00_rate *rate;
unsigned int i; unsigned int i;
int signal; int signal = rxdesc->signal;
int type; int type = (rxdesc->dev_flags & RXDONE_SIGNAL_MASK);
/* switch (rxdesc->rate_mode) {
* For non-HT rates the MCS value needs to contain the case RATE_MODE_CCK:
* actually used rate modulation (CCK or OFDM). case RATE_MODE_OFDM:
*/ /*
if (rxdesc->dev_flags & RXDONE_SIGNAL_MCS) * For non-HT rates the MCS value needs to contain the
signal = RATE_MCS(rxdesc->rate_mode, rxdesc->signal); * actually used rate modulation (CCK or OFDM).
else */
signal = rxdesc->signal; if (rxdesc->dev_flags & RXDONE_SIGNAL_MCS)
signal = RATE_MCS(rxdesc->rate_mode, signal);
type = (rxdesc->dev_flags & RXDONE_SIGNAL_MASK);
sband = &rt2x00dev->bands[rt2x00dev->curr_band];
sband = &rt2x00dev->bands[rt2x00dev->curr_band]; for (i = 0; i < sband->n_bitrates; i++) {
for (i = 0; i < sband->n_bitrates; i++) { rate = rt2x00_get_rate(sband->bitrates[i].hw_value);
rate = rt2x00_get_rate(sband->bitrates[i].hw_value); if (((type == RXDONE_SIGNAL_PLCP) &&
(rate->plcp == signal)) ||
if (((type == RXDONE_SIGNAL_PLCP) && ((type == RXDONE_SIGNAL_BITRATE) &&
(rate->plcp == signal)) || (rate->bitrate == signal)) ||
((type == RXDONE_SIGNAL_BITRATE) && ((type == RXDONE_SIGNAL_MCS) &&
(rate->bitrate == signal)) || (rate->mcs == signal))) {
((type == RXDONE_SIGNAL_MCS) && return i;
(rate->mcs == signal))) { }
return i;
} }
break;
case RATE_MODE_HT_MIX:
case RATE_MODE_HT_GREENFIELD:
if (signal >= 0 && signal <= 76)
return signal;
break;
default:
break;
} }
WARNING(rt2x00dev, "Frame received with unrecognized signal, " WARNING(rt2x00dev, "Frame received with unrecognized signal, "
"signal=0x%.4x, type=%d.\n", signal, type); "mode=0x%.4x, signal=0x%.4x, type=%d.\n",
rxdesc->rate_mode, signal, type);
return 0; return 0;
} }
...@@ -523,18 +531,12 @@ void rt2x00lib_rxdone(struct queue_entry *entry) ...@@ -523,18 +531,12 @@ void rt2x00lib_rxdone(struct queue_entry *entry)
skb_trim(entry->skb, rxdesc.size); skb_trim(entry->skb, rxdesc.size);
/* /*
* Check if the frame was received using HT. In that case, * Translate the signal to the correct bitrate index.
* the rate is the MCS index and should be passed to mac80211
* directly. Otherwise we need to translate the signal to
* the correct bitrate index.
*/ */
if (rxdesc.rate_mode == RATE_MODE_CCK || rate_idx = rt2x00lib_rxdone_read_signal(rt2x00dev, &rxdesc);
rxdesc.rate_mode == RATE_MODE_OFDM) { if (rxdesc.rate_mode == RATE_MODE_HT_MIX ||
rate_idx = rt2x00lib_rxdone_read_signal(rt2x00dev, &rxdesc); rxdesc.rate_mode == RATE_MODE_HT_GREENFIELD)
} else {
rxdesc.flags |= RX_FLAG_HT; rxdesc.flags |= RX_FLAG_HT;
rate_idx = rxdesc.signal;
}
/* /*
* Update extra components * Update extra components
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment