ath9k: fix stack-out-of-bounds Write in ath9k_hif_usb_rx_cb
Subsystems (3)
PATCH 1/1 ath9k: fix stack-out-of-bounds Write in ath9k_hif_usb_rx_cb
Add barrier to accessing the stack array skb_pool.
--- drivers/net/wireless/ath/ath9k/hif_usb.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/ath/ath9k/hif_usb.c +5 -0
@@ -612,6 +612,11 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev, hif_dev->remain_skb = nskb;spin_unlock (&hif_dev->rx_lock); }else { +if (pool_index ==MAX_PKT_NUM_IN_TRANSFER ) { +dev_err (&hif_dev->udev->dev, +"ath9k_htc: over RX MAX_PKT_NUM\n" ); + goto err; + } nskb =__dev_alloc_skb (pkt_len +32 ,GFP_ATOMIC );if (!nskb) { dev_err(&hif_dev->udev->dev,
Signature · 1 line
1.8.3.1
Quoted 13 lines · Qiujun Huang
Add barrier to accessing the stack array
skb_pool.Reported-by [email protected]Signed-off-by Qiujun Huang <[email protected]>--- drivers/net/wireless/ath/ath9k/hif_usb.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/wireless/ath/ath9k/hif_usb.c +0
-0
drivers/net/wireless/ath/ath9k/hif_usb.c static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev, · line 619
Quoted 8 lines
drivers/net/wireless/ath/ath9k/hif_usb.c +5
-0@@ -612,6 +612,11 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev, hif_dev->remain_skb = nskb;spin_unlock (&hif_dev->rx_lock); }else { +if (pool_index ==MAX_PKT_NUM_IN_TRANSFER ) { +dev_err (&hif_dev->udev->dev, +"ath9k_htc: over RX MAX_PKT_NUM\n" ); + goto err; + }
What about 'pool_index >= MAX_PKT_NUM_IN_TRANSFER' just to be on the safe side? Ah, but then error handling won't work:
err:
for (i = 0; i < pool_index; i++) {
RX_STAT_ADD(skb_completed_bytes, skb_pool[i]->len);
ath9k_htc_rx_msg(hif_dev->htc_handle, skb_pool[i],
skb_pool[i]->len, USB_WLAN_RX_PIPE);
RX_STAT_INC(skb_completed);
}Maybe that should use 'min(pool_index, MAX_PKT_NUM_IN_TRANSFER - 1)' or something? Or maybe it's just overengineerin, dunno.
Signature · 1 line
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Quoted 11 lines · Kalle Valo
Quoted 8 lines · Qiujun Huang
Add barrier to accessing the stack array
skb_pool.Reported-by [email protected]Signed-off-by Qiujun Huang <[email protected]>--- drivers/net/wireless/ath/ath9k/hif_usb.c | 5 +++++ 1 file changed, 5 insertions(+)
Quoted 16 lines
drivers/net/wireless/ath/ath9k/hif_usb.c static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev, · line 619
Quoted 13 lines
drivers/net/wireless/ath/ath9k/hif_usb.c +5
-0@@ -612,6 +612,11 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev, hif_dev->remain_skb = nskb;spin_unlock (&hif_dev->rx_lock); }else { +if (pool_index ==MAX_PKT_NUM_IN_TRANSFER ) { +dev_err (&hif_dev->udev->dev, +"ath9k_htc: over RX MAX_PKT_NUM\n" ); + goto err; + }What about '
pool_index>=MAX_PKT_NUM_IN_TRANSFER' just to be on the safe side? Ah, but then error handling won't work:
Get that.
Quoted 11 lines
err:
for (i = 0; i < pool_index; i++) { RX_STAT_ADD(skb_completed_bytes, skb_pool[i]->len); ath9k_htc_rx_msg(hif_dev->htc_handle, skb_pool[i], skb_pool[i]->len, USB_WLAN_RX_PIPE); RX_STAT_INC(skb_completed); }Maybe that should use '
min(pool_index, MAX_PKT_NUM_IN_TRANSFER - 1)' or something? Or maybe it's just overengineerin, dunno.
I will take a deeper look, thanks.
Quoted 11 lines · Kalle Valo
Quoted 8 lines · Qiujun Huang
Add barrier to accessing the stack array
skb_pool.Reported-by [email protected]Signed-off-by Qiujun Huang <[email protected]>--- drivers/net/wireless/ath/ath9k/hif_usb.c | 5 +++++ 1 file changed, 5 insertions(+)
Quoted 12 lines
drivers/net/wireless/ath/ath9k/hif_usb.c static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev, · line 618
Quoted 12 lines
drivers/net/wireless/ath/ath9k/hif_usb.c +4
-0@@ -612,6 +612,11 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev, hif_dev->remain_skb = nskb;spin_unlock (&hif_dev->rx_lock); }else { +if (pool_index ==MAX_PKT_NUM_IN_TRANSFER ) { +dev_err (&hif_dev->udev->dev, +"ath9k_htc: over RX MAX_PKT_NUM\n" ); + goto err;
the barrier ensure pool_index <= MAX_PKT_NUM_IN_TRANSFER
Quoted 4 lines
drivers/net/wireless/ath/ath9k/hif_usb.c static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev, · line 619
Quoted 1 line
drivers/net/wireless/ath/ath9k/hif_usb.c +1
-0+ }What about '
pool_index>=MAX_PKT_NUM_IN_TRANSFER' just to be on the safe side? Ah, but then error handling won't work:
It looks ok?
it can handle the case: pool_index == MAX_PKT_NUM_IN_TRANSFER
Quoted 14 lines
err:
for (i = 0; i < pool_index; i++) { RX_STAT_ADD(skb_completed_bytes, skb_pool[i]->len); ath9k_htc_rx_msg(hif_dev->htc_handle, skb_pool[i], skb_pool[i]->len, USB_WLAN_RX_PIPE); RX_STAT_INC(skb_completed); }Maybe that should use '
min(pool_index, MAX_PKT_NUM_IN_TRANSFER - 1)' or something? Or maybe it's just overengineerin, dunno.--
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches