Skip to contentSkip to conversation

usb: gadget: eem: fix wrong eem header operation

PATCH Superseded Linyu Yuan 2 participants 3 messages Jun 3, 2021 – Jun 7, 2021 USB

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Linyu Yuan

author
#0 lore raw

PATCH 1/1 usb: gadget: eem: fix wrong eem header operation

From: Linyu Yuan <[email protected]>

when skb_clone() or skb_copy_expand() fail,
it should pull skb with lengh indicated by header, or not it will read network data and check it as header.

---
 drivers/usb/gadget/function/f_eem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/function/f_eem.c +2 -2
index cfcc4e81fb77..28dd5f1fd106 100644
@@ -495,7 +495,7 @@ static int eem_unwrap(struct gether *port,
 			skb2 = skb_clone(skb, GFP_ATOMIC);
 			if (unlikely(!skb2)) {
 				DBG(cdev, "unable to unframe EEM packet\n");
-				continue;
+				goto next;
 			}
 			skb_trim(skb2, len - ETH_FCS_LEN);
 
@@ -505,7 +505,7 @@ static int eem_unwrap(struct gether *port,
 						GFP_ATOMIC);
 			if (unlikely(!skb3)) {
 				dev_kfree_skb_any(skb2);
-				continue;
+				goto next;
 			}
 			dev_kfree_skb_any(skb2);
 			skb_queue_tail(list, skb3);
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 3 lines · Linyu Yuan

From: Linyu Yuan <[email protected]>

when skb_clone() or skb_copy_expand() fail,

How can these calls fail? If they do, what is the overall system health?

Quoted 7 lines

it should pull skb with lengh indicated by header, or not it will read network data and check it as header.

---
 drivers/usb/gadget/function/f_eem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

What commit does this fix? Should it go to stable kernels? If so, how far back?

And any reason you didn't use scripts/get_maintainer.pl for who to send your patch to?

thanks,

greg k-h

#2 lore raw
Quoted 7 lines · Greg KH
Quoted 3 lines · Linyu Yuan

From: Linyu Yuan <[email protected]>

when skb_clone() or skb_copy_expand() fail,

How can these calls fail? If they do, what is the overall system health?

indeed skb_copy_expand() fail on system when it have low continuous memory region when using bigger MTU.

Quoted 11 lines
Quoted 8 lines

it should pull skb with lengh indicated by header, or not it will read network data and check it as header.

---
 drivers/usb/gadget/function/f_eem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

What commit does this fix? Should it go to stable kernels? If so, how far back?

this change can't avoid all system memory issue which cause skb failure, but i help reduce driver parse wrong network data which may consume too much CPU time.

i will cc [email protected] on V2. i think it can apply to all active stable branch, from 4.4 to 5.10.

Quoted 3 lines

And any reason you didn't use scripts/get_maintainer.pl for who to send your patch to?

thanks very much, i will follow your suggestion and provide a V2.

Quoted 4 lines

thanks,

greg k-h