From: "voncken" <cedric.voncken@acksys.fr>
To: "'Emmanuel Grumbach'" <egrumbach@gmail.com>
Cc: "'linux-wireless'" <linux-wireless@vger.kernel.org>,
"'Johannes Berg'" <johannes@sipsolutions.net>
Subject: RE: Mac80211 : Wpa rekeying issue
Date: Thu, 31 Dec 2015 09:12:26 +0100 [thread overview]
Message-ID: <0a6a01d143a2$fcb77720$f6266560$@acksys.fr> (raw)
In-Reply-To: <0a5101d1424c$eb46d2d0$c1d47870$@acksys.fr>
[-- Attachment #1: Type: text/plain, Size: 2698 bytes --]
Hi,
I'm not a WPA expert and security expert,
Could you explain why the patch sent by Alexander Wetzel break the security properties of this code?
The Alexander's patch is in attachment.
Thanks for your help.
> -----Message d'origine-----
> De : linux-wireless-owner@vger.kernel.org [mailto:linux-wireless-
> owner@vger.kernel.org] De la part de voncken
> Envoyé : mardi 29 décembre 2015 16:24
> À : 'Emmanuel Grumbach'
> Cc : 'linux-wireless'; 'Johannes Berg'
> Objet : RE: Mac80211 : Wpa rekeying issue
>
> > -----Message d'origine-----
> > De : Emmanuel Grumbach [mailto:egrumbach@gmail.com] Envoyé : mardi 29
> > décembre 2015 15:20 À : Cedric VONCKEN Cc : linux-wireless Objet : Re:
> > Mac80211 : Wpa rekeying issue
> >
> > On Tue, Dec 29, 2015 at 3:01 PM, Cedric VONCKEN
> > <cedric.voncken@acksys.fr>
> > wrote:
> > > Hi,
> > >
> > > My test plateform is:
> > > 2 equipements
> > > Both equipment used compat version 2015-07-21 from openwrt.
> > > Both equipment used security WPA2
> > >
> > > The equipment #1 is an AP.
> > > The Group rekey interval is set to 3601s
> > > The Pair rekey interval set to 50s (I reduced this value to
> > > show the issue often)
> > > The Master rekey interval is set to 86400 s.
> > >
> > > The equipment #2 is a sta+wds
> > >
> > > I used a 5GHz channel to have a free channel (without other AP) I
> > > connected a computer on each equipment.
> > >
> > > To reproduce the issue:
> > > I ran iperf udp@50Mbps from computer connected to the AP to
> > > the computer connected to the sta. After several WPA2 rekeying,
> > > iperf server side didn't received any frame.
> > >
> > > I investigated in the driver. All packets are dropped in sta side,
> > > because the function ieee80211_crypto_ccmp_decrypt return
> > > Rx_DROP_UNUSABLE. This function return this code because the test
> > > if(memcmp(pn,key->u.ccmp.rx_pn[queue],IEEE8021_CCMP_PN_LEN) <=0)
> > > return true.
> > >
> > > Have you any idea to fix this issue?
> > >
> >
> > I don't remember exactly what we had, but you may look at
> > http://permalink.gmane.org/gmane.linux.kernel.wireless.general/137742
>
> Thanks for the link, I think I'm in the same situation.
>
> How can I fix this issue?
>
> Because the patch sent by Alexander Wetzel was rejected by Johannes (for
> security reason), and if I disable the hw crypto I will have performance
> issue.
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless"
> in the body of a message to majordomo@vger.kernel.org More majordomo info
> at http://vger.kernel.org/majordomo-info.html
[-- Attachment #2: fix1.patch --]
[-- Type: application/octet-stream, Size: 3731 bytes --]
diff -ur linux-4.0.4-gentoo/net/mac80211/key.h linux-4.0.4-gentoo_patched/net/mac80211/key.h
--- linux-4.0.4-gentoo/net/mac80211/key.h 2015-04-13 00:12:50.000000000 +0200
+++ linux-4.0.4-gentoo_patched/net/mac80211/key.h 2015-05-20 13:16:06.370256697 +0200
@@ -84,12 +84,14 @@
* Management frames.
*/
u8 rx_pn[IEEE80211_NUM_TIDS + 1][IEEE80211_CCMP_PN_LEN];
+ u8 rx_pn_old[IEEE80211_NUM_TIDS + 1][IEEE80211_CCMP_PN_LEN];
struct crypto_aead *tfm;
u32 replays; /* dot11RSNAStatsCCMPReplays */
} ccmp;
struct {
atomic64_t tx_pn;
u8 rx_pn[IEEE80211_CMAC_PN_LEN];
+ u8 rx_pn_old[IEEE80211_CMAC_PN_LEN];
struct crypto_cipher *tfm;
u32 replays; /* dot11RSNAStatsCMACReplays */
u32 icverrors; /* dot11RSNAStatsCMACICVErrors */
@@ -97,6 +99,7 @@
struct {
atomic64_t tx_pn;
u8 rx_pn[IEEE80211_GMAC_PN_LEN];
+ u8 rx_pn_old[IEEE80211_GMAC_PN_LEN];
struct crypto_aead *tfm;
u32 replays; /* dot11RSNAStatsCMACReplays */
u32 icverrors; /* dot11RSNAStatsCMACICVErrors */
@@ -109,12 +112,14 @@
* Management frames.
*/
u8 rx_pn[IEEE80211_NUM_TIDS + 1][IEEE80211_GCMP_PN_LEN];
+ u8 rx_pn_old[IEEE80211_NUM_TIDS + 1][IEEE80211_GCMP_PN_LEN];
struct crypto_aead *tfm;
u32 replays; /* dot11RSNAStatsGCMPReplays */
} gcmp;
struct {
/* generic cipher scheme */
u8 rx_pn[IEEE80211_NUM_TIDS + 1][MAX_PN_LEN];
+ u8 rx_pn_old[IEEE80211_NUM_TIDS + 1][MAX_PN_LEN];
} gen;
} u;
diff -ur linux-4.0.4-gentoo/net/mac80211/wpa.c linux-4.0.4-gentoo_patched/net/mac80211/wpa.c
--- linux-4.0.4-gentoo/net/mac80211/wpa.c 2015-04-13 00:12:50.000000000 +0200
+++ linux-4.0.4-gentoo_patched/net/mac80211/wpa.c 2015-05-20 21:43:25.529721066 +0200
@@ -495,6 +495,7 @@
struct sk_buff *skb = rx->skb;
struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb);
u8 pn[IEEE80211_CCMP_PN_LEN];
+ static u8 zero[IEEE80211_CCMP_PN_LEN];
int data_len;
int queue;
@@ -525,6 +526,31 @@
return RX_DROP_UNUSABLE;
}
+ /* HACK: try to work around race when replacing PSK with enabled hardware offload on AP or STA */
+ if (unlikely(memcmp(key->u.ccmp.rx_pn[queue], zero, IEEE80211_CCMP_PN_LEN) == 0 )) {
+
+ printk ("DDD - rx_pn is zero, virgin key detected! pl=%x\n", pn[IEEE80211_CCMP_PN_LEN-1]);
+ print_hex_dump_debug("cnt: ", DUMP_PREFIX_OFFSET, IEEE80211_CCMP_PN_LEN, 1, key->u.ccmp.rx_pn[queue], IEEE80211_CCMP_PN_LEN, false);
+ print_hex_dump_debug("pn : ", DUMP_PREFIX_OFFSET, IEEE80211_CCMP_PN_LEN, 1, pn, IEEE80211_CCMP_PN_LEN, false);
+
+ if ((memcmp(pn, zero, IEEE80211_CCMP_PN_LEN -1) == 0) && pn[IEEE80211_CCMP_PN_LEN-1] <= 10) {
+ /* pn is <=10 , we can start using the new counter */
+ printk ("DDD - set new pn\n");
+ memcpy(key->u.ccmp.rx_pn[queue], pn, IEEE80211_CCMP_PN_LEN);
+ } else if (memcmp(pn, key->u.ccmp.rx_pn_old[queue], IEEE80211_CCMP_PN_LEN) <= 0) {
+ printk ("DDD - attack!\n");
+ /* reply attack during rekey operation, guess it will really hard to do that... */
+ key->u.ccmp.replays++; /* we count it as an reply anyway...*/
+ return RX_DROP_UNUSABLE;
+ } else {
+ printk ("DDD - prevent poisening \n");
+ memcpy(key->u.ccmp.rx_pn_old[queue], pn, IEEE80211_CCMP_PN_LEN);
+ }
+ } else {
+
+ memcpy(key->u.ccmp.rx_pn[queue], pn, IEEE80211_CCMP_PN_LEN);
+ }
+
if (!(status->flag & RX_FLAG_DECRYPTED)) {
u8 aad[2 * AES_BLOCK_SIZE];
u8 b_0[AES_BLOCK_SIZE];
@@ -539,8 +565,6 @@
return RX_DROP_UNUSABLE;
}
- memcpy(key->u.ccmp.rx_pn[queue], pn, IEEE80211_CCMP_PN_LEN);
-
/* Remove CCMP header and MIC */
if (pskb_trim(skb, skb->len - mic_len))
return RX_DROP_UNUSABLE;
next prev parent reply other threads:[~2015-12-31 8:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-29 13:01 Mac80211 : Wpa rekeying issue Cedric VONCKEN
2015-12-29 14:19 ` Emmanuel Grumbach
2015-12-29 15:23 ` voncken
2015-12-31 8:12 ` voncken [this message]
2015-12-31 8:41 ` Emmanuel Grumbach
2015-12-31 10:15 ` voncken
2015-12-31 15:25 ` Ben Greear
2016-01-05 9:19 ` Johannes Berg
2016-01-05 9:47 ` Matthias May
2016-01-05 9:58 ` Johannes Berg
2016-01-05 10:54 ` Matthias May
2016-01-05 15:50 ` Johannes Berg
2016-01-06 9:09 ` Matthias May
2016-01-07 21:06 ` Johannes Berg
2016-01-07 21:15 ` Johannes Berg
2016-01-12 11:38 ` Emmanuel Grumbach
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='0a6a01d143a2$fcb77720$f6266560$@acksys.fr' \
--to=cedric.voncken@acksys.fr \
--cc=egrumbach@gmail.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).