From 695d456382c18742c1384f5d7cabffc97f2b20f7 Mon Sep 17 00:00:00 2001 From: Stephen Oliver Date: Wed, 5 Aug 2020 15:44:52 -0400 Subject: [PATCH 1/4] Remove topdir variable --- Makefile | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 043d673..b57c4f3 100755 --- a/Makefile +++ b/Makefile @@ -159,8 +159,6 @@ CONFIG_PLATFORM_PPC64LE = n CONFIG_DRVEXT_MODULE = n -export TopDIR ?= $(shell pwd) - ########### COMMON ################################# ifeq ($(CONFIG_GSPI_HCI), y) HCI_NAME = gspi @@ -775,16 +773,16 @@ endif ifeq ($(CONFIG_AUTOCFG_CP), y) ifeq ($(CONFIG_MULTIDRV), y) -$(shell cp $(TopDIR)/autoconf_multidrv_$(HCI_NAME)_linux.h $(TopDIR)/include/autoconf.h) +$(shell cp autoconf_multidrv_$(HCI_NAME)_linux.h include/autoconf.h) else ifeq ($(CONFIG_RTL8188E)$(CONFIG_SDIO_HCI),yy) -$(shell cp $(TopDIR)/autoconf_rtl8189e_$(HCI_NAME)_linux.h $(TopDIR)/include/autoconf.h) +$(shell cp autoconf_rtl8189e_$(HCI_NAME)_linux.h include/autoconf.h) else ifeq ($(CONFIG_RTL8188F)$(CONFIG_SDIO_HCI),yy) -$(shell cp $(TopDIR)/autoconf_rtl8189f_$(HCI_NAME)_linux.h $(TopDIR)/include/autoconf.h) +$(shell cp autoconf_rtl8189f_$(HCI_NAME)_linux.h include/autoconf.h) else ifeq ($(CONFIG_RTL8723C),y) -$(shell cp $(TopDIR)/autoconf_rtl8723c_$(HCI_NAME)_linux.h $(TopDIR)/include/autoconf.h) +$(shell cp autoconf_rtl8723c_$(HCI_NAME)_linux.h include/autoconf.h) else -$(shell cp $(TopDIR)/autoconf_$(RTL871X)_$(HCI_NAME)_linux.h $(TopDIR)/include/autoconf.h) +$(shell cp autoconf_$(RTL871X)_$(HCI_NAME)_linux.h include/autoconf.h) endif endif From 33a82d10db95f1d21978635eb588f31f325083af Mon Sep 17 00:00:00 2001 From: Stephen Oliver Date: Mon, 17 Aug 2020 15:31:20 -0400 Subject: [PATCH 2/4] Set MTU fields in device structs --- os_dep/linux/ioctl_cfg80211.c | 6 ++++++ os_dep/linux/os_intfs.c | 6 ++++++ os_dep/osdep_service.c | 12 ++++++++++++ 3 files changed, 24 insertions(+) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 01fab29..04f1a76 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -4460,6 +4460,12 @@ static int rtw_cfg80211_add_monitor_if(_adapter *padapter, char *name, goto out; } +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)) + mon_ndev->min_mtu = WLAN_MIN_ETHFRM_LEN; + mon_ndev->mtu = WLAN_DATA_MAXLEN; + mon_ndev->max_mtu = WLAN_DATA_MAXLEN; +#endif + mon_ndev->type = ARPHRD_IEEE80211_RADIOTAP; strncpy(mon_ndev->name, name, IFNAMSIZ); mon_ndev->name[IFNAMSIZ - 1] = 0; diff --git a/os_dep/linux/os_intfs.c b/os_dep/linux/os_intfs.c index caf020d..bd7da8b 100644 --- a/os_dep/linux/os_intfs.c +++ b/os_dep/linux/os_intfs.c @@ -1513,6 +1513,12 @@ struct net_device *rtw_init_netdev(_adapter *old_padapter) if (!pnetdev) return NULL; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)) + pnetdev->min_mtu = WLAN_MIN_ETHFRM_LEN; + pnetdev->mtu = WLAN_DATA_MAXLEN; + pnetdev->max_mtu = WLAN_DATA_MAXLEN; +#endif + padapter = rtw_netdev_priv(pnetdev); padapter->pnetdev = pnetdev; diff --git a/os_dep/osdep_service.c b/os_dep/osdep_service.c index 82a37d2..1068f2d 100644 --- a/os_dep/osdep_service.c +++ b/os_dep/osdep_service.c @@ -2324,6 +2324,12 @@ struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, void *old_p if (!pnetdev) goto RETURN; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)) + pnetdev->min_mtu = WLAN_MIN_ETHFRM_LEN; + pnetdev->mtu = WLAN_MAX_ETHFRM_LEN; + pnetdev->max_mtu = WLAN_DATA_MAXLEN; +#endif + pnpi = netdev_priv(pnetdev); pnpi->priv = old_priv; pnpi->sizeof_priv = sizeof_priv; @@ -2345,6 +2351,12 @@ struct net_device *rtw_alloc_etherdev(int sizeof_priv) if (!pnetdev) goto RETURN; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)) + pnetdev->min_mtu = WLAN_MIN_ETHFRM_LEN; + pnetdev->mtu = WLAN_MAX_ETHFRM_LEN; + pnetdev->max_mtu = WLAN_DATA_MAXLEN; +#endif + pnpi = netdev_priv(pnetdev); pnpi->priv = rtw_zvmalloc(sizeof_priv); From f71a963ad7bedfa60a8c4f90b464648117eea65e Mon Sep 17 00:00:00 2001 From: Stephen Oliver Date: Mon, 14 Dec 2020 23:02:33 -0500 Subject: [PATCH 3/4] Fix a few incompatibilities with newer kernels --- os_dep/linux/ioctl_cfg80211.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/os_dep/linux/ioctl_cfg80211.c b/os_dep/linux/ioctl_cfg80211.c index 04f1a76..86ba2ae 100644 --- a/os_dep/linux/ioctl_cfg80211.c +++ b/os_dep/linux/ioctl_cfg80211.c @@ -7094,6 +7094,11 @@ exit: return ret; } +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0)) +static void cfg80211_rtw_update_mgmt_frame_register(struct wiphy *wiphy, + struct wireless_dev *wdev, + struct mgmt_frame_regs *upd) +#else static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy, #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) struct wireless_dev *wdev, @@ -7101,12 +7106,12 @@ static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy, struct net_device *ndev, #endif u16 frame_type, bool reg) +#endif { #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) struct net_device *ndev = wdev_to_ndev(wdev); #endif _adapter *adapter; - struct rtw_wdev_priv *pwdev_priv; if (ndev == NULL) @@ -7120,20 +7125,6 @@ static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy, frame_type, reg); #endif - /* Wait QC Verify */ - return; - - switch (frame_type) { - case IEEE80211_STYPE_PROBE_REQ: /* 0x0040 */ - SET_CFG80211_REPORT_MGMT(pwdev_priv, IEEE80211_STYPE_PROBE_REQ, reg); - break; - case IEEE80211_STYPE_ACTION: /* 0x00D0 */ - SET_CFG80211_REPORT_MGMT(pwdev_priv, IEEE80211_STYPE_ACTION, reg); - break; - default: - break; - } - exit: return; } @@ -9438,7 +9429,11 @@ static struct cfg80211_ops rtw_cfg80211_ops = { #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)) || defined(COMPAT_KERNEL_RELEASE) .mgmt_tx = cfg80211_rtw_mgmt_tx, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0)) + .update_mgmt_frame_registrations = cfg80211_rtw_update_mgmt_frame_register, +#else .mgmt_frame_register = cfg80211_rtw_mgmt_frame_register, +#endif #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) && LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35)) .action = cfg80211_rtw_mgmt_tx, #endif From baaa09253d52dd166e1c7cc8b44ddab9db2da39e Mon Sep 17 00:00:00 2001 From: Stephen Oliver Date: Mon, 14 Dec 2020 23:52:48 -0500 Subject: [PATCH 4/4] Avoid aliasing symbols in newer kernels --- core/rtw_security.c | 42 +++++++++++++++++++++--------------------- include/rtw_security.h | 4 ++-- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/core/rtw_security.c b/core/rtw_security.c index 5807521..926e0ea 100644 --- a/core/rtw_security.c +++ b/core/rtw_security.c @@ -2133,7 +2133,7 @@ BIP_exit: #ifndef PLATFORM_FREEBSD #if defined(CONFIG_TDLS) /* compress 512-bits */ -static int sha256_compress(struct sha256_state *md, unsigned char *buf) +static int rtw_sha256_compress(struct rtw_sha256_state *md, unsigned char *buf) { u32 S[8], W[64], t0, t1; u32 t; @@ -2181,7 +2181,7 @@ static int sha256_compress(struct sha256_state *md, unsigned char *buf) } /* Initialize the hash state */ -static void sha256_init(struct sha256_state *md) +static void rtw_sha256_init(struct rtw_sha256_state *md) { md->curlen = 0; md->length = 0; @@ -2202,7 +2202,7 @@ static void sha256_init(struct sha256_state *md) @param inlen The length of the data (octets) @return CRYPT_OK if successful */ -static int sha256_process(struct sha256_state *md, unsigned char *in, +static int rtw_sha256_process(struct rtw_sha256_state *md, unsigned char *in, unsigned long inlen) { unsigned long n; @@ -2213,7 +2213,7 @@ static int sha256_process(struct sha256_state *md, unsigned char *in, while (inlen > 0) { if (md->curlen == 0 && inlen >= block_size) { - if (sha256_compress(md, (unsigned char *) in) < 0) + if (rtw_sha256_compress(md, (unsigned char *) in) < 0) return -1; md->length += block_size * 8; in += block_size; @@ -2225,7 +2225,7 @@ static int sha256_process(struct sha256_state *md, unsigned char *in, in += n; inlen -= n; if (md->curlen == block_size) { - if (sha256_compress(md, md->buf) < 0) + if (rtw_sha256_compress(md, md->buf) < 0) return -1; md->length += 8 * block_size; md->curlen = 0; @@ -2243,7 +2243,7 @@ static int sha256_process(struct sha256_state *md, unsigned char *in, @param out [out] The destination of the hash (32 bytes) @return CRYPT_OK if successful */ -static int sha256_done(struct sha256_state *md, unsigned char *out) +static int rtw_sha256_done(struct rtw_sha256_state *md, unsigned char *out) { int i; @@ -2263,7 +2263,7 @@ static int sha256_done(struct sha256_state *md, unsigned char *out) if (md->curlen > 56) { while (md->curlen < 64) md->buf[md->curlen++] = (unsigned char) 0; - sha256_compress(md, md->buf); + rtw_sha256_compress(md, md->buf); md->curlen = 0; } @@ -2273,7 +2273,7 @@ static int sha256_done(struct sha256_state *md, unsigned char *out) /* store length */ WPA_PUT_BE64(md->buf + 56, md->length); - sha256_compress(md, md->buf); + rtw_sha256_compress(md, md->buf); /* copy output */ for (i = 0; i < 8; i++) @@ -2290,17 +2290,17 @@ static int sha256_done(struct sha256_state *md, unsigned char *out) * @mac: Buffer for the hash * Returns: 0 on success, -1 of failure */ -static int sha256_vector(size_t num_elem, u8 *addr[], size_t *len, +static int rtw_sha256_vector(size_t num_elem, u8 *addr[], size_t *len, u8 *mac) { - struct sha256_state ctx; + struct rtw_sha256_state ctx; size_t i; - sha256_init(&ctx); + rtw_sha256_init(&ctx); for (i = 0; i < num_elem; i++) - if (sha256_process(&ctx, addr[i], len[i])) + if (rtw_sha256_process(&ctx, addr[i], len[i])) return -1; - if (sha256_done(&ctx, mac)) + if (rtw_sha256_done(&ctx, mac)) return -1; return 0; } @@ -2362,7 +2362,7 @@ static void hmac_sha256_vector(u8 *key, size_t key_len, size_t num_elem, /* if key is longer than 64 bytes reset it to key = SHA256(key) */ if (key_len > 64) { - sha256_vector(1, &key, &key_len, tk); + rtw_sha256_vector(1, &key, &key_len, tk); key = tk; key_len = 32; } @@ -2390,7 +2390,7 @@ static void hmac_sha256_vector(u8 *key, size_t key_len, size_t num_elem, _addr[i + 1] = addr[i]; _len[i + 1] = len[i]; } - sha256_vector(1 + num_elem, _addr, _len, mac); + rtw_sha256_vector(1 + num_elem, _addr, _len, mac); _rtw_memset(k_pad, 0, sizeof(k_pad)); _rtw_memcpy(k_pad, key, key_len); @@ -2403,7 +2403,7 @@ static void hmac_sha256_vector(u8 *key, size_t key_len, size_t num_elem, _len[0] = 64; _addr[1] = mac; _len[1] = 32; - sha256_vector(2, _addr, _len, mac); + rtw_sha256_vector(2, _addr, _len, mac); } #endif /* CONFIG_TDLS */ #endif /* PLATFORM_FREEBSD */ @@ -2422,7 +2422,7 @@ static void hmac_sha256_vector(u8 *key, size_t key_len, size_t num_elem, */ #ifndef PLATFORM_FREEBSD /* Baron */ #if defined(CONFIG_TDLS) -static void sha256_prf(u8 *key, size_t key_len, char *label, +static void rtw_sha256_prf(u8 *key, size_t key_len, char *label, u8 *data, size_t data_len, u8 *buf, size_t buf_len) { u16 counter = 1; @@ -2446,10 +2446,10 @@ static void sha256_prf(u8 *key, size_t key_len, char *label, while (pos < buf_len) { plen = buf_len - pos; WPA_PUT_LE16(counter_le, counter); - if (plen >= SHA256_MAC_LEN) { + if (plen >= RTW_SHA256_MAC_LEN) { hmac_sha256_vector(key, key_len, 4, addr, len, &buf[pos]); - pos += SHA256_MAC_LEN; + pos += RTW_SHA256_MAC_LEN; } else { hmac_sha256_vector(key, key_len, 4, addr, len, hash); _rtw_memcpy(&buf[pos], hash, plen); @@ -3108,7 +3108,7 @@ void wpa_tdls_generate_tpk(_adapter *padapter, void *sta) nonce[1] = SNonce; } - sha256_vector(2, nonce, len, key_input); + rtw_sha256_vector(2, nonce, len, key_input); /* * TPK-Key-Data = KDF-N_KEY(TPK-Key-Input, "TDLS PMK", @@ -3127,7 +3127,7 @@ void wpa_tdls_generate_tpk(_adapter *padapter, void *sta) } _rtw_memcpy(data + 2 * ETH_ALEN, get_bssid(pmlmepriv), ETH_ALEN); - sha256_prf(key_input, SHA256_MAC_LEN, "TDLS PMK", data, sizeof(data), (u8 *) &psta->tpk, sizeof(psta->tpk)); + rtw_sha256_prf(key_input, RTW_SHA256_MAC_LEN, "TDLS PMK", data, sizeof(data), (u8 *) &psta->tpk, sizeof(psta->tpk)); } diff --git a/include/rtw_security.h b/include/rtw_security.h index ac8432e..85ebf92 100644 --- a/include/rtw_security.h +++ b/include/rtw_security.h @@ -41,7 +41,7 @@ const char *security_type_str(u8 value); #define _WPA_IE_ID_ 0xdd #define _WPA2_IE_ID_ 0x30 -#define SHA256_MAC_LEN 32 +#define RTW_SHA256_MAC_LEN 32 #define AES_BLOCK_SIZE 16 #define AES_PRIV_SIZE (4 * 44) @@ -249,7 +249,7 @@ struct security_priv { #define SEC_IS_BIP_KEY_INSTALLED(sec) _FALSE #endif -struct sha256_state { +struct rtw_sha256_state { u64 length; u32 state[8], curlen; u8 buf[64];