mac80211: Defer setting of RX_FLAG_DECRYPTED.
PATCH 1/1 mac80211: Defer setting of RX_FLAG_DECRYPTED.
The decryption handlers will skip the frame if the RX_FLAG_DECRYPTED flag is set, so the early flag setting introduced by Johannes breaks decryption. To work around this, call the handlers first and then set the flag.
--- net/mac80211/rx.c | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-)
net/mac80211/rx.c +11 -9
@@ -424,6 +424,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx)struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;int keyidx;int hdrlen; +ieee80211_txrx_result result =TXRX_DROP ;struct ieee80211_key *stakey =NULL ;/*
@@ -522,21 +523,22 @@ ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx) ieee80211_wep_is_weak_iv(rx->skb, rx->key)) rx->sta->wep_weak_iv_count++; -/* either the frame will be decrypted or dropped */ - rx->u.rx.status->flag |=RX_FLAG_DECRYPTED ; -switch (rx->key->conf.alg) {case ALG_WEP : -return ieee80211_crypto_wep_decrypt (rx); + result =ieee80211_crypto_wep_decrypt (rx); +break ;case ALG_TKIP : -return ieee80211_crypto_tkip_decrypt (rx); + result =ieee80211_crypto_tkip_decrypt (rx); +break ;case ALG_CCMP : -return ieee80211_crypto_ccmp_decrypt (rx); + result =ieee80211_crypto_ccmp_decrypt (rx); +break ; } -/* not reached */ -WARN_ON (1 ); -return TXRX_DROP ; +/* either the frame will be decrypted or dropped */ + rx->u.rx.status->flag |=RX_FLAG_DECRYPTED ; + +return result; }static void ap_sta_ps_start (struct net_device *dev,struct sta_info *sta)
Signature · 1 line
1.5.3
Quoted 38 lines · On Sunday 07 October 2007 16:35:31 Mattias Nissler wrote:
The decryption handlers will skip the frame if the
RX_FLAG_DECRYPTEDflag is set, so the early flag setting introduced by Johannes breaks decryption. To work around this, call the handlers first and then set the flag.Signed-off-by Mattias Nissler <[email protected]>--- net/mac80211/rx.c | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-)net/mac80211/rx.c +5
-5@@ -424,6 +424,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx)struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;int keyidx;int hdrlen; +ieee80211_txrx_result result =TXRX_DROP ;struct ieee80211_key *stakey =NULL ;/* @@ -522,21 +523,22 @@ ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx) ieee80211_wep_is_weak_iv(rx->skb, rx->key)) rx->sta->wep_weak_iv_count++; -/* either the frame will be decrypted or dropped */ - rx->u.rx.status->flag |=RX_FLAG_DECRYPTED ; -switch (rx->key->conf.alg) {case ALG_WEP : -return ieee80211_crypto_wep_decrypt (rx); + result =ieee80211_crypto_wep_decrypt (rx); +break ;case ALG_TKIP : -return ieee80211_crypto_tkip_decrypt (rx); + result =ieee80211_crypto_tkip_decrypt (rx); +break ;
net/mac80211/rx.c ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx) · line 538
Quoted 10 lines
net/mac80211/rx.c +3
-4case ALG_CCMP : -return ieee80211_crypto_ccmp_decrypt (rx); + result =ieee80211_crypto_ccmp_decrypt (rx); +break ; } -/* not reached */ -WARN_ON (1 ); -return TXRX_DROP ; +/* either the frame will be decrypted or dropped */
I think this comment doesn't apply then anymore, eh?
Quoted 6 lines
net/mac80211/rx.c +3
-0+ rx->u.rx.status->flag |=RX_FLAG_DECRYPTED ; + +return result; }static void ap_sta_ps_start (struct net_device *dev,struct sta_info *sta)
Signature · 1 line
Greetings Michael.
Quoted 4 lines · Michael Buesch
Review
Quoted 1 line · On Sunday 07 October 2007 16:35:31 Mattias Nissler wrote:
(quoted diff) +1
-0+ /* either the frame will be decrypted or dropped */I think this comment doesn't apply then anymore, eh?
Well, I changed the wording to "has been decrypted or will be dropped".
Mattias
The decryption handlers will skip the frame if the RX_FLAG_DECRYPTED flag is set, so the early flag setting introduced by Johannes breaks decryption. To work around this, call the handlers first and then set the flag.
--- net/mac80211/rx.c | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-)
net/mac80211/rx.c +0 -0
@@ -424,6 +424,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_txrx_data
*rx)
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)
rx->skb->data;
int keyidx;
int hdrlen;
+ ieee80211_txrx_result result = TXRX_DROP;
struct ieee80211_key *stakey = NULL;
/*
@@ -522,21 +523,22 @@ ieee80211_rx_h_decrypt(struct ieee80211_txrx_data
*rx)
ieee80211_wep_is_weak_iv(rx->skb, rx->key))
rx->sta->wep_weak_iv_count++;- /* either the frame will be decrypted or dropped */
- rx->u.rx.status->flag |= RX_FLAG_DECRYPTED;
-
switch (rx->key->conf.alg) {
case ALG_WEP:
- return ieee80211_crypto_wep_decrypt(rx);
+ result = ieee80211_crypto_wep_decrypt(rx);
+ break;
case ALG_TKIP:
- return ieee80211_crypto_tkip_decrypt(rx);
+ result = ieee80211_crypto_tkip_decrypt(rx);
+ break;
case ALG_CCMP:
- return ieee80211_crypto_ccmp_decrypt(rx);
+ result = ieee80211_crypto_ccmp_decrypt(rx);
+ break;
}- /* not reached */ - WARN_ON(1); - return TXRX_DROP; + /* either the frame has been decrypted or will be dropped */ + rx->u.rx.status->flag |= RX_FLAG_DECRYPTED;
+
+ return result;
}
static void ap_sta_ps_start(struct net_device *dev, struct sta_info
*sta)
Signature · 1 line
1.5.3
Quoted 6 lines · Mattias Nissler
The decryption handlers will skip the frame if the
RX_FLAG_DECRYPTEDflag is set, so the early flag setting introduced by Johannes breaks decryption. To work around this, call the handlers first and then set the flag.Signed-off-by Mattias Nissler <[email protected]>
However, the patch is mangled (line-wrapped)
Quoted 52 lines
--- net/mac80211/rx.c | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-)net/mac80211/rx.c +1
-0@@ -424,6 +424,7 @@ ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx)struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) rx->skb->data;int keyidx;int hdrlen; +ieee80211_txrx_result result =TXRX_DROP ;struct ieee80211_key *stakey =NULL ;/*net/mac80211/rx.c +10
-9@@ -522,21 +523,22 @@ ieee80211_rx_h_decrypt(struct ieee80211_txrx_data *rx) ieee80211_wep_is_weak_iv(rx->skb, rx->key)) rx->sta->wep_weak_iv_count++; -/* either the frame will be decrypted or dropped */ - rx->u.rx.status->flag |=RX_FLAG_DECRYPTED ; -switch (rx->key->conf.alg) {case ALG_WEP : -return ieee80211_crypto_wep_decrypt (rx); + result =ieee80211_crypto_wep_decrypt (rx); +break ;case ALG_TKIP : -return ieee80211_crypto_tkip_decrypt (rx); + result =ieee80211_crypto_tkip_decrypt (rx); +break ;case ALG_CCMP : -return ieee80211_crypto_ccmp_decrypt (rx); + result =ieee80211_crypto_ccmp_decrypt (rx); +break ; } -/* not reached */ -WARN_ON (1 ); -return TXRX_DROP ; +/* either the frame has been decrypted or will be dropped */ + rx->u.rx.status->flag |=RX_FLAG_DECRYPTED ; + +return result; }static void ap_sta_ps_start(struct
net_device*dev, structsta_info
*sta)
Quoted 7 lines · Johannes Berg
Quoted 5 lines · Mattias Nissler
The decryption handlers will skip the frame if the
RX_FLAG_DECRYPTEDflag is set, so the early flag setting introduced by Johannes breaks decryption. To work around this, call the handlers first and then set the flag.
Quoted 5 lines
Quoted 1 line
Signed-off-by Mattias Nissler <[email protected]>Reviewed-by Johannes Berg <[email protected]>However, the patch is mangled (line-wrapped)
Sorry. Comes from editing patches manually. I see John already took care of it ;-)
Mattias
Johannes Berg
maintainerQuoted 4 lines · Mattias Nissler
The decryption handlers will skip the frame if the
RX_FLAG_DECRYPTEDflag is set, so the early flag setting introduced by Johannes breaks decryption. To work around this, call the handlers first and then set the flag.
Huh. Sorry about that. I had a patch like this initially but then wanted to not clutter the code. I think we should instead remove the checks from the actual decryption functions though. Mind making a patch for that?
johannes
Johannes Berg
maintainerQuoted 4 lines · Johannes Berg
Huh. Sorry about that. I had a patch like this initially but then wanted to not clutter the code. I think we should instead remove the checks from the actual decryption functions though. Mind making a patch for that?
Never mind. This looks better since it doesn't require rewriting half the crypto code.
johannes