linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Lord <mlord@pobox.com>
To: Hayes Wang <hayeswang@realtek.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: nic_swsd <nic_swsd@realtek.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	David Miller <davem@davemloft.net>
Subject: Re: [PATCH net 1/2] r8152: fix the sw rx checksum is unavailable
Date: Thu, 17 Nov 2016 09:25:56 -0500	[thread overview]
Message-ID: <a0909dd5-e356-8f32-2f58-9e997f868529@pobox.com> (raw)
In-Reply-To: <a4a43da6-54e0-a9c8-8802-acb4e6c4a2c8@pobox.com>

On 16-11-17 09:14 AM, Mark Lord wrote:
..
> Using coherent buffers (non-cacheable, allocated with usb_alloc_coherent),

Note that the same behaviour also happens with the original kmalloc'd buffers.

> I can get it to fail extremely regularly by simply reducing the buffer size
> (agg_buf_sz) from 16KB down to 4KB.   This makes reproducing the issue
> much much easier -- the same problems do happen with the larger 16KB size,
> but much less often than with smaller sizes.

Increasing the buffer size to 64KB makes the problem much less frequent,
as one might expect.  Thus far I haven't seen it happen at all, but a longer
run (1-3 days) is needed to make sure.  This however is NOT a "fix".

> So.. with a 4KB URB transfer_buffer size, along with a ton of added error-checking,
> I see this behaviour every 10 (rx) URBs or so:
>
> First URB (number 593):
> [   34.260667] r8152_rx_bottom: 593 corrupted urb: head=bf014000 urb_offset=2856/4096 pkt_len(1518) exceeds remainder(1216)
> [   34.271931] r8152_dump_rx_desc: 044805ee 40080000 006005dc 06020000 00000000 00000000 rx_len=1518
>
> Next URB (number 594):
> [   34.281172] r8152_check_rx_desc: rx_desc looks bad.
> [   34.286228] r8152_rx_bottom: 594 corrupted urb. head=bf018000 urb_offset=0/304 len_used=24
> [   34.294774] r8152_dump_rx_desc: 00008300 00008400 00008500 00008600 00008700 00008800 rx_len=768
>
> What the above sample shows, is the URB transfer buffer ran out of space in the middle
> of a packet, and the hardware then tried to just continue that same packet in the next URB,
> without an rx_desc header inserted.  The r8152.c driver always assumes the URB buffer begins
> with an rx_desc, so of course this behaviour produces really weird effects, and system crashes, etc..
>
> So until that driver bug is addressed, I would advise disabling hardware RX checksums
> for all chip versions, not only for version 02.
>
> It is not clear to me how the chip decides when to forward an rx URB to the host.
> If you could describe how that part works for us, then it would help in further
> understanding why fast systems (eg. a PC) don't generally notice the issue,
> while much slower embedded systems do see the issue regularly.

That last part is critical to understanding things:
How does the chip decide that a URB is "full enough" before sending it to the host?
Why does a really fast host see fewer packets jammed together into a single URB than a slower host?

The answers will help understand if there are more bugs to be found/fixed,
or if everything is explained by what has been observed thus far.

To recap:  the hardware sometimes fills a URB to the very end, and then continues the
current packet at the first byte of the following URB.  The r8152.c driver does NOT
handle this situation; instead it always interprets the first 24 bytes of every URB
as an "rx_desc" structure, without any kind of sanity/validation.  This results in
buffer overruns (it trusts the packet length field, even though the URB is too small
to hold such a packet), and other semi-random behaviour.

Using software rx checksums prevents Bad Things(tm) happening from most of this,
but even that is not perfect given the severity of the bug.

