[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1359071829.2117.6.camel@joe-AO722>
Date: Thu, 24 Jan 2013 15:57:09 -0800
From: Joe Perches <joe@...ches.com>
To: Bjørn Mork <bjorn@...k.no>
Cc: Oliver Neukum <oneukum@...e.de>, linux-usb@...r.kernel.org,
netdev@...r.kernel.org
Subject: Re: [PATCH net] net: usbnet: prevent buggy devices from killing us
On Thu, 2013-01-24 at 20:16 +0100, Bjørn Mork wrote:
> A device sending 0 length frames as fast as it can has been
> observed killing the host system due to the resulting memory
> pressure.
[]
> diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
[]
> @@ -539,6 +545,22 @@ block:
> break;
> }
>
> + /* stop rx if packet error rate is high */
> + if (++dev->pkt_cnt > 30) {
> + dev->pkt_cnt = 0;
> + dev->pkt_err = 0;
> + } else {
> + if (state == rx_cleanup)
> + dev->pkt_err++;
> + if (dev->pkt_err > 20) {
> + set_bit(EVENT_RX_KILL, &dev->flags);
> + if (net_ratelimit())
> + netif_dbg(dev, rx_err, dev->net,
> + "rx kill: high error rate\n");
> + dev->pkt_err = 0;
> + }
> + }
Maybe use ratelimit() here?
> diff --git a/include/linux/usb/usbnet.h b/include/linux/usb/usbnet.h
[]
> @@ -33,6 +33,7 @@ struct usbnet {
> wait_queue_head_t *wait;
> struct mutex phy_mutex;
> unsigned char suspend_count;
> + unsigned char pkt_cnt, pkt_err;
and instead:
struct ratelimit_state errors;
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists