Skip to content

Commit 62a8ff6

Browse files
Sriram Rjmberg-intel
authored andcommitted
ath10k: Validate first subframe of A-MSDU before processing the list
In certain scenarios a normal MSDU can be received as an A-MSDU when the A-MSDU present bit of a QoS header gets flipped during reception. Since this bit is unauthenticated, the hardware crypto engine can pass the frame to the driver without any error indication. This could result in processing unintended subframes collected in the A-MSDU list. Hence, validate A-MSDU list by checking if the first frame has a valid subframe header. Comparing the non-aggregated MSDU and an A-MSDU, the fields of the first subframe DA matches the LLC/SNAP header fields of a normal MSDU. In order to avoid processing such frames, add a validation to filter such A-MSDU frames where the first subframe header DA matches with the LLC/SNAP header pattern. Tested-on: QCA9984 hw1.0 PCI 10.4-3.10-00047 Cc: stable@vger.kernel.org Signed-off-by: Sriram R <srirrama@codeaurora.org> Signed-off-by: Jouni Malinen <jouni@codeaurora.org> Link: https://lore.kernel.org/r/20210511200110.e6f5eb7b9847.I38a77ae26096862527a5eab73caebd7346af8b66@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 0dc267b commit 62a8ff6

File tree

1 file changed

+57
-4
lines changed

1 file changed

+57
-4
lines changed

drivers/net/wireless/ath/ath10k/htt_rx.c

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,14 +2108,62 @@ static void ath10k_htt_rx_h_unchain(struct ath10k *ar,
21082108
ath10k_unchain_msdu(amsdu, unchain_cnt);
21092109
}
21102110

2111+
static bool ath10k_htt_rx_validate_amsdu(struct ath10k *ar,
2112+
struct sk_buff_head *amsdu)
2113+
{
2114+
u8 *subframe_hdr;
2115+
struct sk_buff *first;
2116+
bool is_first, is_last;
2117+
struct htt_rx_desc *rxd;
2118+
struct ieee80211_hdr *hdr;
2119+
size_t hdr_len, crypto_len;
2120+
enum htt_rx_mpdu_encrypt_type enctype;
2121+
int bytes_aligned = ar->hw_params.decap_align_bytes;
2122+
2123+
first = skb_peek(amsdu);
2124+
2125+
rxd = (void *)first->data - sizeof(*rxd);
2126+
hdr = (void *)rxd->rx_hdr_status;
2127+
2128+
is_first = !!(rxd->msdu_end.common.info0 &
2129+
__cpu_to_le32(RX_MSDU_END_INFO0_FIRST_MSDU));
2130+
is_last = !!(rxd->msdu_end.common.info0 &
2131+
__cpu_to_le32(RX_MSDU_END_INFO0_LAST_MSDU));
2132+
2133+
/* Return in case of non-aggregated msdu */
2134+
if (is_first && is_last)
2135+
return true;
2136+
2137+
/* First msdu flag is not set for the first msdu of the list */
2138+
if (!is_first)
2139+
return false;
2140+
2141+
enctype = MS(__le32_to_cpu(rxd->mpdu_start.info0),
2142+
RX_MPDU_START_INFO0_ENCRYPT_TYPE);
2143+
2144+
hdr_len = ieee80211_hdrlen(hdr->frame_control);
2145+
crypto_len = ath10k_htt_rx_crypto_param_len(ar, enctype);
2146+
2147+
subframe_hdr = (u8 *)hdr + round_up(hdr_len, bytes_aligned) +
2148+
crypto_len;
2149+
2150+
/* Validate if the amsdu has a proper first subframe.
2151+
* There are chances a single msdu can be received as amsdu when
2152+
* the unauthenticated amsdu flag of a QoS header
2153+
* gets flipped in non-SPP AMSDU's, in such cases the first
2154+
* subframe has llc/snap header in place of a valid da.
2155+
* return false if the da matches rfc1042 pattern
2156+
*/
2157+
if (ether_addr_equal(subframe_hdr, rfc1042_header))
2158+
return false;
2159+
2160+
return true;
2161+
}
2162+
21112163
static bool ath10k_htt_rx_amsdu_allowed(struct ath10k *ar,
21122164
struct sk_buff_head *amsdu,
21132165
struct ieee80211_rx_status *rx_status)
21142166
{
2115-
/* FIXME: It might be a good idea to do some fuzzy-testing to drop
2116-
* invalid/dangerous frames.
2117-
*/
2118-
21192167
if (!rx_status->freq) {
21202168
ath10k_dbg(ar, ATH10K_DBG_HTT, "no channel configured; ignoring frame(s)!\n");
21212169
return false;
@@ -2126,6 +2174,11 @@ static bool ath10k_htt_rx_amsdu_allowed(struct ath10k *ar,
21262174
return false;
21272175
}
21282176

2177+
if (!ath10k_htt_rx_validate_amsdu(ar, amsdu)) {
2178+
ath10k_dbg(ar, ATH10K_DBG_HTT, "invalid amsdu received\n");
2179+
return false;
2180+
}
2181+
21292182
return true;
21302183
}
21312184

0 commit comments

Comments
 (0)