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/rt2800pci.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/rt2800pci.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800pci.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c index 72e4f29a2fc7..db61a78e32b0 100644 --- a/drivers/net/wireless/rt2x00/rt2800pci.c +++ b/drivers/net/wireless/rt2x00/rt2800pci.c | |||
@@ -616,7 +616,7 @@ static int rt2800pci_set_device_state(struct rt2x00_dev *rt2x00dev, | |||
616 | static void rt2800pci_write_tx_datadesc(struct queue_entry* entry, | 616 | static void rt2800pci_write_tx_datadesc(struct queue_entry* entry, |
617 | struct txentry_desc *txdesc) | 617 | struct txentry_desc *txdesc) |
618 | { | 618 | { |
619 | rt2800_write_txwi(entry->skb, txdesc); | 619 | rt2800_write_txwi((__le32 *) entry->skb->data, txdesc); |
620 | } | 620 | } |
621 | 621 | ||
622 | 622 | ||
@@ -693,15 +693,22 @@ static void rt2800pci_write_beacon(struct queue_entry *entry, | |||
693 | rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg); | 693 | rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg); |
694 | 694 | ||
695 | /* | 695 | /* |
696 | * Add space for the TXWI in front of the skb. | ||
697 | */ | ||
698 | skb_push(entry->skb, TXWI_DESC_SIZE); | ||
699 | memset(entry->skb, 0, TXWI_DESC_SIZE); | ||
700 | |||
701 | /* | ||
696 | * Register descriptor details in skb frame descriptor. | 702 | * Register descriptor details in skb frame descriptor. |
697 | */ | 703 | */ |
698 | skbdesc->desc = entry->skb->data - TXWI_DESC_SIZE; | 704 | skbdesc->flags |= SKBDESC_DESC_IN_SKB; |
705 | skbdesc->desc = entry->skb->data; | ||
699 | skbdesc->desc_len = TXWI_DESC_SIZE; | 706 | skbdesc->desc_len = TXWI_DESC_SIZE; |
700 | 707 | ||
701 | /* | 708 | /* |
702 | * Add the TXWI for the beacon to the skb. | 709 | * Add the TXWI for the beacon to the skb. |
703 | */ | 710 | */ |
704 | rt2800_write_txwi(entry->skb, txdesc); | 711 | rt2800_write_txwi((__le32 *)entry->skb->data, txdesc); |
705 | 712 | ||
706 | /* | 713 | /* |
707 | * Dump beacon to userspace through debugfs. | 714 | * Dump beacon to userspace through debugfs. |
@@ -709,11 +716,6 @@ static void rt2800pci_write_beacon(struct queue_entry *entry, | |||
709 | rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry->skb); | 716 | rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_BEACON, entry->skb); |
710 | 717 | ||
711 | /* | 718 | /* |
712 | * Adjust skb to take TXWI into account. | ||
713 | */ | ||
714 | skb_push(entry->skb, TXWI_DESC_SIZE); | ||
715 | |||
716 | /* | ||
717 | * Write entire beacon with TXWI to register. | 719 | * Write entire beacon with TXWI to register. |
718 | */ | 720 | */ |
719 | beacon_base = HW_BEACON_OFFSET(entry->entry_idx); | 721 | beacon_base = HW_BEACON_OFFSET(entry->entry_idx); |
@@ -888,8 +890,7 @@ static void rt2800pci_txdone(struct rt2x00_dev *rt2x00dev) | |||
888 | 890 | ||
889 | /* Check if we got a match by looking at WCID/ACK/PID | 891 | /* Check if we got a match by looking at WCID/ACK/PID |
890 | * fields */ | 892 | * fields */ |
891 | txwi = (__le32 *)(entry->skb->data - | 893 | txwi = (__le32 *) entry->skb->data; |
892 | rt2x00dev->ops->extra_tx_headroom); | ||
893 | 894 | ||
894 | rt2x00_desc_read(txwi, 1, &word); | 895 | rt2x00_desc_read(txwi, 1, &word); |
895 | tx_wcid = rt2x00_get_field32(word, TXWI_W1_WIRELESS_CLI_ID); | 896 | tx_wcid = rt2x00_get_field32(word, TXWI_W1_WIRELESS_CLI_ID); |
@@ -934,7 +935,7 @@ static void rt2800pci_txdone(struct rt2x00_dev *rt2x00dev) | |||
934 | __set_bit(TXDONE_FALLBACK, &txdesc.flags); | 935 | __set_bit(TXDONE_FALLBACK, &txdesc.flags); |
935 | 936 | ||
936 | 937 | ||
937 | rt2x00lib_txdone(entry, &txdesc); | 938 | rt2x00pci_txdone(entry, &txdesc); |
938 | } | 939 | } |
939 | } | 940 | } |
940 | 941 | ||