linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mac80211: Defer setting of RX_FLAG_DECRYPTED.
@ 2007-10-07 14:35 Mattias Nissler
  2007-10-07 14:53 ` Michael Buesch
  2007-10-08  9:34 ` Johannes Berg
  0 siblings, 2 replies; 7+ messages in thread
From: Mattias Nissler @ 2007-10-07 14:35 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, rt2400-devel

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.

Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>
---
 net/mac80211/rx.c |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index de3f7ae..34699a1 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -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)
-- 
1.5.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] mac80211: Defer setting of RX_FLAG_DECRYPTED.
  2007-10-07 14:35 [PATCH] mac80211: Defer setting of RX_FLAG_DECRYPTED Mattias Nissler
@ 2007-10-07 14:53 ` Michael Buesch
  2007-10-07 15:05   ` Mattias Nissler
  2007-10-08  9:34 ` Johannes Berg
  1 sibling, 1 reply; 7+ messages in thread
From: Michael Buesch @ 2007-10-07 14:53 UTC (permalink / raw)
  To: Mattias Nissler; +Cc: Johannes Berg, linux-wireless, rt2400-devel

On Sunday 07 October 2007 16:35:31 Mattias Nissler wrote:
> 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.
> 
> Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>
> ---
>  net/mac80211/rx.c |   20 +++++++++++---------
>  1 files changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
> index de3f7ae..34699a1 100644
> --- a/net/mac80211/rx.c
> +++ b/net/mac80211/rx.c
> @@ -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 */

I think this comment doesn't apply then anymore, eh?

> +	rx->u.rx.status->flag |= RX_FLAG_DECRYPTED;
> +
> +	return result;
>  }
>  
>  static void ap_sta_ps_start(struct net_device *dev, struct sta_info *sta)



-- 
Greetings Michael.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mac80211: Defer setting of RX_FLAG_DECRYPTED.
  2007-10-07 14:53 ` Michael Buesch
@ 2007-10-07 15:05   ` Mattias Nissler
  2007-10-09 20:12     ` Johannes Berg
  0 siblings, 1 reply; 7+ messages in thread
From: Mattias Nissler @ 2007-10-07 15:05 UTC (permalink / raw)
  To: Michael Buesch; +Cc: Johannes Berg, linux-wireless, rt2400-devel

On Sun, 2007-10-07 at 16:53 +0200, Michael Buesch wrote:
> On Sunday 07 October 2007 16:35:31 Mattias Nissler wrote:
> > +	/* 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.

Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>
---
 net/mac80211/rx.c |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index de3f7ae..34699a1 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -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)
-- 
1.5.3



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] mac80211: Defer setting of RX_FLAG_DECRYPTED.
  2007-10-07 14:35 [PATCH] mac80211: Defer setting of RX_FLAG_DECRYPTED Mattias Nissler
  2007-10-07 14:53 ` Michael Buesch
@ 2007-10-08  9:34 ` Johannes Berg
  2007-10-09  9:12   ` Johannes Berg
  1 sibling, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2007-10-08  9:34 UTC (permalink / raw)
  To: Mattias Nissler; +Cc: linux-wireless, rt2400-devel

[-- Attachment #1: Type: text/plain, Size: 524 bytes --]

On Sun, 2007-10-07 at 16:35 +0200, Mattias Nissler wrote:
> 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.

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

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mac80211: Defer setting of RX_FLAG_DECRYPTED.
  2007-10-08  9:34 ` Johannes Berg
@ 2007-10-09  9:12   ` Johannes Berg
  0 siblings, 0 replies; 7+ messages in thread
From: Johannes Berg @ 2007-10-09  9:12 UTC (permalink / raw)
  To: Mattias Nissler; +Cc: linux-wireless, rt2400-devel

[-- Attachment #1: Type: text/plain, Size: 391 bytes --]

On Mon, 2007-10-08 at 11:34 +0200, Johannes Berg wrote:

> 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

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mac80211: Defer setting of RX_FLAG_DECRYPTED.
  2007-10-07 15:05   ` Mattias Nissler
@ 2007-10-09 20:12     ` Johannes Berg
  2007-10-10 21:07       ` Mattias Nissler
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2007-10-09 20:12 UTC (permalink / raw)
  To: Mattias Nissler; +Cc: Michael Buesch, linux-wireless, rt2400-devel

[-- Attachment #1: Type: text/plain, Size: 2280 bytes --]

On Sun, 2007-10-07 at 17:05 +0200, Mattias Nissler wrote:

> 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.
> 
> Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>

Reviewed-by: Johannes Berg <johannes@sipsolutions.net>

However, the patch is mangled (line-wrapped)

> ---
>  net/mac80211/rx.c |   20 +++++++++++---------
>  1 files changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
> index de3f7ae..34699a1 100644
> --- a/net/mac80211/rx.c
> +++ b/net/mac80211/rx.c
> @@ -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)

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] mac80211: Defer setting of RX_FLAG_DECRYPTED.
  2007-10-09 20:12     ` Johannes Berg
@ 2007-10-10 21:07       ` Mattias Nissler
  0 siblings, 0 replies; 7+ messages in thread
From: Mattias Nissler @ 2007-10-10 21:07 UTC (permalink / raw)
  To: Johannes Berg; +Cc: Michael Buesch, linux-wireless, rt2400-devel

On Tue, 2007-10-09 at 22:12 +0200, Johannes Berg wrote:
> On Sun, 2007-10-07 at 17:05 +0200, Mattias Nissler wrote:
> 
> > 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.
> > 
> > Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>
> 
> Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
> 
> However, the patch is mangled (line-wrapped)

Sorry. Comes from editing patches manually. I see John already took care
of it ;-)

Mattias


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-10-10 21:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-07 14:35 [PATCH] mac80211: Defer setting of RX_FLAG_DECRYPTED Mattias Nissler
2007-10-07 14:53 ` Michael Buesch
2007-10-07 15:05   ` Mattias Nissler
2007-10-09 20:12     ` Johannes Berg
2007-10-10 21:07       ` Mattias Nissler
2007-10-08  9:34 ` Johannes Berg
2007-10-09  9:12   ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).