rt2x00: Fix double usage of skb->cb in USB RX path.

It is not safe to use the skb->cb area for both the rxd and
skb_frame_desc data at the same time, while they occupy an overlapping
piece of memory. This can lead to hard to trace crashes as pointers
within skb_frame_desc are pointing into nowhere, or the rxd data is
overwritten with non-sense.

Fix it by copying the rxd to a small buffer on the stack.

Signed-off-by: Gertjan van Wingerde <gwingerde@kpnplanet.nl>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
Gertjan van Wingerde
2008-06-06 22:54:28 +02:00
committed by John W. Linville
parent 239c249d06
commit a26cbc6508
3 changed files with 9 additions and 19 deletions

View File

@@ -1156,14 +1156,10 @@ static void rt2500usb_fill_rxdone(struct queue_entry *entry,
u32 word1;
/*
* Copy descriptor to the skb->cb array, this has 2 benefits:
* 1) Each descriptor word is 4 byte aligned.
* 2) Descriptor is safe from moving of frame data in rt2x00usb.
* Copy descriptor to the skbdesc->desc buffer, making it safe from moving of
* frame data in rt2x00usb.
*/
skbdesc->desc_len =
min_t(u16, entry->queue->desc_size, sizeof(entry->skb->cb));
memcpy(entry->skb->cb, rxd, skbdesc->desc_len);
skbdesc->desc = entry->skb->cb;
memcpy(skbdesc->desc, rxd, skbdesc->desc_len);
rxd = (__le32 *)skbdesc->desc;
/*