Netdev Archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] ath9k: ath9k_htc_rx_msg: return when sk_buff is too small
@ 2021-05-02 21:26 Phillip Potter
  2021-05-30  9:00 ` Kalle Valo
  0 siblings, 1 reply; 2+ messages in thread
From: Phillip Potter @ 2021-05-02 21:26 UTC (permalink / raw
  To: kvalo; +Cc: davem, kuba, linux-wireless, netdev, linux-kernel, ath9k-devel,
	fw

At the start of ath9k_htc_rx_msg, we check to see if the skb pointer is
valid, but what we don't do is check if it is large enough to contain a
valid struct htc_frame_hdr. We should check for this and return if not,
as the buffer is invalid in this case. Fixes a KMSAN-found uninit-value bug
reported by syzbot at:
https://syzkaller.appspot.com/bug?id=7dccb7d9ad4251df1c49f370607a49e1f09644ee

Reported-by: syzbot+e4534e8c1c382508312c@syzkaller.appspotmail.com
Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---

V2:
* Free skb properly when this problem is detected, as pointed out by
  Florian Westphal.

---
 drivers/net/wireless/ath/ath9k/htc_hst.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c
index 510e61e97dbc..1fe89b068ac4 100644
--- a/drivers/net/wireless/ath/ath9k/htc_hst.c
+++ b/drivers/net/wireless/ath/ath9k/htc_hst.c
@@ -406,6 +406,11 @@ void ath9k_htc_rx_msg(struct htc_target *htc_handle,
 	if (!htc_handle || !skb)
 		return;
 
+	if (!pskb_may_pull(skb, sizeof(struct htc_frame_hdr))) {
+		kfree_skb(skb);
+		return;
+	}
+
 	htc_hdr = (struct htc_frame_hdr *) skb->data;
 	epid = htc_hdr->endpoint_id;
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-30  9:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-02 21:26 [PATCH v2] ath9k: ath9k_htc_rx_msg: return when sk_buff is too small Phillip Potter
2021-05-30  9:00 ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).