From: Brandon Craig Rhodes <brandon@rhodesmill.org>
To: netdev@vger.kernel.org
Subject: TKIP encryption should allocate enough tailroom
Date: Tue, 16 Jan 2007 21:31:40 -0500 [thread overview]
Message-ID: <87bqky759v.fsf@ten22.rhodesmill.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1284 bytes --]
After frustrating days of hung TCP connections, I have determined that
the encryption routines in net/iee80211/ieee80211_crypt_tkip.c should
be more aggressive in providing themselves with enough packet tailroom
to perform their encryption.
They presently will only perform encryption if the packet handed to
them happens to be stored with enough tailroom already; otherwise,
they drop the packet. If ieee80211_michael_mic_add() does not find
the eight bytes of tailroom it needs, it produces a message like
kernel: Invalid packet for Michael MIC add (tailroom=6 hdr_len=24 skb->len=92)
and drops the packet. The ieee80211_tkip_encrypt() function that
follows is less needy, requiring only four bytes of tailroom - but
fails to log anything at all when it drops a packet!
The attached patch, if applied to kernel 2.6.18, solves both problems.
I am not very familiar with the conventions of kernel networking code,
so there may be better ways of fixing this; but the patch should
illustrate the general idea, and perhaps provides others in my unhappy
situation with stable WPA connections until someone can provide a more
authorized patch.
And thanks for all the great code, guys; this is the first problem I
have had with the networking stack in eleven years of using Linux.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ieee80211-tkip-tailroom.patch --]
[-- Type: text/x-diff, Size: 1376 bytes --]
--- net/ieee80211/ieee80211_crypt_tkip.c.orig 2007-01-10 10:20:40.000000000 -0500
+++ net/ieee80211/ieee80211_crypt_tkip.c 2007-01-16 21:21:51.000000000 -0500
@@ -334,9 +334,19 @@
return -1;
}
- if (skb_tailroom(skb) < 4 || skb->len < hdr_len)
+ if (skb->len < hdr_len)
return -1;
+ if (skb_tailroom(skb) < 4) {
+ int err;
+ err = skb_padto(skb, skb->len + 4);
+ if (unlikely(err || skb_tailroom(skb) < 4)) {
+ printk(KERN_DEBUG "Failed to increase tailroom"
+ " for TKIP encrypt");
+ return err || -1;
+ }
+ }
+
len = skb->len - hdr_len;
pos = skb->data + hdr_len;
@@ -541,13 +551,24 @@
struct ieee80211_tkip_data *tkey = priv;
u8 *pos;
- if (skb_tailroom(skb) < 8 || skb->len < hdr_len) {
+ if (skb->len < hdr_len) {
printk(KERN_DEBUG "Invalid packet for Michael MIC add "
"(tailroom=%d hdr_len=%d skb->len=%d)\n",
skb_tailroom(skb), hdr_len, skb->len);
return -1;
}
+ /* 8 bytes needed here, and 4 for ieee80211_tkip_encrypt() */
+ if (skb_tailroom(skb) < 12) {
+ int err;
+ err = skb_padto(skb, skb->len + 12);
+ if (unlikely(err || skb_tailroom(skb) < 12)) {
+ printk(KERN_DEBUG "Failed to increase tailroom"
+ " for Michael MIC add");
+ return err || -1;
+ }
+ }
+
michael_mic_hdr(skb, tkey->tx_hdr);
pos = skb_put(skb, 8);
if (michael_mic(tkey, &tkey->key[16], tkey->tx_hdr,
[-- Attachment #3: Type: text/plain, Size: 83 bytes --]
--
Brandon Craig Rhodes brandon@rhodesmill.org http://rhodesmill.org/brandon
next reply other threads:[~2007-01-17 2:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-17 2:31 Brandon Craig Rhodes [this message]
2007-01-17 3:39 ` TKIP encryption should allocate enough tailroom Mitchell Blank Jr
2007-01-17 3:34 ` Brandon Craig Rhodes
2007-01-17 6:34 ` Herbert Xu
2007-01-17 7:18 ` Herbert Xu
2007-01-17 3:50 ` Michael Wu
2007-01-17 16:46 ` Brandon Craig Rhodes
2007-01-17 17:23 ` Larry Finger
2007-01-17 17:38 ` Brandon Craig Rhodes
2007-01-18 13:16 ` Pekka Pietikainen
2007-01-18 13:55 ` Brandon Craig Rhodes
2007-01-19 12:23 ` Pekka Pietikainen
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=87bqky759v.fsf@ten22.rhodesmill.org \
--to=brandon@rhodesmill.org \
--cc=netdev@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