From: Kalle Valo <kvalo@codeaurora.org>
To: Phillip Potter <phil@philpotter.co.uk>
Cc: davem@davemloft.net, kuba@kernel.org,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, ath9k-devel@qca.qualcomm.com,
fw@strlen.de
Subject: Re: [PATCH v2] ath9k: ath9k_htc_rx_msg: return when sk_buff is too small
Date: Sun, 30 May 2021 12:00:53 +0300 [thread overview]
Message-ID: <87fsy4ppdm.fsf@codeaurora.org> (raw)
In-Reply-To: <20210502212611.1818-1-phil@philpotter.co.uk> (Phillip Potter's message of "Sun, 2 May 2021 22:26:11 +0100")
Phillip Potter <phil@philpotter.co.uk> writes:
> 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;
> + }
This does not look complete to me, I think the function is missing
proper length checks. For example, with ENDPOINT0 it reads two byte
msg_id after the htc header and it's not verified that skb really has
that. I did not check if ep_callbacks.rx handlers have proper length
handling, I recommend verifying that also while fixing this.
Also I want to point out that the skb is freed differently based on
endpoint, I did not check why and don't know if it causes:
if (epid < 0 || epid >= ENDPOINT_MAX) {
if (pipe_id != USB_REG_IN_PIPE)
dev_kfree_skb_any(skb);
else
kfree_skb(skb);
return;
}
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
prev parent reply other threads:[~2021-05-30 9:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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=87fsy4ppdm.fsf@codeaurora.org \
--to=kvalo@codeaurora.org \
--cc=ath9k-devel@qca.qualcomm.com \
--cc=davem@davemloft.net \
--cc=fw@strlen.de \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=phil@philpotter.co.uk \
/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: link
Be 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.