Skip to content

Commit

Permalink
asix: Add rx->ax_skb = NULL after usbnet_skb_return()
Browse files Browse the repository at this point in the history
In asix_rx_fixup_internal() there is a risk that rx->ax_skb gets
reused after passing the Ethernet frame into the network stack via
usbnet_skb_return().

The risks include:

a) asynchronously freeing rx->ax_skb after passing the netdev buffer
   to the NAPI layer which might corrupt the backlog queue.

b) erroneously reusing rx->ax_skb such as calling skb_put_data() multiple
   times which causes writing off the end of the netdev buffer.

Therefore add a defensive rx->ax_skb = NULL after usbnet_skb_return()
so that it is not possible to free rx->ax_skb or to apply
skb_put_data() too many times.

Signed-off-by: Dean Jenkins <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Dean Jenkins authored and davem330 committed Aug 7, 2017
1 parent f9ea322 commit 22889db
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/net/usb/asix_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb,
if (rx->ax_skb) {
skb_put_data(rx->ax_skb, skb->data + offset,
copy_length);
if (!rx->remaining)
if (!rx->remaining) {
usbnet_skb_return(dev, rx->ax_skb);
rx->ax_skb = NULL;
}
}

offset += (copy_length + 1) & 0xfffe;
Expand Down

0 comments on commit 22889db

Please sign in to comment.