From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: qize wang <wangqize888888888@gmail.com>,
Kalle Valo <kvalo@codeaurora.org>,
Sasha Levin <sashal@kernel.org>,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 08/84] mwifiex: Fix heap overflow in mmwifiex_process_tdls_action_frame()
Date: Fri, 27 Dec 2019 12:42:36 -0500 [thread overview]
Message-ID: <20191227174352.6264-8-sashal@kernel.org> (raw)
In-Reply-To: <20191227174352.6264-1-sashal@kernel.org>
From: qize wang <wangqize888888888@gmail.com>
[ Upstream commit 1e58252e334dc3f3756f424a157d1b7484464c40 ]
mwifiex_process_tdls_action_frame() without checking
the incoming tdls infomation element's vality before use it,
this may cause multi heap buffer overflows.
Fix them by putting vality check before use it.
IE is TLV struct, but ht_cap and ht_oper aren’t TLV struct.
the origin marvell driver code is wrong:
memcpy(&sta_ptr->tdls_cap.ht_oper, pos,....
memcpy((u8 *)&sta_ptr->tdls_cap.ht_capb, pos,...
Fix the bug by changing pos(the address of IE) to
pos+2 ( the address of IE value ).
Signed-off-by: qize wang <wangqize888888888@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/wireless/marvell/mwifiex/tdls.c | 70 +++++++++++++++++++--
1 file changed, 64 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/marvell/mwifiex/tdls.c b/drivers/net/wireless/marvell/mwifiex/tdls.c
index 27779d7317fd..6058c48d56dc 100644
--- a/drivers/net/wireless/marvell/mwifiex/tdls.c
+++ b/drivers/net/wireless/marvell/mwifiex/tdls.c
@@ -956,59 +956,117 @@ void mwifiex_process_tdls_action_frame(struct mwifiex_private *priv,
switch (*pos) {
case WLAN_EID_SUPP_RATES:
+ if (pos[1] > 32)
+ return;
sta_ptr->tdls_cap.rates_len = pos[1];
for (i = 0; i < pos[1]; i++)
sta_ptr->tdls_cap.rates[i] = pos[i + 2];
break;
case WLAN_EID_EXT_SUPP_RATES:
+ if (pos[1] > 32)
+ return;
basic = sta_ptr->tdls_cap.rates_len;
+ if (pos[1] > 32 - basic)
+ return;
for (i = 0; i < pos[1]; i++)
sta_ptr->tdls_cap.rates[basic + i] = pos[i + 2];
sta_ptr->tdls_cap.rates_len += pos[1];
break;
case WLAN_EID_HT_CAPABILITY:
- memcpy((u8 *)&sta_ptr->tdls_cap.ht_capb, pos,
+ if (pos > end - sizeof(struct ieee80211_ht_cap) - 2)
+ return;
+ if (pos[1] != sizeof(struct ieee80211_ht_cap))
+ return;
+ /* copy the ie's value into ht_capb*/
+ memcpy((u8 *)&sta_ptr->tdls_cap.ht_capb, pos + 2,
sizeof(struct ieee80211_ht_cap));
sta_ptr->is_11n_enabled = 1;
break;
case WLAN_EID_HT_OPERATION:
- memcpy(&sta_ptr->tdls_cap.ht_oper, pos,
+ if (pos > end -
+ sizeof(struct ieee80211_ht_operation) - 2)
+ return;
+ if (pos[1] != sizeof(struct ieee80211_ht_operation))
+ return;
+ /* copy the ie's value into ht_oper*/
+ memcpy(&sta_ptr->tdls_cap.ht_oper, pos + 2,
sizeof(struct ieee80211_ht_operation));
break;
case WLAN_EID_BSS_COEX_2040:
+ if (pos > end - 3)
+ return;
+ if (pos[1] != 1)
+ return;
sta_ptr->tdls_cap.coex_2040 = pos[2];
break;
case WLAN_EID_EXT_CAPABILITY:
+ if (pos > end - sizeof(struct ieee_types_header))
+ return;
+ if (pos[1] < sizeof(struct ieee_types_header))
+ return;
+ if (pos[1] > 8)
+ return;
memcpy((u8 *)&sta_ptr->tdls_cap.extcap, pos,
sizeof(struct ieee_types_header) +
min_t(u8, pos[1], 8));
break;
case WLAN_EID_RSN:
+ if (pos > end - sizeof(struct ieee_types_header))
+ return;
+ if (pos[1] < sizeof(struct ieee_types_header))
+ return;
+ if (pos[1] > IEEE_MAX_IE_SIZE -
+ sizeof(struct ieee_types_header))
+ return;
memcpy((u8 *)&sta_ptr->tdls_cap.rsn_ie, pos,
sizeof(struct ieee_types_header) +
min_t(u8, pos[1], IEEE_MAX_IE_SIZE -
sizeof(struct ieee_types_header)));
break;
case WLAN_EID_QOS_CAPA:
+ if (pos > end - 3)
+ return;
+ if (pos[1] != 1)
+ return;
sta_ptr->tdls_cap.qos_info = pos[2];
break;
case WLAN_EID_VHT_OPERATION:
- if (priv->adapter->is_hw_11ac_capable)
- memcpy(&sta_ptr->tdls_cap.vhtoper, pos,
+ if (priv->adapter->is_hw_11ac_capable) {
+ if (pos > end -
+ sizeof(struct ieee80211_vht_operation) - 2)
+ return;
+ if (pos[1] !=
+ sizeof(struct ieee80211_vht_operation))
+ return;
+ /* copy the ie's value into vhtoper*/
+ memcpy(&sta_ptr->tdls_cap.vhtoper, pos + 2,
sizeof(struct ieee80211_vht_operation));
+ }
break;
case WLAN_EID_VHT_CAPABILITY:
if (priv->adapter->is_hw_11ac_capable) {
- memcpy((u8 *)&sta_ptr->tdls_cap.vhtcap, pos,
+ if (pos > end -
+ sizeof(struct ieee80211_vht_cap) - 2)
+ return;
+ if (pos[1] != sizeof(struct ieee80211_vht_cap))
+ return;
+ /* copy the ie's value into vhtcap*/
+ memcpy((u8 *)&sta_ptr->tdls_cap.vhtcap, pos + 2,
sizeof(struct ieee80211_vht_cap));
sta_ptr->is_11ac_enabled = 1;
}
break;
case WLAN_EID_AID:
- if (priv->adapter->is_hw_11ac_capable)
+ if (priv->adapter->is_hw_11ac_capable) {
+ if (pos > end - 4)
+ return;
+ if (pos[1] != 2)
+ return;
sta_ptr->tdls_cap.aid =
get_unaligned_le16((pos + 2));
+ }
+ break;
default:
break;
}
--
2.20.1
next prev parent reply other threads:[~2019-12-27 17:50 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20191227174352.6264-1-sashal@kernel.org>
2019-12-27 17:42 ` [PATCH AUTOSEL 4.19 05/84] mwifiex: fix possible heap overflow in mwifiex_process_country_ie() Sasha Levin
2019-12-27 17:42 ` [PATCH AUTOSEL 4.19 07/84] netfilter: ctnetlink: netns exit must wait for callbacks Sasha Levin
2019-12-27 17:42 ` Sasha Levin [this message]
2019-12-27 17:42 ` [PATCH AUTOSEL 4.19 12/84] netfilter: nf_queue: enqueue skbs with NULL dst Sasha Levin
2019-12-27 17:42 ` [PATCH AUTOSEL 4.19 19/84] netfilter: nft_set_rbtree: bogus lookup/get on consecutive elements in named sets Sasha Levin
2019-12-27 17:42 ` [PATCH AUTOSEL 4.19 20/84] netfilter: nf_tables: validate NFT_SET_ELEM_INTERVAL_END Sasha Levin
2019-12-27 17:42 ` [PATCH AUTOSEL 4.19 21/84] netfilter: nf_tables: validate NFT_DATA_VALUE after nft_data_init() Sasha Levin
2019-12-27 17:42 ` [PATCH AUTOSEL 4.19 22/84] netfilter: bridge: make sure to pull arp header in br_nf_forward_arp() Sasha Levin
2019-12-27 17:42 ` [PATCH AUTOSEL 4.19 26/84] selftests: forwarding: Delete IPv6 address at the end Sasha Levin
2019-12-27 17:42 ` [PATCH AUTOSEL 4.19 28/84] af_packet: set defaule value for tmo Sasha Levin
2019-12-27 17:42 ` [PATCH AUTOSEL 4.19 29/84] fjes: fix missed check in fjes_acpi_add Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 32/84] bnxt_en: Return error if FW returns more data than dump length Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 33/84] net: ena: fix napi handler misbehavior when the napi budget is zero Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 34/84] bpf, mips: Limit to 33 tail calls Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 37/84] samples: bpf: Replace symbol compare of trace_event Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 38/84] samples: bpf: fix syscall_tp due to unused syscall Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 40/84] net: usb: lan78xx: Fix suspend/resume PHY register access error Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 41/84] qede: Fix multicast mac configuration Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 45/84] bpf: Clear skb->tstamp in bpf_redirect when necessary Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 46/84] tcp/dccp: fix possible race __inet_lookup_established() Sasha Levin
2020-01-02 8:01 ` Naresh Kamboju
2020-01-09 15:32 ` Sasha Levin
2020-01-09 17:07 ` Michal Kubecek
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 47/84] 6pack,mkiss: fix possible deadlock Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 48/84] net: marvell: mvpp2: phylink requires the link interrupt Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 49/84] bnx2x: Do not handle requests from VFs after parity Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 50/84] bnx2x: Fix logic to get total no. of PFs per engine Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 51/84] bonding: fix active-backup transition after link failure Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 52/84] gtp: do not allow adding duplicate tid and ms_addr pdp context Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 53/84] gtp: fix wrong condition in gtp_genl_dump_pdp() Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 54/84] gtp: avoid zero size hashtable Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 55/84] cxgb4: Fix kernel panic while accessing sge_info Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 56/84] net: usb: lan78xx: Fix error message format specifier Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 58/84] rfkill: Fix incorrect check to avoid NULL pointer dereference Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 61/84] net: gemini: Fix memory leak in gmac_setup_txqs Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 67/84] net: qlogic: Fix error paths in ql_alloc_large_buffers() Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 68/84] net: nfc: nci: fix a possible sleep-in-atomic-context bug in nci_uart_tty_receive() Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 69/84] net: stmmac: Do not accept invalid MTU values Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 70/84] net: stmmac: xgmac: Clear previous RX buffer size Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 71/84] net: stmmac: RX buffer size must be 16 byte aligned Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 72/84] net: stmmac: Always arm TX Timer at end of transmission start Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 75/84] net, sysctl: Fix compiler warning when only cBPF is present Sasha Levin
2019-12-27 17:43 ` [PATCH AUTOSEL 4.19 80/84] net: hisilicon: Fix a BUG trigered by wrong bytes_compl Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191227174352.6264-8-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=kvalo@codeaurora.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=wangqize888888888@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).