From 695b5bc3ecfc7da0a29360a6c2ee0849ffdb300a Mon Sep 17 00:00:00 2001 From: Al Viro Date: Sun, 3 Apr 2005 09:15:52 +0100 Subject: [PATCH 1/6] [PATCH] ieee80211_module.c::store_debug_level() cleanup * trivial __user annotations * store_debug_level() sanitized a bit Signed-off-by: Al Viro --- net/ieee80211/ieee80211_module.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/net/ieee80211/ieee80211_module.c b/net/ieee80211/ieee80211_module.c index e4ca0daaaeea..90bc50b97ea7 100644 --- a/net/ieee80211/ieee80211_module.c +++ b/net/ieee80211/ieee80211_module.c @@ -194,17 +194,23 @@ static int show_debug_level(char *page, char **start, off_t offset, return snprintf(page, count, "0x%08X\n", ieee80211_debug_level); } -static int store_debug_level(struct file *file, const char *buffer, +static int store_debug_level(struct file *file, const char __user *buffer, unsigned long count, void *data) { char buf[] = "0x00000000"; - unsigned long len = min(sizeof(buf) - 1, (u32)count); char *p = (char *)buf; unsigned long val; - if (copy_from_user(buf, buffer, len)) + if (count > sizeof(buf) - 1) + count = sizeof(buf) - 1; + + if (copy_from_user(buf, buffer, count)) return count; - buf[len] = 0; + buf[count] = 0; + /* + * what a FPOS... What, sscanf(buf, "%i", &val) would be too + * scary? + */ if (p[1] == 'x' || p[1] == 'X' || p[0] == 'x' || p[0] == 'X') { p++; if (p[0] == 'x' || p[0] == 'X') @@ -218,7 +224,7 @@ static int store_debug_level(struct file *file, const char *buffer, else ieee80211_debug_level = val; - return strnlen(buf, count); + return strlen(buf); } static int __init ieee80211_init(void) From 3dcefbc9d6bd8b5ff0fc4bdbe3df938be5460f79 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Tue, 26 Apr 2005 18:43:05 +0100 Subject: [PATCH 2/6] [PATCH] zd1201 fixes In netdev-2.6 we need to update zd1201.c since we don't have driver/net/wireless/ieee802_11.h anymore. Signed-off-by: Al Viro --- drivers/usb/net/Makefile | 2 -- drivers/usb/net/zd1201.c | 16 ++++++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/usb/net/Makefile b/drivers/usb/net/Makefile index 16f352195512..fe3fd4115e1e 100644 --- a/drivers/usb/net/Makefile +++ b/drivers/usb/net/Makefile @@ -8,5 +8,3 @@ obj-$(CONFIG_USB_PEGASUS) += pegasus.o obj-$(CONFIG_USB_RTL8150) += rtl8150.o obj-$(CONFIG_USB_USBNET) += usbnet.o obj-$(CONFIG_USB_ZD1201) += zd1201.o - -CFLAGS_zd1201.o = -Idrivers/net/wireless/ diff --git a/drivers/usb/net/zd1201.c b/drivers/usb/net/zd1201.c index 341ae5f732dd..17b9718b8de6 100644 --- a/drivers/usb/net/zd1201.c +++ b/drivers/usb/net/zd1201.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include "zd1201.h" static struct usb_device_id zd1201_table[] = { @@ -337,25 +337,25 @@ static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs) goto resubmit; } - if ((seq & IEEE802_11_SCTL_FRAG) || - (fc & IEEE802_11_FCTL_MOREFRAGS)) { + if ((seq & IEEE80211_SCTL_FRAG) || + (fc & IEEE80211_FCTL_MOREFRAGS)) { struct zd1201_frag *frag = NULL; char *ptr; if (datalen<14) goto resubmit; - if ((seq & IEEE802_11_SCTL_FRAG) == 0) { + if ((seq & IEEE80211_SCTL_FRAG) == 0) { frag = kmalloc(sizeof(struct zd1201_frag*), GFP_ATOMIC); if (!frag) goto resubmit; - skb = dev_alloc_skb(IEEE802_11_DATA_LEN +14+2); + skb = dev_alloc_skb(IEEE80211_DATA_LEN +14+2); if (!skb) { kfree(frag); goto resubmit; } frag->skb = skb; - frag->seq = seq & IEEE802_11_SCTL_SEQ; + frag->seq = seq & IEEE80211_SCTL_SEQ; skb_reserve(skb, 2); memcpy(skb_put(skb, 12), &data[datalen-14], 12); memcpy(skb_put(skb, 2), &data[6], 2); @@ -364,7 +364,7 @@ static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs) goto resubmit; } hlist_for_each_entry(frag, node, &zd->fraglist, fnode) - if(frag->seq == (seq&IEEE802_11_SCTL_SEQ)) + if(frag->seq == (seq&IEEE80211_SCTL_SEQ)) break; if (!frag) goto resubmit; @@ -372,7 +372,7 @@ static void zd1201_usbrx(struct urb *urb, struct pt_regs *regs) ptr = skb_put(skb, len); if (ptr) memcpy(ptr, data+8, len); - if (fc & IEEE802_11_FCTL_MOREFRAGS) + if (fc & IEEE80211_FCTL_MOREFRAGS) goto resubmit; hlist_del_init(&frag->fnode); kfree(frag); From e157249d948bf0c5da10ce8610e2b4b36d0a3c4c Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Fri, 6 May 2005 23:32:39 +0200 Subject: [PATCH 3/6] [PATCH] net/ieee80211/: make two functions static This patch makes two needlessly global functions static. Signed-off-by: Adrian Bunk --- net/ieee80211/ieee80211_crypt_ccmp.c | 4 ++-- net/ieee80211/ieee80211_tx.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net/ieee80211/ieee80211_crypt_ccmp.c b/net/ieee80211/ieee80211_crypt_ccmp.c index f5f412ae7f28..11d15573b26a 100644 --- a/net/ieee80211/ieee80211_crypt_ccmp.c +++ b/net/ieee80211/ieee80211_crypt_ccmp.c @@ -59,8 +59,8 @@ struct ieee80211_ccmp_data { u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, - const u8 pt[16], u8 ct[16]) +static void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, + const u8 pt[16], u8 ct[16]) { struct scatterlist src, dst; diff --git a/net/ieee80211/ieee80211_tx.c b/net/ieee80211/ieee80211_tx.c index 308fcd9ab1e3..a3054c5c0c05 100644 --- a/net/ieee80211/ieee80211_tx.c +++ b/net/ieee80211/ieee80211_tx.c @@ -212,8 +212,8 @@ void ieee80211_txb_free(struct ieee80211_txb *txb) { kfree(txb); } -struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, - int gfp_mask) +static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, + int gfp_mask) { struct ieee80211_txb *txb; int i; From 76fe1b0e4c093f985c66a062c9c10370b4985796 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Sat, 7 May 2005 00:54:49 +0200 Subject: [PATCH 4/6] [PATCH] fix IEEE80211_CRYPT_* selects Some of the options didn't obey the most important rule of select If you select something, you have to ensure that the dependencies of what you do select are fulfilled. resulting in the following compile error: <-- snip --> ... LD .tmp_vmlinux1 crypto/built-in.o(.init.text+0x31b): In function `aes_init': : undefined reference to `crypto_register_alg' crypto/built-in.o(.init.text+0x326): In function `michael_mic_init': : undefined reference to `crypto_register_alg' crypto/built-in.o(.exit.text+0x6): In function `aes_fini': : undefined reference to `crypto_unregister_alg' crypto/built-in.o(.exit.text+0x16): In function `michael_mic_exit': : undefined reference to `crypto_unregister_alg' net/built-in.o(.text+0x5ba52): In function `ieee80211_ccmp_init': : undefined reference to `crypto_alloc_tfm' net/built-in.o(.text+0x5ba94): In function `ieee80211_ccmp_init': : undefined reference to `crypto_free_tfm' net/built-in.o(.text+0x5bab7): In function `ieee80211_ccmp_deinit': : undefined reference to `crypto_free_tfm' net/built-in.o(.text+0x5c5c2): In function `ieee80211_tkip_init': : undefined reference to `crypto_alloc_tfm' net/built-in.o(.text+0x5c5d5): In function `ieee80211_tkip_init': : undefined reference to `crypto_alloc_tfm' net/built-in.o(.text+0x5c623): In function `ieee80211_tkip_init': : undefined reference to `crypto_free_tfm' net/built-in.o(.text+0x5c62a): In function `ieee80211_tkip_init': : undefined reference to `crypto_free_tfm' net/built-in.o(.text+0x5c65e): In function `ieee80211_tkip_deinit': : undefined reference to `crypto_free_tfm' net/built-in.o(.text+0x5c665): In function `ieee80211_tkip_deinit': : undefined reference to `crypto_free_tfm' make: *** [.tmp_vmlinux1] Error 1 <-- snip --> This patch adds the missing selects of CRYPTO (similar to how IEEE80211_CRYPT_WEP already does it). Yes, you could argue whether CRYPTO should be select'ed by the CRYPTO_* options, but with the current CRYPTO* dependencies this patch is required. --- net/ieee80211/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ieee80211/Kconfig b/net/ieee80211/Kconfig index 23b23f72a9a4..961c711eda97 100644 --- a/net/ieee80211/Kconfig +++ b/net/ieee80211/Kconfig @@ -44,6 +44,7 @@ config IEEE80211_CRYPT_WEP config IEEE80211_CRYPT_CCMP tristate "IEEE 802.11i CCMP support" depends on IEEE80211 + select CRYPTO select CRYPTO_AES ---help--- Include software based cipher suites in support of IEEE 802.11i @@ -56,6 +57,7 @@ config IEEE80211_CRYPT_CCMP config IEEE80211_CRYPT_TKIP tristate "IEEE 802.11i TKIP encryption" depends on IEEE80211 + select CRYPTO select CRYPTO_MICHAEL_MIC ---help--- Include software based cipher suites in support of IEEE 802.11i From 286d974797705ae7ceedc846666ef98bdeee3646 Mon Sep 17 00:00:00 2001 From: Jiri Benc Date: Tue, 24 May 2005 15:10:18 +0200 Subject: [PATCH 5/6] [PATCH] ieee80211: cleanup Cleanup of unused and duplicated constants and structures in the ieee80211 header. Signed-off-by: Jiri Benc Signed-off-by: Jirka Bohac --- include/net/ieee80211.h | 40 ++++++++---------------------------- net/ieee80211/ieee80211_rx.c | 4 ++-- 2 files changed, 10 insertions(+), 34 deletions(-) diff --git a/include/net/ieee80211.h b/include/net/ieee80211.h index b1bfaf1084f4..f1d9b9e9dec7 100644 --- a/include/net/ieee80211.h +++ b/include/net/ieee80211.h @@ -93,6 +93,8 @@ struct eapol { u16 length; } __attribute__ ((packed)); +#define IEEE80211_1ADDR_LEN 10 +#define IEEE80211_2ADDR_LEN 16 #define IEEE80211_3ADDR_LEN 24 #define IEEE80211_4ADDR_LEN 30 #define IEEE80211_FCS_LEN 4 @@ -299,23 +301,6 @@ struct ieee80211_snap_hdr { #define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9 -/* Information Element IDs */ -#define WLAN_EID_SSID 0 -#define WLAN_EID_SUPP_RATES 1 -#define WLAN_EID_FH_PARAMS 2 -#define WLAN_EID_DS_PARAMS 3 -#define WLAN_EID_CF_PARAMS 4 -#define WLAN_EID_TIM 5 -#define WLAN_EID_IBSS_PARAMS 6 -#define WLAN_EID_CHALLENGE 16 -#define WLAN_EID_RSN 48 -#define WLAN_EID_GENERIC 221 - -#define IEEE80211_MGMT_HDR_LEN 24 -#define IEEE80211_DATA_HDR3_LEN 24 -#define IEEE80211_DATA_HDR4_LEN 30 - - #define IEEE80211_STATMASK_SIGNAL (1<<0) #define IEEE80211_STATMASK_RSSI (1<<1) #define IEEE80211_STATMASK_NOISE (1<<2) @@ -489,15 +474,6 @@ Total: 28-2340 bytes */ -struct ieee80211_header_data { - u16 frame_ctl; - u16 duration_id; - u8 addr1[6]; - u8 addr2[6]; - u8 addr3[6]; - u16 seq_ctrl; -}; - #define BEACON_PROBE_SSID_ID_POSITION 12 /* Management Frame Information Element Types */ @@ -542,7 +518,7 @@ struct ieee80211_info_element { */ struct ieee80211_authentication { - struct ieee80211_header_data header; + struct ieee80211_hdr_3addr header; u16 algorithm; u16 transaction; u16 status; @@ -551,7 +527,7 @@ struct ieee80211_authentication { struct ieee80211_probe_response { - struct ieee80211_header_data header; + struct ieee80211_hdr_3addr header; u32 time_stamp[2]; u16 beacon_interval; u16 capability; @@ -793,21 +769,21 @@ extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mod extern inline int ieee80211_get_hdrlen(u16 fc) { - int hdrlen = 24; + int hdrlen = IEEE80211_3ADDR_LEN; switch (WLAN_FC_GET_TYPE(fc)) { case IEEE80211_FTYPE_DATA: if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS)) - hdrlen = 30; /* Addr4 */ + hdrlen = IEEE80211_4ADDR_LEN; break; case IEEE80211_FTYPE_CTL: switch (WLAN_FC_GET_STYPE(fc)) { case IEEE80211_STYPE_CTS: case IEEE80211_STYPE_ACK: - hdrlen = 10; + hdrlen = IEEE80211_1ADDR_LEN; break; default: - hdrlen = 16; + hdrlen = IEEE80211_2ADDR_LEN; break; } break; diff --git a/net/ieee80211/ieee80211_rx.c b/net/ieee80211/ieee80211_rx.c index 2bda8a174818..2ae6ab8914b0 100644 --- a/net/ieee80211/ieee80211_rx.c +++ b/net/ieee80211/ieee80211_rx.c @@ -475,7 +475,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, #endif /* Data frame - extract src/dst addresses */ - if (skb->len < IEEE80211_DATA_HDR3_LEN) + if (skb->len < IEEE80211_3ADDR_LEN) goto rx_dropped; switch (fc & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { @@ -488,7 +488,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, memcpy(src, hdr->addr2, ETH_ALEN); break; case IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS: - if (skb->len < IEEE80211_DATA_HDR4_LEN) + if (skb->len < IEEE80211_4ADDR_LEN) goto rx_dropped; memcpy(dst, hdr->addr3, ETH_ALEN); memcpy(src, hdr->addr4, ETH_ALEN); From 66b04a80eea60cabf9d89fd34deb3234a740052f Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Fri, 27 May 2005 22:53:55 -0400 Subject: [PATCH 6/6] [wireless] ipw2100: fix build after applying SuSE cleanups s/ieee80211_header_data/ieee80211_hdr_3addr/ --- drivers/net/wireless/ipw2100.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ipw2100.h b/drivers/net/wireless/ipw2100.h index 0cc5746dd4f1..bb31fa03f69f 100644 --- a/drivers/net/wireless/ipw2100.h +++ b/drivers/net/wireless/ipw2100.h @@ -885,7 +885,7 @@ struct ipw2100_priv { -#define IPW_HEADER_802_11_SIZE sizeof(struct ieee80211_header_data) +#define IPW_HEADER_802_11_SIZE sizeof(struct ieee80211_hdr_3addr) #define IPW_MAX_80211_PAYLOAD_SIZE 2304U #define IPW_MAX_802_11_PAYLOAD_LENGTH 2312 #define IPW_MAX_ACCEPTABLE_TX_FRAME_LENGTH 1536 @@ -900,7 +900,7 @@ struct ipw2100_priv { IPW_802_11_FCS_LENGTH) #define IPW_802_11_PAYLOAD_OFFSET \ - (sizeof(struct ieee80211_header_data) + \ + (sizeof(struct ieee80211_hdr_3addr) + \ sizeof(struct ieee80211_snap_hdr)) struct ipw2100_rx {