Skip to contentSkip to conversation

mac80211: Fix frame injection using non-AP vif

PATCH In review Jouni Malinen 3 participants 3 messages Nov 26, 2010 – Nov 30, 2010 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac80211: Fix frame injection using non-AP vif

In order for frame injection to work properly for some use cases (e.g., finding the station entry and keys for encryption), mac80211 needs to find the correct sdata entry. This works when the main vif is in AP mode, but commit a2c1e3dad516618cb0fbfb1a62c36d0b0744573a broke this particular use case for station main vif. While this type of injection is quite unusual operation, it has some uses and we should fix it. Do this by changing the monitor vif sdata selection to allow station vif to be selected instead of limiting it to just AP vifs. We still need to skip some iftypes to avoid selecting unsuitable vif for injection.

---
 net/mac80211/tx.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
net/mac80211/tx.c +6 -1
@@ -1595,7 +1595,12 @@ static void ieee80211_xmit(struct ieee80
 						list) {
 				if (!ieee80211_sdata_running(tmp_sdata))
 					continue;
-				if (tmp_sdata->vif.type != NL80211_IFTYPE_AP)
+				if (tmp_sdata->vif.type ==
+				    NL80211_IFTYPE_MONITOR ||
+				    tmp_sdata->vif.type ==
+				    NL80211_IFTYPE_AP_VLAN ||
+					tmp_sdata->vif.type ==
+				    NL80211_IFTYPE_WDS)
 					continue;
 				if (compare_ether_addr(tmp_sdata->vif.addr,
 						       hdr->addr2) == 0) {
Signature · 1 line
Jouni Malinen                                            PGP id EFC895FA
#1 lore raw
Quoted 19 lines · Jouni Malinen

In order for frame injection to work properly for some use cases (e.g., finding the station entry and keys for encryption), mac80211 needs to find the correct sdata entry. This works when the main vif is in AP mode, but commit a2c1e3dad516618cb0fbfb1a62c36d0b0744573a broke this particular use case for station main vif. While this type of injection is quite unusual operation, it has some uses and we should fix it. Do this by changing the monitor vif sdata selection to allow station vif to be selected instead of limiting it to just AP vifs. We still need to skip some iftypes to avoid selecting unsuitable vif for injection.

---
 net/mac80211/tx.c |    7 ++++++-

 1 file changed, 6 insertions(+), 1 deletion(-)

net/mac80211/tx.c  2010-11-26 20:36:22.000000000 +0200 static void ieee80211_xmit(struct ieee80 · line 1599

Quoted 6 lines
net/mac80211/tx.c  2010-11-26 20:36:22.000000000 +0200 renamed from net/mac80211/tx.c     2010-11-26 20:21:02.000000000 +0200 +2 -1
@@ -1595,7 +1595,12 @@ static void ieee80211_xmit(struct ieee80
                                                list) {
                                if (!ieee80211_sdata_running(tmp_sdata))
                                        continue;
-                               if (tmp_sdata->vif.type != NL80211_IFTYPE_AP)
+                               if (tmp_sdata->vif.type ==
+                                   NL80211_IFTYPE_MONITOR ||

Ah, for some reason I thought we were able to push frames as a monitor all along, no wonder packetspammer didn't work, or should it?

Luis

maintainer
#2 lore raw
Quoted 18 lines · Luis R. Rodriguez
Quoted 16 lines · Jouni Malinen

In order for frame injection to work properly for some use cases (e.g., finding the station entry and keys for encryption), mac80211 needs to find the correct sdata entry. This works when the main vif is in AP mode, but commit a2c1e3dad516618cb0fbfb1a62c36d0b0744573a broke this particular use case for station main vif. While this type of injection is quite unusual operation, it has some uses and we should fix it. Do this by changing the monitor vif sdata selection to allow station vif to be selected instead of limiting it to just AP vifs. We still need to skip some iftypes to avoid selecting unsuitable vif for injection.

---
 net/mac80211/tx.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
Quoted 12 lines

net/mac80211/tx.c 2010-11-26 20:36:22.000000000 +0200 static void ieee80211_xmit(struct ieee80 · line 1599

Quoted 9 lines
net/mac80211/tx.c 2010-11-26 20:36:22.000000000 +0200 renamed from net/mac80211/tx.c 2010-11-26 20:21:02.000000000 +0200 +2 -1
@@ -1595,7 +1595,12 @@ static void ieee80211_xmit(struct ieee80
                                               list) {
                               if (!ieee80211_sdata_running(tmp_sdata))
                                       continue;
-                               if (tmp_sdata->vif.type != NL80211_IFTYPE_AP)
+                               if (tmp_sdata->vif.type ==
+                                   NL80211_IFTYPE_MONITOR ||

Ah, for some reason I thought we were able to push frames as a monitor all along, no wonder packetspammer didn't work, or should it?

That'll still work -- it just won't encrypt the frames correctly where necessary for a primary *station* interface.

johannes