Skip to contentSkip to conversation

staging/wlan-ng: apply changes from wlan-ng-devel that get the driver working

PATCH Applied Richard Kennedy 4 participants 13 messages Nov 3, 2008 – Nov 12, 2008 Staging

lore
Share & tools
lore
#0 lore raw

cover staging/wlan-ng: apply changes from wlan-ng-devel that get the driver working

These changes from wlan-ng-devel get the card in my laptop working. All the patches are needed to get it fully working. Patches are against 2.6.28-rc2 + latest wlan-ng cleanup-patches

My laptop can now connected to wep enable access point under the control of NetworkManager

Regards
Richard

Richard Kennedy (8):
p80211netdev.c fix netdev alloc to prevent oops on device start prism2_usb.c always enable the card in probe_usb hfa384x_usb.c use newest version of 384x_drvr_start p80211netdev.c correctly enable wext handlers
p80211wext.c add latest changes & remove extra nulls from wext_handlers p80211wext.c don't set default key id twice
hfa384x_usb.c hfa384x_usbin_callback: check for hardware removed p80211conv.c copy code from wlan-ng-devel branch to not drop packets

 drivers/staging/wlan-ng/hfa384x_usb.c  |   70 +++++++++++++++++++++++++------
 drivers/staging/wlan-ng/p80211conv.c   |   49 ++++++++++++++++++++++-
 drivers/staging/wlan-ng/p80211netdev.c |   18 ++------
 drivers/staging/wlan-ng/p80211wext.c   |   44 +++++++++++---------
 drivers/staging/wlan-ng/prism2_usb.c   |   14 ++++--
 5 files changed, 142 insertions(+), 53 deletions(-)
#1 lore raw

PATCH 1/8 p80211netdev.c fix netdev alloc to prevent oops on device start

a version of this patch is in the wlan-ng_devel tree

initializes netdev correctly to prevent an oops on device start.

---
 drivers/staging/wlan-ng/p80211netdev.c |   16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)
drivers/staging/wlan-ng/p80211netdev.c +4 -12
index d229780..cc9cd4c 100644
@@ -845,13 +845,11 @@ int wlan_setup(wlandevice_t *wlandev)
 		     (unsigned long)wlandev);
 
 	/* Allocate and initialize the struct device */