Cheers

  reply	other threads:[~2016-11-17 14:29 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-11  7:15 [PATCH net 0/2] r8152: rx patches Hayes Wang
2016-11-11  7:15 ` [PATCH net 1/2] r8152: fix the sw rx checksum is unavailable Hayes Wang
2016-11-17  3:36   ` Hayes Wang
2016-11-17 14:14     ` Mark Lord
2016-11-17 14:25       ` Mark Lord [this message]
     [not found]     ` <d683c019-4e0f-6fe6-368c-c4fc86c72fe6@pobox.com>
2016-11-18  7:57       ` Hayes Wang
2016-11-18 12:03         ` Mark Lord
2016-11-22 13:12           ` Mark Lord
2016-11-23  3:52           ` Hayes Wang
2016-11-23 13:41             ` Mark Lord
2016-11-23 15:12               ` Hayes Wang
2016-11-23 19:29                 ` Mark Lord
2016-11-24  3:24                   ` Hayes Wang
2016-11-24 12:31                   ` Mark Lord
2016-11-24 13:26                     ` Hayes Wang
2016-11-24 15:24                       ` Mark Lord
2016-11-25  6:11                         ` Hayes Wang
2016-11-25 12:36                           ` Mark Lord
2016-11-24 16:21                       ` David Miller
2016-11-24 16:43                         ` Mark Lord
2016-11-24 17:00                           ` Mark Lord
2016-11-24 17:13                             ` David Miller
2016-11-24 17:11                           ` David Miller
2016-11-24 18:34                             ` Mark Lord
2016-11-24 18:49                               ` Mark Lord
2016-11-24 19:00                               ` Greg KH
2016-11-24 19:10                                 ` Mark Lord
2016-11-24 19:17                                   ` Greg KH
2016-11-25  9:52                                   ` Hayes Wang
2016-11-25 13:32                                     ` Mark Lord
2016-11-25  0:27                               ` Francois Romieu
2016-11-25  3:49                                 ` Mark Lord
2016-11-25  9:53                                   ` Greg KH
2016-11-25 12:34                                     ` Mark Lord
2016-11-25 12:41                                       ` Mark Lord
2016-11-25 14:22                                         ` Greg KH
2016-11-25 14:35                                           ` Mark Lord
2016-11-25 12:49                                     ` Mark Lord
2016-11-25 14:24                                       ` Greg KH
2016-11-25 16:58                                       ` David Miller
2016-11-30 11:58                                         ` Hayes Wang
2016-12-09  3:23                                           ` Hayes Wang
2016-12-09 13:05                                             ` Mark Lord
2017-01-01  0:07                                           ` Ansis Atteka
2017-01-03  0:40                                             ` Ansis Atteka
2017-01-03 13:19                                               ` Mark Lord
2017-01-09  7:58                                               ` Hayes Wang
2019-01-05 14:14                                             ` r8152: data corruption in various scenarios Mark Lord
2019-01-05 14:22                                               ` Mark Lord
2019-01-06 19:14                                               ` Kai Heng Feng
2019-01-06 21:13                                                 ` Mark Lord
2019-01-06 21:16                                                   ` Mark Lord
2019-01-07  3:53                                                     ` Hayes Wang
2019-01-07 16:01                                                       ` Mario.Limonciello
2019-01-07 18:06                                                         ` Mark Lord
2019-01-07 18:27                                                           ` Mario.Limonciello
2019-01-07 19:24                                                             ` Mark Lord
2019-01-07  4:09                                                     ` Kai Heng Feng
2019-01-07  4:13                                                       ` Mark Lord
2019-01-07  6:46                                                         ` Kai Heng Feng
2019-01-07  7:01                                                           ` Mark Lord
2016-11-24 18:42                           ` [PATCH net 1/2] r8152: fix the sw rx checksum is unavailable Greg KH
2016-11-24 18:58                             ` Mark Lord
2016-11-25  6:31                           ` Hayes Wang
2016-11-25  6:51                             ` Hayes Wang
2016-11-25 12:35                               ` Mark Lord
2016-11-24 16:19                     ` David Miller
2016-11-24 12:37               ` Hayes Wang
2016-11-11  7:15 ` [PATCH net 2/2] r8152: rx descriptor check Hayes Wang
2016-11-11 12:13   ` Francois Romieu
2016-11-12 13:21     ` Mark Lord
2016-11-14  6:43     ` Hayes Wang
2016-11-15  1:10       ` Francois Romieu
2016-11-17  3:05         ` Hayes Wang
2016-11-13 17:39   ` David Miller
2016-11-13 20:34     ` Mark Lord
2016-11-13 20:38       ` Mark Lord
2016-11-14  7:23       ` Hayes Wang
2016-11-14 17:27         ` David Miller
2016-11-14  7:03     ` Hayes Wang

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=a0909dd5-e356-8f32-2f58-9e997f868529@pobox.com \
    --to=mlord@pobox.com \
    --cc=davem@davemloft.net \
    --cc=hayeswang@realtek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nic_swsd@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).