Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2c706002 authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville
Browse files

don't use net/ieee80211.h



Convert all the drivers using net/ieee80211.h to use linux/ieee80211.h.
Contains a bugfix in libertas where the SSID parsing could overrun the
buffer when the AP sends invalid information.

Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Acked-by: Dan Williams <dcbw@redhat.com> [airo, libertas]
Acked-by: Pavel Roskin <proski@gnu.org> [orinoco]
Acked-by: David Kilroy <kilroyd@googlemail.com> [orinoco]
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 9b1fbae4
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -30,10 +30,11 @@
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/wireless.h>
#include <linux/ieee80211.h>
#include <linux/if_arp.h>
#include <linux/ctype.h>
#include <linux/string.h>
#include <net/iw_handler.h>
#include <net/ieee80211.h>

#include <linux/dma-mapping.h>
#include <net/checksum.h>
@@ -449,9 +450,9 @@ static size_t gelic_wl_synthesize_ie(u8 *buf,

	/* element id */
	if (rsn)
		*buf++ = MFIE_TYPE_RSN;
		*buf++ = WLAN_EID_RSN;
	else
		*buf++ = MFIE_TYPE_GENERIC;
		*buf++ = WLAN_EID_GENERIC;

	/* length filed; set later */
	buf++;
@@ -539,7 +540,7 @@ static void gelic_wl_parse_ie(u8 *data, size_t len,
			break;

		switch (item_id) {
		case MFIE_TYPE_GENERIC:
		case WLAN_EID_GENERIC:
			if ((OUI_LEN + 1 <= item_len) &&
			    !memcmp(pos, wpa_oui, OUI_LEN) &&
			    pos[OUI_LEN] == 0x01) {
@@ -547,7 +548,7 @@ static void gelic_wl_parse_ie(u8 *data, size_t len,
				ie_info->wpa.len = item_len + 2;
			}
			break;
		case MFIE_TYPE_RSN:
		case WLAN_EID_RSN:
			ie_info->rsn.data = pos - 2;
			/* length includes the header */
			ie_info->rsn.len = item_len + 2;
@@ -581,7 +582,7 @@ static char *gelic_wl_translate_scan(struct net_device *netdev,
	char *tmp;
	u8 rate;
	unsigned int i, j, len;
	u8 buf[MAX_WPA_IE_LEN];
	u8 buf[64]; /* arbitrary size large enough */

	pr_debug("%s: <-\n", __func__);

@@ -1734,14 +1735,14 @@ static void gelic_wl_scan_complete_event(struct gelic_wl_info *wl)
		target->essid_len = strnlen(scan_info->essid,
					    sizeof(scan_info->essid));
		target->rate_len = 0;
		for (r = 0; r < MAX_RATES_LENGTH; r++)
		for (r = 0; r < 12; r++)
			if (scan_info->rate[r])
				target->rate_len++;
		if (8 < target->rate_len)
			pr_info("%s: AP returns %d rates\n", __func__,
				target->rate_len);
		target->rate_ext_len = 0;
		for (r = 0; r < MAX_RATES_EX_LENGTH; r++)
		for (r = 0; r < 16; r++)
			if (scan_info->ext_rate[r])
				target->rate_ext_len++;
		list_move_tail(&target->list, &wl->network_list);
+2 −2
Original line number Diff line number Diff line
@@ -164,8 +164,8 @@ struct gelic_eurus_scan_info {
	__be16 security;
	u8  bssid[8]; /* last ETH_ALEN are valid. bssid[0],[1] are unused */
	u8  essid[32]; /* IW_ESSID_MAX_SIZE */
	u8  rate[16]; /* first MAX_RATES_LENGTH(12) are valid */
	u8  ext_rate[16]; /* first MAX_RATES_EX_LENGTH(16) are valid */
	u8  rate[16]; /* first 12 are valid */
	u8  ext_rate[16]; /* first 16 are valid */
	__be32 reserved1;
	__be32 reserved2;
	__be32 reserved3;
+24 −26
Original line number Diff line number Diff line
@@ -47,10 +47,11 @@
#include <linux/ioport.h>
#include <linux/pci.h>
#include <asm/uaccess.h>
#include <net/ieee80211.h>
#include <linux/kthread.h>
#include <linux/freezer.h>

#include <linux/ieee80211.h>

#include "airo.h"

#define DRV_NAME "airo"
@@ -7265,56 +7266,53 @@ static inline char *airo_translate_scan(struct net_device *dev,
	if (test_bit(FLAG_WPA_CAPABLE, &ai->flags)) {
		unsigned int num_null_ies = 0;
		u16 length = sizeof (bss->extra.iep);
		struct ieee80211_info_element *info_element =
			(struct ieee80211_info_element *) &bss->extra.iep;
		u8 *ie = (void *)&bss->extra.iep;

		while ((length >= sizeof(*info_element)) && (num_null_ies < 2)) {
			if (sizeof(*info_element) + info_element->len > length) {
		while ((length >= 2) && (num_null_ies < 2)) {
			if (2 + ie[1] > length) {
				/* Invalid element, don't continue parsing IE */
				break;
			}

			switch (info_element->id) {
			case MFIE_TYPE_SSID:
			switch (ie[0]) {
			case WLAN_EID_SSID:
				/* Two zero-length SSID elements
				 * mean we're done parsing elements */
				if (!info_element->len)
				if (!ie[1])
					num_null_ies++;
				break;

			case MFIE_TYPE_GENERIC:
				if (info_element->len >= 4 &&
				    info_element->data[0] == 0x00 &&
				    info_element->data[1] == 0x50 &&
				    info_element->data[2] == 0xf2 &&
				    info_element->data[3] == 0x01) {
			case WLAN_EID_GENERIC:
				if (ie[1] >= 4 &&
				    ie[2] == 0x00 &&
				    ie[3] == 0x50 &&
				    ie[4] == 0xf2 &&
				    ie[5] == 0x01) {
					iwe.cmd = IWEVGENIE;
					iwe.u.data.length = min(info_element->len + 2,
								  MAX_WPA_IE_LEN);
					/* 64 is an arbitrary cut-off */
					iwe.u.data.length = min(ie[1] + 2,
								64);
					current_ev = iwe_stream_add_point(
							info, current_ev,
							end_buf, &iwe,
							(char *) info_element);
							end_buf, &iwe, ie);
				}
				break;

			case MFIE_TYPE_RSN:
			case WLAN_EID_RSN:
				iwe.cmd = IWEVGENIE;
				iwe.u.data.length = min(info_element->len + 2,
							  MAX_WPA_IE_LEN);
				/* 64 is an arbitrary cut-off */
				iwe.u.data.length = min(ie[1] + 2, 64);
				current_ev = iwe_stream_add_point(
					info, current_ev, end_buf,
					&iwe, (char *) info_element);
					&iwe, ie);
				break;

			default:
				break;
			}

			length -= sizeof(*info_element) + info_element->len;
			info_element =
			    (struct ieee80211_info_element *)&info_element->
			    data[info_element->len];
			length -= 2 + ie[1];
			ie += 2 + ie[1];
		}
	}
	return current_ev;
+35 −35
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@
#include <linux/moduleparam.h>
#include <linux/firmware.h>
#include <linux/jiffies.h>
#include <net/ieee80211.h>
#include <linux/ieee80211.h>
#include "atmel.h"

#define DRIVER_MAJOR 0
@@ -569,7 +569,7 @@ static void atmel_wmem32(struct atmel_private *priv, u16 pos, u32 data);
static void atmel_command_irq(struct atmel_private *priv);
static int atmel_validate_channel(struct atmel_private *priv, int channel);
static void atmel_management_frame(struct atmel_private *priv,
				   struct ieee80211_hdr_4addr *header,
				   struct ieee80211_hdr *header,
				   u16 frame_len, u8 rssi);
static void atmel_management_timer(u_long a);
static void atmel_send_command(struct atmel_private *priv, int command,
@@ -577,7 +577,7 @@ static void atmel_send_command(struct atmel_private *priv, int command,
static int atmel_send_command_wait(struct atmel_private *priv, int command,
				   void *cmd, int cmd_size);
static void atmel_transmit_management_frame(struct atmel_private *priv,
					    struct ieee80211_hdr_4addr *header,
					    struct ieee80211_hdr *header,
					    u8 *body, int body_len);

static u8 atmel_get_mib8(struct atmel_private *priv, u8 type, u8 index);
@@ -785,7 +785,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
{
	static const u8 SNAP_RFC1024[6] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
	struct atmel_private *priv = netdev_priv(dev);
	struct ieee80211_hdr_4addr header;
	struct ieee80211_hdr header;
	unsigned long flags;
	u16 buff, frame_ctl, len = (ETH_ZLEN < skb->len) ? skb->len : ETH_ZLEN;

@@ -823,7 +823,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)

	frame_ctl = IEEE80211_FTYPE_DATA;
	header.duration_id = 0;
	header.seq_ctl = 0;
	header.seq_ctrl = 0;
	if (priv->wep_is_on)
		frame_ctl |= IEEE80211_FCTL_PROTECTED;
	if (priv->operating_mode == IW_MODE_ADHOC) {
@@ -840,7 +840,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
	if (priv->use_wpa)
		memcpy(&header.addr4, SNAP_RFC1024, 6);

	header.frame_ctl = cpu_to_le16(frame_ctl);
	header.frame_control = cpu_to_le16(frame_ctl);
	/* Copy the wireless header into the card */
	atmel_copy_to_card(dev, buff, (unsigned char *)&header, DATA_FRAME_WS_HEADER_SIZE);
	/* Copy the packet sans its 802.3 header addresses which have been replaced */
@@ -860,7 +860,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev)
}

static void atmel_transmit_management_frame(struct atmel_private *priv,
					    struct ieee80211_hdr_4addr *header,
					    struct ieee80211_hdr *header,
					    u8 *body, int body_len)
{
	u16 buff;
@@ -876,7 +876,7 @@ static void atmel_transmit_management_frame(struct atmel_private *priv,
}

static void fast_rx_path(struct atmel_private *priv,
			 struct ieee80211_hdr_4addr *header,
			 struct ieee80211_hdr *header,
			 u16 msdu_size, u16 rx_packet_loc, u32 crc)
{
	/* fast path: unfragmented packet copy directly into skbuf */
@@ -914,7 +914,7 @@ static void fast_rx_path(struct atmel_private *priv,
	}

	memcpy(skbp, header->addr1, 6); /* destination address */
	if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS)
	if (le16_to_cpu(header->frame_control) & IEEE80211_FCTL_FROMDS)
		memcpy(&skbp[6], header->addr3, 6);
	else
		memcpy(&skbp[6], header->addr2, 6); /* source address */
@@ -949,7 +949,7 @@ static int probe_crc(struct atmel_private *priv, u16 packet_loc, u16 msdu_size)
}

static void frag_rx_path(struct atmel_private *priv,
			 struct ieee80211_hdr_4addr *header,
			 struct ieee80211_hdr *header,
			 u16 msdu_size, u16 rx_packet_loc, u32 crc, u16 seq_no,
			 u8 frag_no, int more_frags)
{
@@ -957,7 +957,7 @@ static void frag_rx_path(struct atmel_private *priv,
	u8 source[6];
	struct sk_buff *skb;

	if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS)
	if (le16_to_cpu(header->frame_control) & IEEE80211_FCTL_FROMDS)
		memcpy(source, header->addr3, 6);
	else
		memcpy(source, header->addr2, 6);
@@ -1039,7 +1039,7 @@ static void frag_rx_path(struct atmel_private *priv,
static void rx_done_irq(struct atmel_private *priv)
{
	int i;
	struct ieee80211_hdr_4addr header;
	struct ieee80211_hdr header;

	for (i = 0;
	     atmel_rmem8(priv, atmel_rx(priv, RX_DESC_FLAGS_OFFSET, priv->rx_desc_head)) == RX_DESC_FLAG_VALID &&
@@ -1066,10 +1066,10 @@ static void rx_done_irq(struct atmel_private *priv)
			goto next;
		}

		/* Get header as far as end of seq_ctl */
		/* Get header as far as end of seq_ctrl */
		atmel_copy_to_host(priv->dev, (char *)&header, rx_packet_loc, 24);
		frame_ctl = le16_to_cpu(header.frame_ctl);
		seq_control = le16_to_cpu(header.seq_ctl);
		frame_ctl = le16_to_cpu(header.frame_control);
		seq_control = le16_to_cpu(header.seq_ctrl);

		/* probe for CRC use here if needed  once five packets have
		   arrived with the same crc status, we assume we know what's
@@ -1819,7 +1819,7 @@ static int atmel_set_encodeext(struct net_device *dev,
	/* Determine and validate the key index */
	idx = encoding->flags & IW_ENCODE_INDEX;
	if (idx) {
		if (idx < 1 || idx > WEP_KEYS)
		if (idx < 1 || idx > 4)
			return -EINVAL;
		idx--;
	} else
@@ -1882,7 +1882,7 @@ static int atmel_get_encodeext(struct net_device *dev,

	idx = encoding->flags & IW_ENCODE_INDEX;
	if (idx) {
		if (idx < 1 || idx > WEP_KEYS)
		if (idx < 1 || idx > 4)
			return -EINVAL;
		idx--;
	} else
@@ -2797,7 +2797,7 @@ static void handle_beacon_probe(struct atmel_private *priv, u16 capability,
				u8 channel)
{
	int rejoin = 0;
	int new = capability & MFIE_TYPE_POWER_CONSTRAINT ?
	int new = capability & WLAN_CAPABILITY_SHORT_PREAMBLE ?
		SHORT_PREAMBLE : LONG_PREAMBLE;

	if (priv->preamble != new) {
@@ -2826,19 +2826,19 @@ static void handle_beacon_probe(struct atmel_private *priv, u16 capability,
static void send_authentication_request(struct atmel_private *priv, u16 system,
					u8 *challenge, int challenge_len)
{
	struct ieee80211_hdr_4addr header;
	struct ieee80211_hdr header;
	struct auth_body auth;

	header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
	header.frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_AUTH);
	header.duration_id = cpu_to_le16(0x8000);
	header.seq_ctl = 0;
	header.seq_ctrl = 0;
	memcpy(header.addr1, priv->CurrentBSSID, 6);
	memcpy(header.addr2, priv->dev->dev_addr, 6);
	memcpy(header.addr3, priv->CurrentBSSID, 6);

	if (priv->wep_is_on && priv->CurrentAuthentTransactionSeqNum != 1)
		/* no WEP for authentication frames with TrSeqNo 1 */
                header.frame_ctl |=  cpu_to_le16(IEEE80211_FCTL_PROTECTED);
                header.frame_control |=  cpu_to_le16(IEEE80211_FCTL_PROTECTED);

	auth.alg = cpu_to_le16(system);

@@ -2861,7 +2861,7 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
{
	u8 *ssid_el_p;
	int bodysize;
	struct ieee80211_hdr_4addr header;
	struct ieee80211_hdr header;
	struct ass_req_format {
		__le16 capability;
		__le16 listen_interval;
@@ -2874,10 +2874,10 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
		u8 rates[4];
	} body;

	header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT |
	header.frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
		(is_reassoc ? IEEE80211_STYPE_REASSOC_REQ : IEEE80211_STYPE_ASSOC_REQ));
	header.duration_id = cpu_to_le16(0x8000);
	header.seq_ctl = 0;
	header.seq_ctrl = 0;

	memcpy(header.addr1, priv->CurrentBSSID, 6);
	memcpy(header.addr2, priv->dev->dev_addr, 6);
@@ -2887,7 +2887,7 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
	if (priv->wep_is_on)
		body.capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY);
	if (priv->preamble == SHORT_PREAMBLE)
		body.capability |= cpu_to_le16(MFIE_TYPE_POWER_CONSTRAINT);
		body.capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE);

	body.listen_interval = cpu_to_le16(priv->listen_interval * priv->beacon_period);

@@ -2901,10 +2901,10 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
		bodysize = 12 + priv->SSID_size;
	}

	ssid_el_p[0] = MFIE_TYPE_SSID;
	ssid_el_p[0] = WLAN_EID_SSID;
	ssid_el_p[1] = priv->SSID_size;
	memcpy(ssid_el_p + 2, priv->SSID, priv->SSID_size);
	ssid_el_p[2 + priv->SSID_size] = MFIE_TYPE_RATES;
	ssid_el_p[2 + priv->SSID_size] = WLAN_EID_SUPP_RATES;
	ssid_el_p[3 + priv->SSID_size] = 4; /* len of suported rates */
	memcpy(ssid_el_p + 4 + priv->SSID_size, atmel_basic_rates, 4);

@@ -2912,9 +2912,9 @@ static void send_association_request(struct atmel_private *priv, int is_reassoc)
}

static int is_frame_from_current_bss(struct atmel_private *priv,
				     struct ieee80211_hdr_4addr *header)
				     struct ieee80211_hdr *header)
{
	if (le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_FROMDS)
	if (le16_to_cpu(header->frame_control) & IEEE80211_FCTL_FROMDS)
		return memcmp(header->addr3, priv->CurrentBSSID, 6) == 0;
	else
		return memcmp(header->addr2, priv->CurrentBSSID, 6) == 0;
@@ -2962,7 +2962,7 @@ static int retrieve_bss(struct atmel_private *priv)
}

static void store_bss_info(struct atmel_private *priv,
			   struct ieee80211_hdr_4addr *header, u16 capability,
			   struct ieee80211_hdr *header, u16 capability,
			   u16 beacon_period, u8 channel, u8 rssi, u8 ssid_len,
			   u8 *ssid, int is_beacon)
{
@@ -3001,7 +3001,7 @@ static void store_bss_info(struct atmel_private *priv,
	else if (capability & WLAN_CAPABILITY_ESS)
		priv->BSSinfo[index].BSStype =IW_MODE_INFRA;

	priv->BSSinfo[index].preamble = capability & MFIE_TYPE_POWER_CONSTRAINT ?
	priv->BSSinfo[index].preamble = capability & WLAN_CAPABILITY_SHORT_PREAMBLE ?
		SHORT_PREAMBLE : LONG_PREAMBLE;
}

@@ -3037,7 +3037,7 @@ static void authenticate(struct atmel_private *priv, u16 frame_len)
			}
		} else if (system == WLAN_AUTH_SHARED_KEY) {
			if (trans_seq_no == 0x0002 &&
			    auth->el_id == MFIE_TYPE_CHALLENGE) {
			    auth->el_id == WLAN_EID_CHALLENGE) {
				send_authentication_request(priv, system, auth->chall_text, auth->chall_text_len);
				return;
			} else if (trans_seq_no == 0x0004) {
@@ -3288,12 +3288,12 @@ static void atmel_smooth_qual(struct atmel_private *priv)

/* deals with incoming managment frames. */
static void atmel_management_frame(struct atmel_private *priv,
				   struct ieee80211_hdr_4addr *header,
				   struct ieee80211_hdr *header,
				   u16 frame_len, u8 rssi)
{
	u16 subtype;

	subtype = le16_to_cpu(header->frame_ctl) & IEEE80211_FCTL_STYPE;
	subtype = le16_to_cpu(header->frame_control) & IEEE80211_FCTL_STYPE;
	switch (subtype) {
	case IEEE80211_STYPE_BEACON:
	case IEEE80211_STYPE_PROBE_RESP:
+10 −8
Original line number Diff line number Diff line
@@ -2,6 +2,8 @@

#include <linux/types.h>
#include <linux/etherdevice.h>
#include <linux/ieee80211.h>
#include <linux/if_arp.h>
#include <net/lib80211.h>

#include "assoc.h"
@@ -341,12 +343,12 @@ static int lbs_adhoc_start(struct lbs_private *priv,
	WARN_ON(!assoc_req->channel);

	/* set Physical parameter set */
	cmd.phyparamset.dsparamset.elementid = MFIE_TYPE_DS_SET;
	cmd.phyparamset.dsparamset.elementid = WLAN_EID_DS_PARAMS;
	cmd.phyparamset.dsparamset.len = 1;
	cmd.phyparamset.dsparamset.currentchan = assoc_req->channel;

	/* set IBSS parameter set */
	cmd.ssparamset.ibssparamset.elementid = MFIE_TYPE_IBSS_SET;
	cmd.ssparamset.ibssparamset.elementid = WLAN_EID_IBSS_PARAMS;
	cmd.ssparamset.ibssparamset.len = 2;
	cmd.ssparamset.ibssparamset.atimwindow = 0;

@@ -430,8 +432,8 @@ static inline int match_bss_no_security(struct lbs_802_11_security *secinfo,
{
	if (!secinfo->wep_enabled  && !secinfo->WPAenabled
	    && !secinfo->WPA2enabled
	    && match_bss->wpa_ie[0] != MFIE_TYPE_GENERIC
	    && match_bss->rsn_ie[0] != MFIE_TYPE_RSN
	    && match_bss->wpa_ie[0] != WLAN_EID_GENERIC
	    && match_bss->rsn_ie[0] != WLAN_EID_RSN
	    && !(match_bss->capability & WLAN_CAPABILITY_PRIVACY))
		return 1;
	else
@@ -453,7 +455,7 @@ static inline int match_bss_wpa(struct lbs_802_11_security *secinfo,
				struct bss_descriptor *match_bss)
{
	if (!secinfo->wep_enabled && secinfo->WPAenabled
	    && (match_bss->wpa_ie[0] == MFIE_TYPE_GENERIC)
	    && (match_bss->wpa_ie[0] == WLAN_EID_GENERIC)
	    /* privacy bit may NOT be set in some APs like LinkSys WRT54G
	    && (match_bss->capability & WLAN_CAPABILITY_PRIVACY) */
	   )
@@ -466,7 +468,7 @@ static inline int match_bss_wpa2(struct lbs_802_11_security *secinfo,
				 struct bss_descriptor *match_bss)
{
	if (!secinfo->wep_enabled && secinfo->WPA2enabled &&
	    (match_bss->rsn_ie[0] == MFIE_TYPE_RSN)
	    (match_bss->rsn_ie[0] == WLAN_EID_RSN)
	    /* privacy bit may NOT be set in some APs like LinkSys WRT54G
	    (match_bss->capability & WLAN_CAPABILITY_PRIVACY) */
	   )
@@ -480,8 +482,8 @@ static inline int match_bss_dynamic_wep(struct lbs_802_11_security *secinfo,
{
	if (!secinfo->wep_enabled && !secinfo->WPAenabled
	    && !secinfo->WPA2enabled
	    && (match_bss->wpa_ie[0] != MFIE_TYPE_GENERIC)
	    && (match_bss->rsn_ie[0] != MFIE_TYPE_RSN)
	    && (match_bss->wpa_ie[0] != WLAN_EID_GENERIC)
	    && (match_bss->rsn_ie[0] != WLAN_EID_RSN)
	    && (match_bss->capability & WLAN_CAPABILITY_PRIVACY))
		return 1;
	else
Loading