-	dev = kmalloc(sizeof(netdevice_t), GFP_ATOMIC);
+	dev = alloc_netdev(0,"wlan%d",ether_setup);
 	if ( dev == NULL ) {
 		WLAN_LOG_ERROR("Failed to alloc netdev.\n");
 		result = 1;
 	} else {
-		memset( dev, 0, sizeof(netdevice_t));
-		ether_setup(dev);
 		wlandev->netdev = dev;
 		dev->priv = wlandev;
 		dev->hard_start_xmit =	p80211knetdev_hard_start_xmit;
@@ -960,15 +958,9 @@ int register_wlandev(wlandevice_t *wlandev)
 
 	DBFENTER;
 
-	i = dev_alloc_name(wlandev->netdev, "wlan%d");
-	if (i >= 0) {
-		i = register_netdev(wlandev->netdev);
-	}
-	if (i != 0) {
-		return -EIO;
-	}
-
-	strcpy(wlandev->name, dev->name);
+	i = register_netdev(wlandev->netdev);
+	if (i)
+		return i;
 
 	DBFEXIT;
 	return 0;
Signature · 1 line
1.5.6.5
#2 lore raw

PATCH 2/8 prism2_usb.c always enable the card in probe_usb

In reply to Richard Kennedy

always enable card in probe_usb
& update register_wlandev to match latest wlan-ng-dev tree.

---
 drivers/staging/wlan-ng/prism2_usb.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
drivers/staging/wlan-ng/prism2_usb.c +9 -5
index f1ae371..34a36c1 100644
@@ -110,11 +110,6 @@ static int prism2sta_probe_usb(
 	 * linux netdevice.
 	 */
 	SET_NETDEV_DEV(wlandev->netdev, &(interface->dev));
-        if ( register_wlandev(wlandev) != 0 ) {
-		WLAN_LOG_ERROR("%s: register_wlandev() failed.\n", dev_info);
-		result = -EIO;
-		goto failed;
-        }
 
 	/* Do a chip-level reset on the MAC */
 	if (prism2_doreset) {
@@ -138,6 +133,15 @@ static int prism2sta_probe_usb(
 
 	wlandev->msdstate = WLAN_MSD_HWPRESENT;
 
+        if ( register_wlandev(wlandev) != 0 ) {
+		WLAN_LOG_ERROR("%s: register_wlandev() failed.\n", dev_info);
+		result = -EIO;
+		goto failed;
+        }
+
+/* enable the card */
+	prism2sta_ifstate(wlandev, P80211ENUM_ifstate_enable);
+
 	goto done;
 
  failed:
Signature · 1 line
1.5.6.5
#3 lore raw

Re: [PATCH 2/8] prism2_usb.c always enable the card in probe_usb

Am Montag, 3. November 2008 12:13:48 schrieb Richard Kennedy:

Quoted 2 lines

always enable card in probe_usb
& update register_wlandev to match latest wlan-ng-dev tree.

This breaks both error cases.

Quoted 10 lines
---
 drivers/staging/wlan-ng/prism2_usb.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
drivers/staging/wlan-ng/prism2_usb.c +0 -0
index f1ae371..34a36c1 100644
@@ -110,11 +110,6 @@ static int prism2sta_probe_usb(
 	 * linux netdevice.

drivers/staging/wlan-ng/prism2_usb.c static int prism2sta_probe_usb( · line 115

Quoted 10 lines
drivers/staging/wlan-ng/prism2_usb.c +0 -5
 	 */
 	SET_NETDEV_DEV(wlandev->netdev, &(interface->dev));
-        if ( register_wlandev(wlandev) != 0 ) {
-		WLAN_LOG_ERROR("%s: register_wlandev() failed.\n", dev_info);
-		result = -EIO;
-		goto failed;
-        }
 
 	/* Do a chip-level reset on the MAC */
 	if (prism2_doreset) {
	/* Do a chip-level reset on the MAC */
	if (prism2_doreset) {
		result = hfa384x_corereset(hw,
				prism2_reset_holdtime,
				prism2_reset_settletime, 0);
		if (result != 0) {
			unregister_wlandev(wlandev);

You must remove the unregister_wlandev here.

drivers/staging/wlan-ng/prism2_usb.c static int prism2sta_probe_usb( · line 139

Quoted 8 lines
drivers/staging/wlan-ng/prism2_usb.c +4 -0
@@ -138,6 +133,15 @@ static int prism2sta_probe_usb(
 
 	wlandev->msdstate = WLAN_MSD_HWPRESENT;
 
+        if ( register_wlandev(wlandev) != 0 ) {
+		WLAN_LOG_ERROR("%s: register_wlandev() failed.\n", dev_info);
+		result = -EIO;
+		goto failed;

"failed" fails to undo usb_get_dev() which it must do if you jump there from this late.

Regards
Oliver

#4 lore raw

Re: [PATCH 2/8] prism2_usb.c always enable the card in probe_usb

Quoted 48 lines · Oliver Neukum

Am Montag, 3. November 2008 12:13:48 schrieb Richard Kennedy:

Quoted 2 lines

always enable card in probe_usb
& update register_wlandev to match latest wlan-ng-dev tree.

This breaks both error cases.

Quoted 10 lines
---
 drivers/staging/wlan-ng/prism2_usb.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
drivers/staging/wlan-ng/prism2_usb.c +0 -0
index f1ae371..34a36c1 100644
@@ -110,11 +110,6 @@ static int prism2sta_probe_usb(
 	 * linux netdevice.

drivers/staging/wlan-ng/prism2_usb.c static int prism2sta_probe_usb( · line 115

Quoted 10 lines
drivers/staging/wlan-ng/prism2_usb.c +0 -5
 	 */
 	SET_NETDEV_DEV(wlandev->netdev, &(interface->dev));
-        if ( register_wlandev(wlandev) != 0 ) {
-		WLAN_LOG_ERROR("%s: register_wlandev() failed.\n", dev_info);
-		result = -EIO;
-		goto failed;
-        }
 
 	/* Do a chip-level reset on the MAC */
 	if (prism2_doreset) {
	/* Do a chip-level reset on the MAC */
	if (prism2_doreset) {
		result = hfa384x_corereset(hw,
				prism2_reset_holdtime,
				prism2_reset_settletime, 0);
		if (result != 0) {
			unregister_wlandev(wlandev);

You must remove the unregister_wlandev here.

drivers/staging/wlan-ng/prism2_usb.c static int prism2sta_probe_usb( · line 139

Quoted 8 lines
drivers/staging/wlan-ng/prism2_usb.c +4 -0
@@ -138,6 +133,15 @@ static int prism2sta_probe_usb(
 
 	wlandev->msdstate = WLAN_MSD_HWPRESENT;
 
+        if ( register_wlandev(wlandev) != 0 ) {
+		WLAN_LOG_ERROR("%s: register_wlandev() failed.\n", dev_info);
+		result = -EIO;
+		goto failed;

"failed" fails to undo usb_get_dev() which it must do if you jump there from this late.

Quoted 2 lines

Regards
Oliver

Oliver,
thanks for that, I will tidy it up & post a patch.

prism2_doreset is 0 by default, so that hunk of code will not usually get called. hfa384x_corereset doesn't do much on usb, and holdtime & settletime aren't used at all. So more targets for clean up I guess :)

regards
Richard

#5 lore raw

PATCH 3/8 hfa384x_usb.c use newest version of 384x_drvr_start

In reply to Richard Kennedy

include the needed fixes from Karl Relton
<[email protected]>

see thread on linux-wlan-devel mailing list
"Possible cause of those pesky hfa384x_usbctlx_complete_sync errors"

---
 drivers/staging/wlan-ng/hfa384x_usb.c |   68 ++++++++++++++++++++++++++------
 1 files changed, 55 insertions(+), 13 deletions(-)
drivers/staging/wlan-ng/hfa384x_usb.c +55 -13
index 53c547d..4b1d24e 100644
@@ -3140,19 +3140,38 @@ int hfa384x_drvr_setconfig(hfa384x_t *hw, UINT16 rid, void *buf, UINT16 len)
 * Call context:
 *	process
 ----------------------------------------------------------------*/
+
 int hfa384x_drvr_start(hfa384x_t *hw)
 {
-	int		result;
+	int		result, result1, result2;
+	u16		status;
 	DBFENTER;
 
 	might_sleep();
-
-	if (usb_clear_halt(hw->usb, hw->endp_in)) {
+    
+	/* Clear endpoint stalls - but only do this if the endpoint
+	 * is showing a stall status. Some prism2 cards seem to behave
+	 * badly if a clear_halt is called when the endpoint is already
+	 * ok
+	 */
+	result = usb_get_status(hw->usb, USB_RECIP_ENDPOINT, hw->endp_in, &status);
+	if (result < 0) {
+		WLAN_LOG_ERROR(
+			"Cannot get bulk in endpoint status.\n");
+		goto done;
+	}
+	if ((status == 1) && usb_clear_halt(hw->usb, hw->endp_in)) {
 		WLAN_LOG_ERROR(
 			"Failed to reset bulk in endpoint.\n");
 	}
 
-	if (usb_clear_halt(hw->usb, hw->endp_out)) {
+	result = usb_get_status(hw->usb, USB_RECIP_ENDPOINT, hw->endp_out, &status);
+	if (result < 0) {
+		WLAN_LOG_ERROR(
+			"Cannot get bulk out endpoint status.\n");
+		goto done;
+	}
+	if ((status == 1) && usb_clear_halt(hw->usb, hw->endp_out)) {
 		WLAN_LOG_ERROR(
 			"Failed to reset bulk out endpoint.\n");
 	}
@@ -3169,18 +3188,41 @@ int hfa384x_drvr_start(hfa384x_t *hw)
 		goto done;
 	}
 
-	/* call initialize */
-	result = hfa384x_cmd_initialize(hw);
-	if (result != 0) {
-		usb_kill_urb(&hw->rx_urb);
-		WLAN_LOG_ERROR(
-			"cmd_initialize() failed, result=%d\n",
-			result);
-		goto done;
+	/* Call initialize twice, with a 1 second sleep in between.
+	 * This is a nasty work-around since many prism2 cards seem to
+	 * need time to settle after an init from cold. The second
+	 * call to initialize in theory is not necessary - but we call
+	 * it anyway as a double insurance policy:
+	 * 1) If the first init should fail, the second may well succeed
+	 *    and the card can still be used
+	 * 2) It helps ensures all is well with the card after the first
+	 *    init and settle time.
+	 */
+	result1 = hfa384x_cmd_initialize(hw);
+	msleep(1000);
+	result = result2 = hfa384x_cmd_initialize(hw);
+	if (result1 != 0) {
+		if (result2 != 0) {
+			WLAN_LOG_ERROR(
+				"cmd_initialize() failed on two attempts, results %d and %d\n",
+				result1, result2);
+			usb_kill_urb(&hw->rx_urb);
+			goto done;
+		} else {
+			WLAN_LOG_DEBUG(0, "First cmd_initialize() failed (result %d),\n",
+				result1);
+			WLAN_LOG_DEBUG(0, "but second attempt succeeded. All should be ok\n");
+		}
+	} else if (result2 != 0) {
+		WLAN_LOG_WARNING(
+			"First cmd_initialize() succeeded, but second attempt failed (result=%d)\n",
+			result2);
+		WLAN_LOG_WARNING("Most likely the card will be functional\n");
+			goto done;
 	}
 
 	hw->state = HFA384x_STATE_RUNNING;
-
+	
 done:
 	DBFEXIT;
 	return result;
Signature · 1 line
1.5.6.5
#6 lore raw

PATCH 4/8 p80211netdev.c correctly enable wext handlers

In reply to Richard Kennedy

correctly enable wext handlers
CONFIG_NET_WIRELESS does not exist so wext_handlers did not get defined.

---
 drivers/staging/wlan-ng/p80211netdev.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
drivers/staging/wlan-ng/p80211netdev.c +0 -2
index cc9cd4c..17b9321 100644
@@ -864,12 +864,10 @@ int wlan_setup(wlandevice_t *wlandev)
 		dev->open =		p80211knetdev_open;
 		dev->stop =		p80211knetdev_stop;
 
-#ifdef CONFIG_NET_WIRELESS
 #if (WIRELESS_EXT < 21)
 		dev->get_wireless_stats = p80211wext_get_wireless_stats;
 #endif
 		dev->wireless_handlers = &p80211wext_handler_def;
-#endif
 
 		netif_stop_queue(dev);
 #ifdef HAVE_CHANGE_MTU
Signature · 1 line
1.5.6.5
#7 lore raw

Re: [PATCH 4/8] p80211netdev.c correctly enable wext handlers

Quoted 3 lines · Richard Kennedy

correctly enable wext handlers
CONFIG_NET_WIRELESS does not exist so wext_handlers did not get defined.

This patch had already been applied to my tree from someone else.

thanks,

greg k-h

#8 lore raw

PATCH 5/8 p80211wext.c add latest changes & remove extra nulls from wext_handlers

In reply to Richard Kennedy

add the latest changes from wlan-ng-devel
remove 2 stray nulls from the wext_handler table introduced by the tidy up patch.

---
 drivers/staging/wlan-ng/p80211wext.c |   39
++++++++++++++++++++++-----------
 1 files changed, 26 insertions(+), 13 deletions(-)
drivers/staging/wlan-ng/p80211wext.c +26 -13
index 153e5eb..de0789a 100644
@@ -553,10 +553,13 @@ static int p80211wext_giwencode(netdevice_t *dev,
 
 	DBFENTER;
 
+	i = (erq->flags & IW_ENCODE_INDEX) - 1;
+	erq->flags = 0;
+
 	if (wlandev->hostwep & HOSTWEP_PRIVACYINVOKED)
-		erq->flags = IW_ENCODE_ENABLED;
+		erq->flags |= IW_ENCODE_ENABLED;
 	else
-		erq->flags = IW_ENCODE_DISABLED;
+		erq->flags |= IW_ENCODE_DISABLED;
 
 	if (wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED)
 		erq->flags |= IW_ENCODE_RESTRICTED;
@@ -619,17 +622,24 @@ static int p80211wext_siwencode(netdevice_t *dev,
 			err = -EFAULT;
 			goto exit;
 		}
-		else {
-			enable = 1;
+
+		/* Set current key number only if no keys are given */
+		if (erq->flags & IW_ENCODE_NOKEY) {
+			result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, i);
+		
+			if (result) {
+				err = -EFAULT;
+				goto exit;
+			}
 		}
 
-	}
-	else {
-		// Do not thing when no Key Index
+	} else {
+		// Use defaultkey if no Key Index
+		i = wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK;
 	}
 
 	/* Check if there is no key information in the iwconfig request */
-	if((erq->flags & IW_ENCODE_NOKEY) == 0 && enable == 1) {
+	if((erq->flags & IW_ENCODE_NOKEY) == 0 ) {
 
 		/*------------------------------------------------------------
 		 * If there is WEP Key for setting, check the Key Information
@@ -684,8 +694,7 @@ static int p80211wext_siwencode(netdevice_t *dev,
 	/* Check the PrivacyInvoked flag */
 	if (erq->flags & IW_ENCODE_DISABLED) {
 		result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_false);
-	}
-	else if((erq->flags & IW_ENCODE_ENABLED) || enable == 1) {
+	} else {
 		result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11PrivacyInvoked, P80211ENUM_truth_true);
 	}
 
@@ -694,7 +703,13 @@ static int p80211wext_siwencode(netdevice_t *dev,
 		goto exit;
 	}
 
-	/* Check the ExcludeUnencrypted flag */
+	/*  The  security  mode  may  be open or restricted, and its meaning
+	    depends on the card used. With  most  cards,  in  open  mode  no
+	    authentication  is  used  and  the  card  may  also  accept non-
+	    encrypted sessions, whereas in restricted  mode  only  encrypted
+	    sessions  are  accepted  and the card will use authentication if
+	    available. 
+	*/
 	if (erq->flags & IW_ENCODE_RESTRICTED) {
 		result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11ExcludeUnencrypted, P80211ENUM_truth_true);
 	}
@@ -1760,8 +1775,6 @@ static iw_handler p80211wext_handlers[] =  {
 	(iw_handler) NULL,                  		/* SIOCGIWAPLIST */
 	(iw_handler) p80211wext_siwscan,		/* SIOCSIWSCAN */
 	(iw_handler) p80211wext_giwscan,		/* SIOCGIWSCAN */
-	(iw_handler) NULL,	/* null */		/* SIOCSIWSCAN */
-	(iw_handler) NULL,	/* null */		/* SIOCGIWSCAN */
 	(iw_handler) p80211wext_siwessid,  		/* SIOCSIWESSID */
 	(iw_handler) p80211wext_giwessid,      		/* SIOCGIWESSID */
 	(iw_handler) NULL,                 		/* SIOCSIWNICKN */
Signature · 1 line
1.5.6.5
#9 lore raw

PATCH 6/8 p80211wext don't set default key id twice

In reply to Richard Kennedy

p80211wext don't set default key id twice

another change from wlan-ng-devel

---
 drivers/staging/wlan-ng/p80211wext.c |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
drivers/staging/wlan-ng/p80211wext.c +0 -7
index de0789a..28c8359 100644
@@ -616,13 +616,6 @@ static int p80211wext_siwencode(netdevice_t *dev,
 		else
 			i--;
 
-		result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, i);
-
-		if (result) {
-			err = -EFAULT;
-			goto exit;
-		}
-
 		/* Set current key number only if no keys are given */
 		if (erq->flags & IW_ENCODE_NOKEY) {
 			result = p80211wext_dorequest(wlandev, DIDmib_dot11smt_dot11PrivacyTable_dot11WEPDefaultKeyID, i);
Signature · 1 line
1.5.6.5
#10 lore raw

PATCH 7/8 hfa384x_usbin_callback: check for hardware removed

In reply to Richard Kennedy

hfa384x_usbin_callback: check for hardware removed

copied from latest wlan-ng-devel version

---
 drivers/staging/wlan-ng/hfa384x_usb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/wlan-ng/hfa384x_usb.c +1 -1
index 4b1d24e..9184e27 100644
@@ -3788,7 +3788,7 @@ static void hfa384x_usbin_callback(struct urb *urb, struct pt_regs *regs)
 
 	if ( !wlandev ||
 	     !wlandev->netdev ||
-	     !netif_device_present(wlandev->netdev) )
+	     wlandev->hwremoved )
 		goto exit;
 
 	hw = wlandev->priv;
Signature · 1 line
1.5.6.5
#11 lore raw

PATCH 8/8 p80211conv.c copy code from wlan-ng-devel branch to not drop packets

In reply to Richard Kennedy

allow card to correctly receive network packets, without this change all incoming packets are dropped. code copied from the latest wlan-ng-devel tree.

---
 drivers/staging/wlan-ng/p80211conv.c |   49 +++++++++++++++++++++++++++++++++-
 1 files changed, 48 insertions(+), 1 deletions(-)
drivers/staging/wlan-ng/p80211conv.c +48 -1
index 749ea8d..b09a9ab 100644
@@ -380,6 +380,14 @@ int skb_p80211_to_ether( wlandevice_t *wlandev, UINT32 ethconv, struct sk_buff *
 	     (memcmp(saddr, e_hdr->saddr, WLAN_ETHADDR_LEN) == 0))) {
 		WLAN_LOG_DEBUG(3, "802.3 ENCAP len: %d\n", payload_length);
 		/* 802.3 Encapsulated */
+		/* Test for an overlength frame */
+		if ( payload_length > (netdev->mtu + WLAN_ETHHDR_LEN)) {
+			/* A bogus length ethfrm has been encap'd. */
+			/* Is someone trying an oflow attack? */
+			WLAN_LOG_ERROR("ENCAP frame too large (%d > %d)\n",
+				payload_length, netdev->mtu + WLAN_ETHHDR_LEN);
+			return 1;
+		}
 
 		/* Chop off the 802.11 header.  it's already sane. */
 		skb_pull(skb, payload_offset);
@@ -399,6 +407,15 @@ int skb_p80211_to_ether( wlandevice_t *wlandev, UINT32 ethconv, struct sk_buff *
 		/* it's a SNAP + RFC1042 frame && protocol is in STT */
 		/* build 802.3 + RFC1042 */
 
+		/* Test for an overlength frame */
+		if ( payload_length > netdev->mtu ) {
+			/* A bogus length ethfrm has been sent. */
+			/* Is someone trying an oflow attack? */
+			WLAN_LOG_ERROR("SNAP frame too large (%d > %d)\n",
+				payload_length, netdev->mtu);
+			return 1;
+		}
+
 		/* chop 802.11 header from skb. */
 		skb_pull(skb, payload_offset);
 
@@ -419,6 +436,18 @@ int skb_p80211_to_ether( wlandevice_t *wlandev, UINT32 ethconv, struct sk_buff *
 		/* it's an 802.1h frame || (an RFC1042 && protocol is not in STT) */
 		/* build a DIXII + RFC894 */
 
+		/* Test for an overlength frame */
+		if ((payload_length - sizeof(wlan_llc_t) - sizeof(wlan_snap_t))
+		    > netdev->mtu) {
+			/* A bogus length ethfrm has been sent. */
+			/* Is someone trying an oflow attack? */
+			WLAN_LOG_ERROR("DIXII frame too large (%ld > %d)\n",
+					(long int) (payload_length - sizeof(wlan_llc_t) -
+						    sizeof(wlan_snap_t)),
+					netdev->mtu);
+			return 1;
+		}
+
 		/* chop 802.11 header from skb. */
 		skb_pull(skb, payload_offset);
 
@@ -443,6 +472,16 @@ int skb_p80211_to_ether( wlandevice_t *wlandev, UINT32 ethconv, struct sk_buff *
 		/*  build an 802.3 frame */
 		/* allocate space and setup hostbuf */
 
+		/* Test for an overlength frame */
+		if ( payload_length > netdev->mtu ) {
+			/* A bogus length ethfrm has been sent. */
+			/* Is someone trying an oflow attack? */
+			WLAN_LOG_ERROR("OTHER frame too large (%d > %d)\n",
+				payload_length,
+				netdev->mtu);
+			return 1;
+		}
+
 		/* Chop off the 802.11 header. */
 		skb_pull(skb, payload_offset);
 
@@ -457,8 +496,16 @@ int skb_p80211_to_ether( wlandevice_t *wlandev, UINT32 ethconv, struct sk_buff *
 
 	}
 
+        /*
+         * Note that eth_type_trans() expects an skb w/ skb->data pointing
+         * at the MAC header, it then sets the following skb members:
+         * skb->mac_header, 
+         * skb->data, and
+         * skb->pkt_type.
+         * It then _returns_ the value that _we're_ supposed to stuff in
+         * skb->protocol.  This is nuts.
+         */
 	skb->protocol = eth_type_trans(skb, netdev);
-	skb_reset_mac_header(skb);
 
         /* jkriegl: process signal and noise as set in hfa384x_int_rx() */
 	/* jkriegl: only process signal/noise if requested by iwspy */
Signature · 1 line
1.5.6.5
#12 lore raw

patch staging-wlan-ng-p80211conv.c-copy-code-from-wlan-ng-devel-branch-to-not-drop-packets.patch added to gregkh-2.6 tree

This is a note to let you know that I've just added the patch titled

Subject: Staging: wlan-ng: p80211conv.c copy code from wlan-ng-devel branch to not drop packets

to my gregkh-2.6 tree. Its filename is

staging-wlan-ng-p80211conv.c-copy-code-from-wlan-ng-devel-branch-to-not-drop-packets.patch

This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/

Quoted 1 line

From [email protected] Wed Nov 12 14:31:45 2008

From: Richard Kennedy <[email protected]>
Date: Mon, 03 Nov 2008 11:24:54 +0000
Subject: Staging: wlan-ng: p80211conv.c copy code from wlan-ng-devel branch to not drop packets
To: gregkh <[email protected]>
Cc: lkml <[email protected]>
Message-ID: <[email protected]>

allow card to correctly receive network packets, without this change all incoming packets are dropped. code copied from the latest wlan-ng-devel tree.

---
 drivers/staging/wlan-ng/p80211conv.c |   49 ++++++++++++++++++++++++++++++++++-
 1 file changed, 48 insertions(+), 1 deletion(-)
drivers/staging/wlan-ng/p80211conv.c +48 -1
@@ -377,6 +377,14 @@ int skb_p80211_to_ether( wlandevice_t *w
 	     (memcmp(saddr, e_hdr->saddr, WLAN_ETHADDR_LEN) == 0))) {
 		WLAN_LOG_DEBUG(3, "802.3 ENCAP len: %d\n", payload_length);
 		/* 802.3 Encapsulated */
+		/* Test for an overlength frame */
+		if ( payload_length > (netdev->mtu + WLAN_ETHHDR_LEN)) {
+			/* A bogus length ethfrm has been encap'd. */
+			/* Is someone trying an oflow attack? */
+			WLAN_LOG_ERROR("ENCAP frame too large (%d > %d)\n",
+				payload_length, netdev->mtu + WLAN_ETHHDR_LEN);
+			return 1;
+		}
 
 		/* Chop off the 802.11 header.  it's already sane. */
 		skb_pull(skb, payload_offset);
@@ -396,6 +404,15 @@ int skb_p80211_to_ether( wlandevice_t *w
 		/* it's a SNAP + RFC1042 frame && protocol is in STT */
 		/* build 802.3 + RFC1042 */
 
+		/* Test for an overlength frame */
+		if ( payload_length > netdev->mtu ) {
+			/* A bogus length ethfrm has been sent. */
+			/* Is someone trying an oflow attack? */
+			WLAN_LOG_ERROR("SNAP frame too large (%d > %d)\n",
+				payload_length, netdev->mtu);
+			return 1;
+		}
+
 		/* chop 802.11 header from skb. */
 		skb_pull(skb, payload_offset);
 
@@ -416,6 +433,18 @@ int skb_p80211_to_ether( wlandevice_t *w
 		/* it's an 802.1h frame || (an RFC1042 && protocol is not in STT) */
 		/* build a DIXII + RFC894 */
 
+		/* Test for an overlength frame */
+		if ((payload_length - sizeof(wlan_llc_t) - sizeof(wlan_snap_t))
+		    > netdev->mtu) {
+			/* A bogus length ethfrm has been sent. */
+			/* Is someone trying an oflow attack? */
+			WLAN_LOG_ERROR("DIXII frame too large (%ld > %d)\n",
+					(long int) (payload_length - sizeof(wlan_llc_t) -
+						    sizeof(wlan_snap_t)),
+					netdev->mtu);
+			return 1;
+		}
+
 		/* chop 802.11 header from skb. */
 		skb_pull(skb, payload_offset);
 
@@ -440,6 +469,16 @@ int skb_p80211_to_ether( wlandevice_t *w
 		/*  build an 802.3 frame */
 		/* allocate space and setup hostbuf */
 
+		/* Test for an overlength frame */
+		if ( payload_length > netdev->mtu ) {
+			/* A bogus length ethfrm has been sent. */
+			/* Is someone trying an oflow attack? */
+			WLAN_LOG_ERROR("OTHER frame too large (%d > %d)\n",
+				payload_length,
+				netdev->mtu);
+			return 1;
+		}
+
 		/* Chop off the 802.11 header. */
 		skb_pull(skb, payload_offset);
 
@@ -454,8 +493,16 @@ int skb_p80211_to_ether( wlandevice_t *w
 
 	}
 
+        /*
+         * Note that eth_type_trans() expects an skb w/ skb->data pointing
+         * at the MAC header, it then sets the following skb members:
+         * skb->mac_header,
+         * skb->data, and
+         * skb->pkt_type.
+         * It then _returns_ the value that _we're_ supposed to stuff in
+         * skb->protocol.  This is nuts.
+         */
 	skb->protocol = eth_type_trans(skb, netdev);
-	skb_reset_mac_header(skb);
 
         /* jkriegl: process signal and noise as set in hfa384x_int_rx() */
 	/* jkriegl: only process signal/noise if requested by iwspy */

Patches currently in gregkh-2.6 which might be from [email protected] are

staging/staging-wlan-ng-hfa384x_usb.c-use-newest-version-of-384x_drvr_start.patch staging/staging-wlan-ng-hfa384x_usbin_callback-check-for-hardware-removed.patch staging/staging-wlan-ng-p80211conv.c-copy-code-from-wlan-ng-devel-branch-to-not-drop-packets.patch staging/staging-wlan-ng-p80211netdev.c-fix-netdev-alloc-to-prevent-oops-on-device-start.patch staging/staging-wlan-ng-p80211wext.c-add-latest-changes-remove-extra-nulls-from-wext_handlers.patch staging/staging-wlan-ng-p80211wext-don-t-set-default-key-id-twice.patch staging/staging-wlan-ng-prism2_usb.c-always-enable-the-card-in-probe_usb.patch