usbnet: fix oops in usbnet_start_xmit
PATCH 1/1 usbnet: fix oops in usbnet_start_xmit
This patch fixes the bug added in commit v3.1-rc7-1055-gf9b491e SKB can be NULL at this point, at least for cdc-ncm. Let's call skb_tx_timestamp() after driver specific tx-fixup hacks.
--- drivers/net/usb/usbnet.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/usb/usbnet.c +2 -2
@@ -1057,8 +1057,6 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,unsigned long flags;int retval; -skb_tx_timestamp (skb); -// some devices want funky USB-level framing, for // win32 driver (usually) and/or hardware quirks if (info->tx_fixup) {
@@ -1075,6 +1073,8 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb, } length = skb->len; +skb_tx_timestamp (skb); +if (!(urb =usb_alloc_urb (0 ,GFP_ATOMIC ))) {netif_dbg (dev, tx_err, dev->net,"no urb\n" ); goto drop;
Quoted 2 lines · Konstantin Khlebnikov
This patch fixes the bug added in commit v3.1-rc7-1055-gf9b491e SKB can be NULL at this point, at least for cdc-ncm.
What? You mean .ndo_start_xmit is called with skb NULL?
Quoted 1 line
Let's call
skb_tx_timestamp()after driver specific tx-fixup hacks.
No, that won't work.
That call is before the fixup on purpose, because some fixups add padding in front of the Ethernet payload, and this will spoil the PTP packet detection filter.
I don't know why the skb can be NULL here. If that is really the case, then the correct fix is:
if (skb) skb_tx_timestamp(skb);
Thanks,
Richard
Quoted 33 lines
Signed-off-by Konstantin Khlebnikov <[email protected]>--- drivers/net/usb/usbnet.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/net/usb/usbnet.c +2
-3@@ -1057,8 +1057,6 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,unsigned long flags;int retval; -skb_tx_timestamp (skb); -// some devices want funky USB-level framing, for // win32 driver (usually) and/or hardware quirks if (info->tx_fixup) {@@ -1075,6 +1073,8 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb, } length = skb->len; +skb_tx_timestamp (skb); +if (!(urb =usb_alloc_urb (0 ,GFP_ATOMIC ))) {netif_dbg (dev, tx_err, dev->net,"no urb\n" ); goto drop; --To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 2 lines · Konstantin Khlebnikov
This patch fixes the bug added in commit v3.1-rc7-1055-gf9b491e SKB can be NULL at this point, at least for cdc-ncm.
OK, I didn't think of that, but...
Quoted 1 line
Let's call
skb_tx_timestamp()after driver specific tx-fixup hacks.
... the reason I put the skb_tx_timestamp() call before the tx_fixup is that these hacks often perform skb_push/skb_pull or any other kind of framing. This may result (at least in the case of the asix drivers) in perfectly correct PTP packets being not recognized as such by the packet filter.
Can we do a check like this:
if(skb) skb_tx_timestamp() tx_fixup()
?
Regards, Michael
Quoted 5 lines · Richard Cochran
Quoted 2 lines · Konstantin Khlebnikov
This patch fixes the bug added in commit v3.1-rc7-1055-gf9b491e SKB can be NULL at this point, at least for cdc-ncm.
What? You mean .ndo_start_xmit is called with skb NULL?
no. cdc_ncm call usbnet_start_xmit with NULL skb from timer handler and tx_fixup hook pickup skb from internal context. yeah, it really messy.
Quoted 52 lines
Quoted 2 lines
Let's call
skb_tx_timestamp()after driver specific tx-fixup hacks.No, that won't work.
That call is before the fixup on purpose, because some fixups add padding in front of the Ethernet payload, and this will spoil the PTP packet detection filter.
I don't know why the skb can be NULL here. If that is really the case, then the correct fix is:
if (skb) skb_tx_timestamp(skb);Thanks,
RichardQuoted 33 lines
Signed-off-by Konstantin Khlebnikov<[email protected]>--- drivers/net/usb/usbnet.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/net/usb/usbnet.c +2
-3@@ -1057,8 +1057,6 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,unsigned long flags;int retval; -skb_tx_timestamp (skb); -// some devices want funky USB-level framing, for // win32 driver (usually) and/or hardware quirks if (info->tx_fixup) {@@ -1075,6 +1073,8 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb, } length = skb->len; +skb_tx_timestamp (skb); +if (!(urb =usb_alloc_urb (0 ,GFP_ATOMIC ))) {netif_dbg (dev, tx_err, dev->net,"no urb\n" ); goto drop; --To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · Konstantin Khlebnikov
Quoted 5 lines · Richard Cochran
Quoted 2 lines · Konstantin Khlebnikov
This patch fixes the bug added in commit v3.1-rc7-1055-gf9b491e SKB can be NULL at this point, at least for cdc-ncm.
What? You mean .ndo_start_xmit is called with skb NULL?
no.
cdc_ncmcallusbnet_start_xmitwith NULL skb from timer handler andtx_fixuphook pickup skb from internal context. yeah, it really messy.
You said it.
Can you please submit the fix suggested by Michael and myself?
Thanks,
Richard
PATCH v2 1/1 usbnet: fix oops in usbnet_start_xmit
In reply to Konstantin KhlebnikovThis patch fixes the bug added in commit v3.1-rc7-1055-gf9b491e SKB can be NULL at this point, at least for cdc-ncm.
--- drivers/net/usb/usbnet.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/net/usb/usbnet.c +2 -1
@@ -1057,7 +1057,8 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,unsigned long flags;int retval; -skb_tx_timestamp (skb); +if (skb) +skb_tx_timestamp (skb);// some devices want funky USB-level framing, for // win32 driver (usually) and/or hardware quirks
Quoted 4 lines · Konstantin Khlebnikov
This patch fixes the bug added in commit v3.1-rc7-1055-gf9b491e SKB can be NULL at this point, at least for cdc-ncm.
Signed-off-by Konstantin Khlebnikov <[email protected]>
Quoted 19 lines
--- drivers/net/usb/usbnet.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)drivers/net/usb/usbnet.c +2
-1@@ -1057,7 +1057,8 @@ netdev_tx_t usbnet_start_xmit (struct sk_buff *skb,unsigned long flags;int retval; -skb_tx_timestamp (skb); +if (skb) +skb_tx_timestamp (skb);// some devices want funky USB-level framing, for // win32 driver (usually) and/or hardware quirks
From: Richard Cochran <[email protected]>
Date: Mon, 7 Nov 2011 18:39:19 +0100
Quoted 7 lines · Konstantin Khlebnikov
Quoted 4 lines
This patch fixes the bug added in commit v3.1-rc7-1055-gf9b491e SKB can be NULL at this point, at least for cdc-ncm.
Signed-off-by Konstantin Khlebnikov <[email protected]>Acked-by Richard Cochran <[email protected]>
Applied, but the overall logic in the usbnet transmit path definitely could use a good reconsideration and cleanup.
I'm even open to having generic support at the generic net device TX level to fixup the segmentation layout of the SKB so that it meets the device's requirements. We can do it more efficiently there too.