Skip to content

Commit a658c92

Browse files
ecsvkvalo
authored andcommitted
ath11k: Fix buffer overflow when scanning with extraie
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
1 parent 5a10537 commit a658c92

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
@@ -2113,7 +2113,7 @@ int ath11k_wmi_send_scan_start_cmd(struct ath11k *ar,
21132113
void *ptr;
21142114
int i, ret, len;
21152115
u32 *tmp_ptr;
2116-
u8 extraie_len_with_pad = 0;
2116+
u16 extraie_len_with_pad = 0;
21172117
struct hint_short_ssid *s_ssid = NULL;
21182118
struct hint_bssid *hint_bssid = NULL;
21192119

@@ -2132,7 +2132,7 @@ int ath11k_wmi_send_scan_start_cmd(struct ath11k *ar,
21322132
len += sizeof(*bssid) * params->num_bssid;
21332133

21342134
len += TLV_HDR_SIZE;
2135-
if (params->extraie.len)
2135+
if (params->extraie.len && params->extraie.len <= 0xFFFF)
21362136
extraie_len_with_pad =
21372137
roundup(params->extraie.len, sizeof(u32));
21382138
len += extraie_len_with_pad;
@@ -2239,7 +2239,7 @@ int ath11k_wmi_send_scan_start_cmd(struct ath11k *ar,
22392239
FIELD_PREP(WMI_TLV_LEN, len);
22402240
ptr += TLV_HDR_SIZE;
22412241

2242-
if (params->extraie.len)
2242+
if (extraie_len_with_pad)
22432243
memcpy(ptr, params->extraie.ptr,
22442244
params->extraie.len);
22452245

0 commit comments

Comments
 (0)