Skip to contentSkip to conversation

ath9k: Fix potential out of bounds in ath9k_htc_txcompletion_cb()

PATCH In review Dan Carpenter 2 participants 2 messages Aug 13, 2020 – Aug 17, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath9k: Fix potential out of bounds in ath9k_htc_txcompletion_cb()

The value of "htc_hdr->endpoint_id" comes from skb->data so Smatch marks it as untrusted so we have to check it before using it as an array offset.

This is similar to a bug that syzkaller found in commit e4ff08a4d727 ("ath9k: Fix use-after-free Write in ath9k_htc_rx_msg") so it is probably a real issue.

Fixes fb9987d0f748 ("ath9k_htc: Support for AR9271 chipset.")
---
 drivers/net/wireless/ath/ath9k/htc_hst.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/wireless/ath/ath9k/htc_hst.c +2 -0
index d2e062eaf561..510e61e97dbc 100644
@@ -339,6 +339,8 @@ void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle,
 
 	if (skb) {
 		htc_hdr = (struct htc_frame_hdr *) skb->data;
+		if (htc_hdr->endpoint_id >= ARRAY_SIZE(htc_handle->endpoint))
+			goto ret;
 		endpoint = &htc_handle->endpoint[htc_hdr->endpoint_id];
 		skb_pull(skb, sizeof(struct htc_frame_hdr));
 
Signature · 1 line
2.28.0
#1 lore raw
Quoted 11 lines · Dan Carpenter

The value of "htc_hdr->endpoint_id" comes from skb->data so Smatch marks it as untrusted so we have to check it before using it as an array offset.

This is similar to a bug that syzkaller found in commit e4ff08a4d727 ("ath9k: Fix use-after-free Write in ath9k_htc_rx_msg") so it is probably a real issue.

Fixes fb9987d0f748 ("ath9k_htc: Support for AR9271 chipset.")

Patch applied to ath-next branch of ath.git, thanks.

2705cd7558e7 ath9k: Fix potential out of bounds in ath9k_htc_txcompletion_cb()

Signature · 3 lines
https://patchwork.kernel.org/patch/11712553/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches