aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDean Jenkins <Dean_Jenkins@mentor.com>2017-08-07 04:50:14 -0400
committerDavid S. Miller <davem@davemloft.net>2017-08-07 13:10:19 -0400
commit22889dbbd98a0e3390e9120074c39c6e5a3fea5e (patch)
treec39bb8673bb205b0a073a33f29d3fbcca4a890ef /drivers
parentf9ea3225ddafa269cf1f6b495d132c26fde93903 (diff)
asix: Add rx->ax_skb = NULL after usbnet_skb_return()
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 <Dean_Jenkins@mentor.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/usb/asix_common.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
index 7847436c441e..6983b6bd8cf9 100644
--- a/drivers/net/usb/asix_common.c
+++ b/drivers/net/usb/asix_common.c
@@ -168,8 +168,10 @@ int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb,
168 if (rx->ax_skb) { 168 if (rx->ax_skb) {
169 skb_put_data(rx->ax_skb, skb->data + offset, 169 skb_put_data(rx->ax_skb, skb->data + offset,
170 copy_length); 170 copy_length);
171 if (!rx->remaining) 171 if (!rx->remaining) {
172 usbnet_skb_return(dev, rx->ax_skb); 172 usbnet_skb_return(dev, rx->ax_skb);
173 rx->ax_skb = NULL;
174 }
173 } 175 }
174 176
175 offset += (copy_length + 1) & 0xfffe; 177 offset += (copy_length + 1) & 0xfffe;