diff options
author | Gertjan van Wingerde <gwingerde@gmail.com> | 2010-06-03 04:51:45 -0400 |
---|---|---|
committer | Ivo van Doorn <IvDoorn@gmail.com> | 2010-06-03 04:51:45 -0400 |
commit | 0b8004aa12d13ec750d102ba4082a95f0107c649 (patch) | |
tree | eac5224159d34ae525b552254816c3a1e056336c /drivers/net/wireless/rt2x00/rt2800usb.c | |
parent | baaffe67b5b33e4215409669226ef623cb65e15c (diff) |
rt2x00: Properly reserve room for descriptors in skbs.
Instead of fiddling with the skb->data pointer and thereby risking
out of bounds accesses, properly reserve the space needed in an
skb for descriptors.
Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2800usb.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800usb.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index d0d8060040ba..ee407f138753 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c | |||
@@ -400,13 +400,14 @@ static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
400 | struct txentry_desc *txdesc) | 400 | struct txentry_desc *txdesc) |
401 | { | 401 | { |
402 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); | 402 | struct skb_frame_desc *skbdesc = get_skb_frame_desc(skb); |
403 | __le32 *txi = (__le32 *)(skb->data - TXWI_DESC_SIZE - TXINFO_DESC_SIZE); | 403 | __le32 *txi = (__le32 *) skb->data; |
404 | __le32 *txwi = (__le32 *) (skb->data + TXINFO_DESC_SIZE); | ||
404 | u32 word; | 405 | u32 word; |
405 | 406 | ||
406 | /* | 407 | /* |
407 | * Initialize TXWI descriptor | 408 | * Initialize TXWI descriptor |
408 | */ | 409 | */ |
409 | rt2800_write_txwi(skb, txdesc); | 410 | rt2800_write_txwi(txwi, txdesc); |
410 | 411 | ||
411 | /* | 412 | /* |
412 | * Initialize TXINFO descriptor | 413 | * Initialize TXINFO descriptor |
@@ -426,6 +427,7 @@ static void rt2800usb_write_tx_desc(struct rt2x00_dev *rt2x00dev, | |||
426 | /* | 427 | /* |
427 | * Register descriptor details in skb frame descriptor. | 428 | * Register descriptor details in skb frame descriptor. |
428 | */ | 429 | */ |
430 | skbdesc->flags |= SKBDESC_DESC_IN_SKB; | ||
429 | skbdesc->desc = txi; | 431 | skbdesc->desc = txi; |
430 | skbdesc->desc_len = TXINFO_DESC_SIZE + TXWI_DESC_SIZE; | 432 | skbdesc->desc_len = TXINFO_DESC_SIZE + TXWI_DESC_SIZE; |
431 | } | 433 | } |
@@ -450,15 +452,22 @@ static void rt2800usb_write_beacon(struct queue_entry *entry, | |||
450 | rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg); | 452 | rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg); |
451 | 453 | ||
452 | /* | 454 | /* |
455 | * Add space for the TXWI in front of the skb. | ||
456 | */ | ||
457 | skb_push(entry->skb, TXWI_DESC_SIZE); | ||
458 | memset(entry->skb, 0, TXWI_DESC_SIZE); | ||
459 | |||
460 | /* | ||
453 | * Register descriptor details in skb frame descriptor. | 461 | * Register descriptor details in skb frame descriptor. |
454 | */ | 462 | */ |
455 | skbdesc->desc = entry->skb->data - TXWI_DESC_SIZE; | 463 | skbdesc->flags |= SKBDESC_DESC_IN_SKB; |
464 | skbdesc->desc = entry->skb->data; | ||
456 | skbdesc->desc_len = TXWI_DESC_SIZE; | 465 | skbdesc->desc_len = TXWI_DESC_SIZE; |
457 | 466 | ||
458 | /* | 467 | /* |
459 | * Add the TXWI for the beacon to the skb. | 468 | * Add the TXWI for the beacon to the skb. |
460 | */ | 469 | */ |
461 | rt2800_write_txwi(entry->skb, txdesc); | 470 | rt2800_write_txwi((__le32 *) entry->skb->data, txdesc); |
462 | 471 | ||
463 | /* | 472 | /* |
464 | * Dump beacon to userspace through debugfs. | 473 | * Dump beacon to userspace through debugfs. |
@@ -466,11 +475,6 @@ static void rt2800usb_write_beacon(struct queue_entry *entry, | |||
466 | rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry->skb); | 475 | rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry->skb); |
467 | 476 | ||
468 | /* | 477 | /* |
469 | * Adjust skb to take TXWI into account. | ||
470 | */ | ||
471 | skb_push(entry->skb, TXWI_DESC_SIZE); | ||
472 | |||
473 | /* | ||
474 | * Write entire beacon with descriptor to register. | 478 | * Write entire beacon with descriptor to register. |
475 | */ | 479 | */ |
476 | beacon_base = HW_BEACON_OFFSET(entry->entry_idx); | 480 | beacon_base = HW_BEACON_OFFSET(entry->entry_idx); |