Skip to contentSkip to conversation

mac80211: fixed injection in monitor mode

PATCH In review Gabriele Gristina 4 participants 6 messages Oct 16, 2009 – Oct 17, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac80211: fixed injection in monitor mode

I have a problem with mac80211 injection:
if i setup interface in monitor mode with iwconfig and i try to send a custum 802.11 frame i see twice the packet in monitor interface. The first packet is right, the second is different only in the radiotap
header: rtap len is fixed to 13 bytes...
If i setup interface with airmon-ng the packet is sended once but the radiotap header is fixed to 13 bytes.

Patch for 2.6.31.4

mac80211/main.c 2009-10-15 23:06:03.000000000 +0200 renamed from mac80211/main.c.orig 2009-10-16 00:50:00.000000000 +0200 +5 -1
@@ -607,6 +607,9 @@
     skb->protocol = htons(ETH_P_802_2);
     memset(skb->cb, 0, sizeof(skb->cb));
 
+    if (!(info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS))
+        goto out_no_echo;
+
     rcu_read_lock();
     list_for_each_entry_rcu(sdata, &local->interfaces, list) {
         if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {
@@ -630,7 +633,8 @@
         skb = NULL;
     }
     rcu_read_unlock();
-    dev_kfree_skb(skb);
+out_no_echo:
+    if (skb) dev_kfree_skb(skb);
 }
 EXPORT_SYMBOL(ieee80211_tx_status);
 
#1 lore raw
Quoted 23 lines · Gabriele Gristina

I have a problem with mac80211 injection:
if i setup interface in monitor mode with iwconfig and i try to send a custum 802.11 frame i see twice the packet in monitor interface. The first packet is right, the second is different only in the radiotap
header: rtap len is fixed to 13 bytes...
If i setup interface with airmon-ng the packet is sended once but the radiotap header is fixed to 13 bytes.

Patch for 2.6.31.4

mac80211/main.c 2009-10-15 23:06:03.000000000 +0200 renamed from mac80211/main.c.orig 2009-10-16 00:50:00.000000000 +0200 +3 -0
@@ -607,6 +607,9 @@
     skb->protocol = htons(ETH_P_802_2);
     memset(skb->cb, 0, sizeof(skb->cb));
 
+    if (!(info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS))
+        goto out_no_echo;
+
     rcu_read_lock();
     list_for_each_entry_rcu(sdata, &local->interfaces, list) {
         if (sdata->vif.type == NL80211_IFTYPE_MONITOR) {

mac80211/main.c 2009-10-15 23:06:03.000000000 +0200 line 640

Quoted 9 lines
mac80211/main.c 2009-10-15 23:06:03.000000000 +0200 renamed from mac80211/main.c.orig 2009-10-16 00:50:00.000000000 +0200 +2 -1
@@ -630,7 +633,8 @@
         skb = NULL;
     }
     rcu_read_unlock();
-    dev_kfree_skb(skb);
+out_no_echo:
+    if (skb) dev_kfree_skb(skb);
 }
 EXPORT_SYMBOL(ieee80211_tx_status);
 

Thanks for the patch! But I need a Signed-off-by line...

http://linux.yyz.us/patch-format.html

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.
#2 lore raw
In reply to Gabriele Gristina
Quoted 7 lines · Gabriele Gristina

I have a problem with mac80211 injection:
if i setup interface in monitor mode with iwconfig and i try to send a custum 802.11 frame i see twice the packet in monitor interface. The first packet is right, the second is different only in the radiotap
header: rtap len is fixed to 13 bytes...
If i setup interface with airmon-ng the packet is sended once but the radiotap header is fixed to 13 bytes.

This is correct. The patch is wrong.

johannes

author
#3 lore raw

why is wrong?
there's another way to inject once packet?

2009/10/16, Johannes Berg <[email protected]>:

Quoted 13 lines · Gabriele Gristina
Quoted 7 lines

I have a problem with mac80211 injection:
if i setup interface in monitor mode with iwconfig and i try to send a custum 802.11 frame i see twice the packet in monitor interface. The first packet is right, the second is different only in the radiotap
header: rtap len is fixed to 13 bytes...
If i setup interface with airmon-ng the packet is sended once but the radiotap header is fixed to 13 bytes.

This is correct. The patch is wrong.

johannes

#4 lore raw
In reply to Johannes Berg
Quoted 11 lines · Johannes Berg
Quoted 8 lines · Gabriele Gristina

I have a problem with mac80211 injection:
if i setup interface in monitor mode with iwconfig and i try to send a custum 802.11 frame i see twice the packet in monitor interface. The first packet is right, the second is different only in the radiotap
header: rtap len is fixed to 13 bytes...
If i setup interface with airmon-ng the packet is sended once but the radiotap header is fixed to 13 bytes.

Quoted 3 lines

This is correct. The patch is wrong.

I'm very stupid, could you please elaborate how seeing every single packets twice with different headers is "correct"?

Thanks,
Rick

Quoted 2 lines

johannes

#5 lore raw
Quoted 12 lines · Richard Farina
Quoted 11 lines · Johannes Berg
Quoted 8 lines · Gabriele Gristina

I have a problem with mac80211 injection:
if i setup interface in monitor mode with iwconfig and i try to send a custum 802.11 frame i see twice the packet in monitor interface. The first packet is right, the second is different only in the radiotap
header: rtap len is fixed to 13 bytes...
If i setup interface with airmon-ng the packet is sended once but the radiotap header is fixed to 13 bytes.

Quoted 5 lines
Quoted 3 lines

This is correct. The patch is wrong.

I'm very stupid, could you please elaborate how seeing every single packets twice with different headers is "correct"?

Look at the patch. I'ts the injection itself + tx status.

johannes