From: Jouni Malinen <jouni@codeaurora.org> To: Kalle Valo <kvalo@codeaurora.org> Cc: ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, Baochen Qiang <bqiang@codeaurora.org>, Jouni Malinen <jouni@codeaurora.org> Subject: [PATCH 2/5] ath11k: Drop MSDU with length error in DP rx path Date: Mon, 13 Sep 2021 21:02:43 +0300 [thread overview] Message-ID: <20210913180246.193388-2-jouni@codeaurora.org> (raw) In-Reply-To: <20210913180246.193388-1-jouni@codeaurora.org> From: Baochen Qiang <bqiang@codeaurora.org> There are MSDUs whose length are invalid. For example, attackers may inject on purpose truncated A-MSDUs with invalid MSDU length. Such MSDUs are marked with an err bit set in rx attention tlvs, so we can check and drop them. Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-01740-QCAHSTSWPLZ_V2_TO_X86-1 Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1 Signed-off-by: Baochen Qiang <bqiang@codeaurora.org> Signed-off-by: Jouni Malinen <jouni@codeaurora.org> --- drivers/net/wireless/ath/ath11k/dp_rx.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c index 0c27eead3e02..c50f70913583 100644 --- a/drivers/net/wireless/ath/ath11k/dp_rx.c +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c @@ -142,6 +142,18 @@ static u32 ath11k_dp_rx_h_attn_mpdu_err(struct rx_attention *attn) return errmap; } +static bool ath11k_dp_rx_h_attn_msdu_len_err(struct ath11k_base *ab, + struct hal_rx_desc *desc) +{ + struct rx_attention *rx_attention; + u32 errmap; + + rx_attention = ath11k_dp_rx_get_attention(ab, desc); + errmap = ath11k_dp_rx_h_attn_mpdu_err(rx_attention); + + return errmap & DP_RX_MPDU_ERR_MSDU_LEN; +} + static u16 ath11k_dp_rx_h_msdu_start_msdu_len(struct ath11k_base *ab, struct hal_rx_desc *desc) { @@ -2525,6 +2537,12 @@ static int ath11k_dp_rx_process_msdu(struct ath11k *ar, } rx_desc = (struct hal_rx_desc *)msdu->data; + if (ath11k_dp_rx_h_attn_msdu_len_err(ab, rx_desc)) { + ath11k_warn(ar->ab, "msdu len not valid\n"); + ret = -EIO; + goto free_out; + } + lrx_desc = (struct hal_rx_desc *)last_buf->data; rx_attention = ath11k_dp_rx_get_attention(ab, lrx_desc); if (!ath11k_dp_rx_h_attn_msdu_done(rx_attention)) { -- 2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: Jouni Malinen <jouni@codeaurora.org> To: Kalle Valo <kvalo@codeaurora.org> Cc: ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, Baochen Qiang <bqiang@codeaurora.org>, Jouni Malinen <jouni@codeaurora.org> Subject: [PATCH 2/5] ath11k: Drop MSDU with length error in DP rx path Date: Mon, 13 Sep 2021 21:02:43 +0300 [thread overview] Message-ID: <20210913180246.193388-2-jouni@codeaurora.org> (raw) In-Reply-To: <20210913180246.193388-1-jouni@codeaurora.org> From: Baochen Qiang <bqiang@codeaurora.org> There are MSDUs whose length are invalid. For example, attackers may inject on purpose truncated A-MSDUs with invalid MSDU length. Such MSDUs are marked with an err bit set in rx attention tlvs, so we can check and drop them. Tested-on: QCA6390 hw2.0 PCI WLAN.HST.1.0.1-01740-QCAHSTSWPLZ_V2_TO_X86-1 Tested-on: WCN6855 hw2.0 PCI WLAN.HSP.1.1-01720.1-QCAHSPSWPL_V1_V2_SILICONZ_LITE-1 Signed-off-by: Baochen Qiang <bqiang@codeaurora.org> Signed-off-by: Jouni Malinen <jouni@codeaurora.org> --- drivers/net/wireless/ath/ath11k/dp_rx.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c index 0c27eead3e02..c50f70913583 100644 --- a/drivers/net/wireless/ath/ath11k/dp_rx.c +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c @@ -142,6 +142,18 @@ static u32 ath11k_dp_rx_h_attn_mpdu_err(struct rx_attention *attn) return errmap; } +static bool ath11k_dp_rx_h_attn_msdu_len_err(struct ath11k_base *ab, + struct hal_rx_desc *desc) +{ + struct rx_attention *rx_attention; + u32 errmap; + + rx_attention = ath11k_dp_rx_get_attention(ab, desc); + errmap = ath11k_dp_rx_h_attn_mpdu_err(rx_attention); + + return errmap & DP_RX_MPDU_ERR_MSDU_LEN; +} + static u16 ath11k_dp_rx_h_msdu_start_msdu_len(struct ath11k_base *ab, struct hal_rx_desc *desc) { @@ -2525,6 +2537,12 @@ static int ath11k_dp_rx_process_msdu(struct ath11k *ar, } rx_desc = (struct hal_rx_desc *)msdu->data; + if (ath11k_dp_rx_h_attn_msdu_len_err(ab, rx_desc)) { + ath11k_warn(ar->ab, "msdu len not valid\n"); + ret = -EIO; + goto free_out; + } + lrx_desc = (struct hal_rx_desc *)last_buf->data; rx_attention = ath11k_dp_rx_get_attention(ab, lrx_desc); if (!ath11k_dp_rx_h_attn_msdu_done(rx_attention)) { -- 2.25.1 -- ath11k mailing list ath11k@lists.infradead.org http://lists.infradead.org/mailman/listinfo/ath11k
next prev parent reply other threads:[~2021-09-13 18:03 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-13 18:02 [PATCH 1/5] ath11k: Change DMA_FROM_DEVICE to DMA_TO_DEVICE when map reinjected packets Jouni Malinen 2021-09-13 18:02 ` Jouni Malinen 2021-09-13 18:02 ` Jouni Malinen [this message] 2021-09-13 18:02 ` [PATCH 2/5] ath11k: Drop MSDU with length error in DP rx path Jouni Malinen 2021-09-28 13:34 ` Kalle Valo 2021-09-28 13:34 ` Kalle Valo 2021-09-13 18:02 ` [PATCH 3/5] ath11k: Fix inaccessible debug registers Jouni Malinen 2021-09-13 18:02 ` Jouni Malinen 2021-09-13 18:02 ` [PATCH 4/5] ath11k: Fix memory leak in ath11k_qmi_driver_event_work Jouni Malinen 2021-09-13 18:02 ` Jouni Malinen 2021-09-13 18:02 ` [PATCH 5/5] ath11k: Handle MSI enablement during rmmod and SSR Jouni Malinen 2021-09-13 18:02 ` Jouni Malinen 2021-10-11 6:47 ` Kalle Valo 2021-10-11 6:47 ` Kalle Valo 2021-10-11 15:11 ` Kalle Valo 2021-10-11 15:11 ` Kalle Valo 2021-09-13 22:38 ` [PATCH 1/5] ath11k: Change DMA_FROM_DEVICE to DMA_TO_DEVICE when map reinjected packets Peter Oh 2021-09-13 22:38 ` Peter Oh 2021-09-14 17:09 ` Kalle Valo 2021-09-14 17:09 ` Kalle Valo
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=20210913180246.193388-2-jouni@codeaurora.org \ --to=jouni@codeaurora.org \ --cc=ath11k@lists.infradead.org \ --cc=bqiang@codeaurora.org \ --cc=kvalo@codeaurora.org \ --cc=linux-wireless@vger.kernel.org \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.