mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1 1/1] usb: gadget: NCM: NULL pointer dereference in eth_start_xmit
@ 2016-04-25 15:25 jim_baxter
  2016-04-25 16:51 ` One Thousand Gnomes
  0 siblings, 1 reply; 2+ messages in thread
From: jim_baxter @ 2016-04-25 15:25 UTC (permalink / raw)
  To: linux-usb, linux-kernel
  Cc: Felipe Balbi, Greg Kroah-Hartman, Mike Looijmans, Robert Baldyga,
	Jim Baxter, Mark Craske

From: Jim Baxter <jim_baxter@mentor.com>

"Unable to handle kernel NULL pointer dereference at virtual address
00000078" is reported with "PC is at eth_start_xmit+0x19c/0x378 [u_ether]"

The failure scenario is seen when closing the NCM connection while the
TCP/IPv6 stack is still trying to transmit over NCM.

Defensive code is missing from commit
6d3865f9d41f15ddbcecaa6722871fc0db21d7ab
"usb: gadget: NCM: Add transmit multi-frame."


Add check for non-NULL dev->port_usb before accessing
dev->port_usb->supports_multi_frame.

Signed-off-by: Mark Craske <Mark_Craske@mentor.com>
Signed-off-by: Jim Baxter <jim_baxter@mentor.com>

---
 drivers/usb/gadget/function/u_ether.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index 637809e..68f0b7b 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -556,7 +556,8 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
 			/* Multi frame CDC protocols may store the frame for
 			 * later which is not a dropped frame.
 			 */
-			if (dev->port_usb->supports_multi_frame)
+			if (dev->port_usb &&
+			    dev->port_usb->supports_multi_frame)
 				goto multiframe;
 			goto drop;
 		}
-- 
1.9.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v1 1/1] usb: gadget: NCM: NULL pointer dereference in eth_start_xmit
  2016-04-25 15:25 [PATCH v1 1/1] usb: gadget: NCM: NULL pointer dereference in eth_start_xmit jim_baxter
@ 2016-04-25 16:51 ` One Thousand Gnomes
  0 siblings, 0 replies; 2+ messages in thread
From: One Thousand Gnomes @ 2016-04-25 16:51 UTC (permalink / raw)
  To: jim_baxter
  Cc: linux-usb, linux-kernel, Felipe Balbi, Greg Kroah-Hartman,
	Mike Looijmans, Robert Baldyga, Mark Craske

On Mon, 25 Apr 2016 16:25:03 +0100
<jim_baxter@mentor.com> wrote:

> From: Jim Baxter <jim_baxter@mentor.com>
> 
> "Unable to handle kernel NULL pointer dereference at virtual address
> 00000078" is reported with "PC is at eth_start_xmit+0x19c/0x378 [u_ether]"
> 
> The failure scenario is seen when closing the NCM connection while the
> TCP/IPv6 stack is still trying to transmit over NCM.
> 
> Defensive code is missing from commit
> 6d3865f9d41f15ddbcecaa6722871fc0db21d7ab
> "usb: gadget: NCM: Add transmit multi-frame."

This looks inadequate. Surely you also need to hold dev->lock ?

Also it'll also crash at the no zlp test with the same problem.

Alan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-25 16:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-25 15:25 [PATCH v1 1/1] usb: gadget: NCM: NULL pointer dereference in eth_start_xmit jim_baxter
2016-04-25 16:51 ` One Thousand Gnomes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®