From: Sergei Shtylyov <sshtylyov@mvista•com>
To: "Bjørn Mork" <bjorn@mork•no>
Cc: Oliver Neukum <oneukum@suse•de>,
linux-usb@vger•kernel.org, netdev@vger•kernel.org
Subject: Re: [RFC] net: usbnet: prevent buggy devices from killing us
Date: Thu, 24 Jan 2013 16:39:18 +0400 [thread overview]
Message-ID: <51012B76.1060600@mvista.com> (raw)
In-Reply-To: <1359023152-32576-1-git-send-email-bjorn@mork.no>
Hello.
On 24-01-2013 14:25, 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. We handle the done queue as fast as we can, so
> if this queue is filling up then that is an indication that we
> are under too heavy pressure. Refusing further allocations
> until the done queue is handled prevents the buggy device
> from taking the system down.
>
> Signed-off-by: Bjørn Mork <bjorn@mork•no>
[...]
> drivers/net/usb/usbnet.c | 8 ++++++++
> 1 files changed, 8 insertions(+), 0 deletions(-)
> diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
> index f34b2eb..85c7ffd 100644
> --- a/drivers/net/usb/usbnet.c
> +++ b/drivers/net/usb/usbnet.c
> @@ -380,6 +380,14 @@ static int rx_submit (struct usbnet *dev, struct urb *urb, gfp_t flags)
> unsigned long lockflags;
> size_t size = dev->rx_urb_size;
>
> + /* Do not let a device flood us to death! */
> + if (dev->done.qlen > 1024) {
> + netif_dbg(dev, rx_err, dev->net, "done queue filling up (%u) - throttling\n", dev->done.qlen);
> + usbnet_defer_kevent (dev, EVENT_RX_MEMORY);
> + usb_free_urb (urb);
Run your patch thru scripts/checkpatch.pl please -- spaces before parens
are not allowed.
WBR, Sergei
next prev parent reply other threads:[~2013-01-24 12:39 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-24 10:25 [RFC] net: usbnet: prevent buggy devices from killing us Bjørn Mork
[not found] ` <1359023152-32576-1-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
2013-01-24 10:46 ` Oliver Neukum
[not found] ` <6505263.QGCG9bfoCC-7ztolUikljGernLeA6q8OA@public.gmane.org>
2013-01-24 10:52 ` Bjørn Mork
[not found] ` <87bocehmzd.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2013-01-24 11:03 ` Oliver Neukum
[not found] ` <2321910.EQLkSoxl50-7ztolUikljGernLeA6q8OA@public.gmane.org>
2013-01-24 11:22 ` Bjørn Mork
[not found] ` <877gn2hlkh.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2013-01-24 11:31 ` Oliver Neukum
2013-01-24 12:47 ` Bjørn Mork
[not found] ` <87y5fig32r.fsf-lbf33ChDnrE/G1V5fR+Y7Q@public.gmane.org>
2013-01-24 13:12 ` Oliver Neukum
[not found] ` <2556579.vjYlY1iKn5-7ztolUikljGernLeA6q8OA@public.gmane.org>
2013-01-24 13:42 ` Bjørn Mork
2013-01-24 19:16 ` [PATCH net] " Bjørn Mork
2013-01-24 22:09 ` Oliver Neukum
2013-01-25 7:13 ` Bjørn Mork
2013-01-25 12:02 ` Oliver Neukum
[not found] ` <1659086.jLlTU1VIap-7ztolUikljGernLeA6q8OA@public.gmane.org>
2013-01-25 12:27 ` Bjørn Mork
[not found] ` <1359055016-13603-1-git-send-email-bjorn-yOkvZcmFvRU@public.gmane.org>
2013-01-24 23:57 ` Joe Perches
2013-01-25 8:14 ` Bjørn Mork
2013-01-24 10:47 ` [RFC] " Bjørn Mork
2013-01-24 12:39 ` Sergei Shtylyov [this message]
[not found] ` <51012B76.1060600-Igf4POYTYCDQT0dZR+AlfA@public.gmane.org>
2013-01-24 13:01 ` Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51012B76.1060600@mvista.com \
--to=sshtylyov@mvista$(echo .)com \
--cc=bjorn@mork$(echo .)no \
--cc=linux-usb@vger$(echo .)kernel.org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=oneukum@suse$(echo .)de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox