Skip to content

Commit 2e691f9

Browse files
ecsvgregkh
authored andcommitted
ath11k: Fix buffer overflow when scanning with extraie
commit a658c92 upstream. If cfg80211 is providing extraie's for a scanning process then ath11k will copy that over to the firmware. The extraie.len is a 32 bit value in struct element_info and describes the amount of bytes for the vendor information elements. The WMI_TLV packet is having a special WMI_TAG_ARRAY_BYTE section. This section can have a (payload) length up to 65535 bytes because the WMI_TLV_LEN can store up to 16 bits. The code was missing such a check and could have created a scan request which cannot be parsed correctly by the firmware. But the bigger problem was the allocation of the buffer. It has to align the TLV sections by 4 bytes. But the code was using an u8 to store the newly calculated length of this section (with alignment). And the new calculated length was then used to allocate the skbuff. But the actual code to copy in the data is using the extraie.len and not the calculated "aligned" length. The length of extraie with IEEE80211_HW_SINGLE_SCAN_ON_ALL_BANDS enabled was 264 bytes during tests with a QCA Milan card. But it only allocated 8 bytes (264 bytes % 256) for it. As consequence, the code to memcpy the extraie into the skb was then just overwriting data after skb->end. Things like shinfo were therefore corrupted. This could usually be seen by a crash in skb_zcopy_clear which tried to call a ubuf_info callback (using a bogus address). Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-02892.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1 Cc: stable@vger.kernel.org Fixes: d5c6515 ("ath11k: driver for Qualcomm IEEE 802.11ax devices") Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://lore.kernel.org/r/20211207142913.1734635-1-sven@narfation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a87cecf commit 2e691f9

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

  • drivers/net/wireless/ath/ath11k

‎drivers/net/wireless/ath/ath11k/wmi.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,7 @@ int ath11k_wmi_send_scan_start_cmd(struct ath11k *ar,
20362036
void *ptr;
20372037
int i, ret, len;
20382038
u32 *tmp_ptr;
2039-
u8 extraie_len_with_pad = 0;
2039+
u16 extraie_len_with_pad = 0;
20402040
struct hint_short_ssid *s_ssid = NULL;
20412041
struct hint_bssid *hint_bssid = NULL;
20422042

@@ -2055,7 +2055,7 @@ int ath11k_wmi_send_scan_start_cmd(struct ath11k *ar,
20552055
len += sizeof(*bssid) * params->num_bssid;
20562056

20572057
len += TLV_HDR_SIZE;
2058-
if (params->extraie.len)
2058+
if (params->extraie.len && params->extraie.len <= 0xFFFF)
20592059
extraie_len_with_pad =
20602060
roundup(params->extraie.len, sizeof(u32));
20612061
len += extraie_len_with_pad;
@@ -2162,7 +2162,7 @@ int ath11k_wmi_send_scan_start_cmd(struct ath11k *ar,
21622162
FIELD_PREP(WMI_TLV_LEN, len);
21632163
ptr += TLV_HDR_SIZE;
21642164

2165-
if (params->extraie.len)
2165+
if (extraie_len_with_pad)
21662166
memcpy(ptr, params->extraie.ptr,
21672167
params->extraie.len);
21682168

0 commit comments

Comments
 (0)