From: Kalle Valo <kvalo@codeaurora.org>
To: Qiujun Huang <hqjagain@gmail.com>
Cc: ath9k-devel@qca.qualcomm.com, davem@davemloft.net,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, anenbupt@gmail.com
Subject: Re: [PATCH] ath9k: fix stack-out-of-bounds Write in ath9k_hif_usb_rx_cb
Date: Tue, 31 Mar 2020 14:03:22 +0300 [thread overview]
Message-ID: <87bloc23d1.fsf@kamboji.qca.qualcomm.com> (raw)
In-Reply-To: <1585625296-31013-1-git-send-email-hqjagain@gmail.com> (Qiujun Huang's message of "Tue, 31 Mar 2020 11:28:16 +0800")
Qiujun Huang <hqjagain@gmail.com> writes:
> Add barrier to accessing the stack array skb_pool.
>
> Reported-by: syzbot+d403396d4df67ad0bd5f@syzkaller.appspotmail.com
> Signed-off-by: Qiujun Huang <hqjagain@gmail.com>
> ---
> drivers/net/wireless/ath/ath9k/hif_usb.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
> index dd0c323..c4a2b72 100644
> --- a/drivers/net/wireless/ath/ath9k/hif_usb.c
> +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
> @@ -612,6 +612,11 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev,
> hif_dev->remain_skb = nskb;
> spin_unlock(&hif_dev->rx_lock);
> } else {
> + if (pool_index == MAX_PKT_NUM_IN_TRANSFER) {
> + dev_err(&hif_dev->udev->dev,
> + "ath9k_htc: over RX MAX_PKT_NUM\n");
> + goto err;
> + }
What about 'pool_index >= MAX_PKT_NUM_IN_TRANSFER' just to be on the
safe side? Ah, but then error handling won't work:
err:
for (i = 0; i < pool_index; i++) {
RX_STAT_ADD(skb_completed_bytes, skb_pool[i]->len);
ath9k_htc_rx_msg(hif_dev->htc_handle, skb_pool[i],
skb_pool[i]->len, USB_WLAN_RX_PIPE);
RX_STAT_INC(skb_completed);
}
Maybe that should use 'min(pool_index, MAX_PKT_NUM_IN_TRANSFER - 1)' or
something? Or maybe it's just overengineerin, dunno.
--
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
next prev parent reply other threads:[~2020-03-31 11:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-31 3:28 [PATCH] ath9k: fix stack-out-of-bounds Write in ath9k_hif_usb_rx_cb Qiujun Huang
2020-03-31 11:03 ` Kalle Valo [this message]
2020-03-31 11:21 ` Qiujun Huang
2020-03-31 11:39 ` Qiujun Huang
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=87bloc23d1.fsf@kamboji.qca.qualcomm.com \
--to=kvalo@codeaurora.org \
--cc=anenbupt@gmail.com \
--cc=ath9k-devel@qca.qualcomm.com \
--cc=davem@davemloft.net \
--cc=hqjagain@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).