Commit efd5d6b0 authored by Sergei Poselenov's avatar Sergei Poselenov Committed by John W. Linville

rt2800usb: Added rx packet length validity check

On our system (ARM Cortex-M3 SOC running linux-2.6.33)
frequent crashes were observed in the rt2800usb module
because of the invalid length of the received packet (3392,
46920...). This patch adds the sanity check on the packet
legth. Also, changed WARNING to ERROR in rt2x00lib_rxdone()
so that the bad packet condition would be noticed.

The fix was tested on the latest compat-wireless-3.5.1-1-snpc.

Cc: stable@vger.kernel.org
Signed-off-by: default avatarSergei Poselenov <sposelenov@emcraft.com>
Acked-by: default avatarIvo van Doorn <IvDoorn@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent a396e100
...@@ -667,8 +667,16 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry, ...@@ -667,8 +667,16 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry,
skb_pull(entry->skb, RXINFO_DESC_SIZE); skb_pull(entry->skb, RXINFO_DESC_SIZE);
/* /*
* FIXME: we need to check for rx_pkt_len validity * Check for rx_pkt_len validity. Return if invalid, leaving
* rxdesc->size zeroed out by the upper level.
*/ */
if (unlikely(rx_pkt_len == 0 ||
rx_pkt_len > entry->queue->data_size)) {
ERROR(entry->queue->rt2x00dev,
"Bad frame size %d, forcing to 0\n", rx_pkt_len);
return;
}
rxd = (__le32 *)(entry->skb->data + rx_pkt_len); rxd = (__le32 *)(entry->skb->data + rx_pkt_len);
/* /*
......
...@@ -629,7 +629,7 @@ void rt2x00lib_rxdone(struct queue_entry *entry, gfp_t gfp) ...@@ -629,7 +629,7 @@ void rt2x00lib_rxdone(struct queue_entry *entry, gfp_t gfp)
*/ */
if (unlikely(rxdesc.size == 0 || if (unlikely(rxdesc.size == 0 ||
rxdesc.size > entry->queue->data_size)) { rxdesc.size > entry->queue->data_size)) {
WARNING(rt2x00dev, "Wrong frame size %d max %d.\n", ERROR(rt2x00dev, "Wrong frame size %d max %d.\n",
rxdesc.size, entry->queue->data_size); rxdesc.size, entry->queue->data_size);
dev_kfree_skb(entry->skb); dev_kfree_skb(entry->skb);
goto renew_skb; goto renew_skb;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment