netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] asix: fix infinite loop in rx_fixup()
@ 2012-01-07 18:09 Aurelien Jacobs
  2012-01-07 20:15 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Aurelien Jacobs @ 2012-01-07 18:09 UTC (permalink / raw)
  To: netdev; +Cc: Aurelien Jacobs

At this point if skb->len happens to be 2, the subsequant skb_pull(skb, 4)
call won't work and the skb->len won't be decreased and won't ever reach 0,
resulting in an infinite loop.

With an ASIX 88772 under heavy load, without this patch, rx_fixup() reaches
an infinite loop in less than a minute. With this patch applied,
no infinite loop even after hours of heavy load.

Signed-off-by: Aurelien Jacobs <aurel@gnuage.org>
---
 drivers/net/usb/asix.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/usb/asix.c b/drivers/net/usb/asix.c
index dbdca22..df2b08d 100644
--- a/drivers/net/usb/asix.c
+++ b/drivers/net/usb/asix.c
@@ -374,11 +374,11 @@ static int asix_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
 			return 0;
 		}
 
 		skb_pull(skb, (size + 1) & 0xfffe);
 
-		if (skb->len == 0)
+		if (skb->len < sizeof(header))
 			break;
 
 		head = (u8 *) skb->data;
 		memcpy(&header, head, sizeof(header));
 		le32_to_cpus(&header);
-- 
1.7.8.2

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

* Re: [PATCH] asix: fix infinite loop in rx_fixup()
  2012-01-07 18:09 [PATCH] asix: fix infinite loop in rx_fixup() Aurelien Jacobs
@ 2012-01-07 20:15 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-01-07 20:15 UTC (permalink / raw)
  To: aurel; +Cc: netdev

From: Aurelien Jacobs <aurel@gnuage.org>
Date: Sat,  7 Jan 2012 19:09:27 +0100

> At this point if skb->len happens to be 2, the subsequant skb_pull(skb, 4)
> call won't work and the skb->len won't be decreased and won't ever reach 0,
> resulting in an infinite loop.
> 
> With an ASIX 88772 under heavy load, without this patch, rx_fixup() reaches
> an infinite loop in less than a minute. With this patch applied,
> no infinite loop even after hours of heavy load.
> 
> Signed-off-by: Aurelien Jacobs <aurel@gnuage.org>

Applied, thanks.

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

end of thread, other threads:[~2012-01-07 20:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-07 18:09 [PATCH] asix: fix infinite loop in rx_fixup() Aurelien Jacobs
2012-01-07 20:15 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).