From: Vladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>
To: "John W . Linville" <linville@tuxdriver.com>
Cc: Vladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>,
<linux-wireless@vger.kernel.org>,
"Luis R . Rodriguez" <rodrigue@qca.qualcomm.com>
Subject: [PATCH 2/7] wil6210: Sanity check for reported DMA length
Date: Sun, 12 May 2013 14:43:33 +0300 [thread overview]
Message-ID: <1368359018-20870-3-git-send-email-qca_vkondrat@qca.qualcomm.com> (raw)
In-Reply-To: <1368359018-20870-1-git-send-email-qca_vkondrat@qca.qualcomm.com>
If Rx descriptor contains garbage, it is possible to access memory beyond
allocated buffer.
Check this condition and drop Rx if reported length is
unreasonable large
Signed-off-by: Vladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>
---
drivers/net/wireless/ath/wil6210/txrx.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/ath/wil6210/txrx.c b/drivers/net/wireless/ath/wil6210/txrx.c
index b9cac7d..6506b76 100644
--- a/drivers/net/wireless/ath/wil6210/txrx.c
+++ b/drivers/net/wireless/ath/wil6210/txrx.c
@@ -351,7 +351,13 @@ static struct sk_buff *wil_vring_reap_rx(struct wil6210_priv *wil,
d1 = wil_skb_rxdesc(skb);
*d1 = *d;
+ wil_vring_advance_head(vring, 1);
dmalen = le16_to_cpu(d1->dma.length);
+ if (dmalen > sz) {
+ wil_err(wil, "Rx size too large: %d bytes!\n", dmalen);
+ kfree(skb);
+ return NULL;
+ }
skb_trim(skb, dmalen);
wil->stats.last_mcs_rx = wil_rxdesc_mcs(d1);
@@ -364,8 +370,6 @@ static struct sk_buff *wil_vring_reap_rx(struct wil6210_priv *wil,
wil_hex_dump_txrx("Rx ", DUMP_PREFIX_NONE, 32, 4,
(const void *)d, sizeof(*d), false);
- wil_vring_advance_head(vring, 1);
-
/* no extra checks if in sniffer mode */
if (ndev->type != ARPHRD_ETHER)
return skb;
--
1.8.1.2
next prev parent reply other threads:[~2013-05-12 11:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-12 11:43 [PATCH 0/7] wil6210 patches Vladimir Kondratiev
2013-05-12 11:43 ` [PATCH 1/7] wil6210: 'length' in Tx/Rx descriptors is little endian Vladimir Kondratiev
2013-05-12 11:43 ` Vladimir Kondratiev [this message]
2013-05-12 11:43 ` [PATCH 3/7] wil6210: debug dump packet content right after DMA Vladimir Kondratiev
2013-05-12 11:43 ` [PATCH 4/7] wil6210: trace support Vladimir Kondratiev
2013-05-12 11:43 ` [PATCH 5/7] wil6210: use NAPI Vladimir Kondratiev
2013-05-12 11:43 ` [PATCH 6/7] wil6210: fix remaining use of non-cached copy of tx/rx descriptors Vladimir Kondratiev
2013-05-12 11:43 ` [PATCH 7/7] wil6210: do not stop Tx queue on packet drop Vladimir Kondratiev
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=1368359018-20870-3-git-send-email-qca_vkondrat@qca.qualcomm.com \
--to=qca_vkondrat@qca.qualcomm.com \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=rodrigue@qca.qualcomm.com \
/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