netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: romieu@fr.zoreil.com
Cc: eric.dumazet@gmail.com, nhorman@tuxdriver.com, netdev@vger.kernel.org
Subject: Re: [PATCH RFC] r8169: straighten out overlength frame detection (v3)
Date: Fri, 08 Jan 2010 16:02:52 -0800 (PST)	[thread overview]
Message-ID: <20100108.160252.189352309.davem@davemloft.net> (raw)
In-Reply-To: <20100108234800.GA2908@electric-eye.fr.zoreil.com>

From: Francois Romieu <romieu@fr.zoreil.com>
Date: Sat, 9 Jan 2010 00:48:00 +0100

> For a single packet, at the time the first interruption is received,
> 4 Rx descriptors have been written. The FirstFrag bit is set on the
> first descriptor only and the LastFrag bit is not set anywhere :
> 
> entry 019 opts1 0x20803ff0 opts2 0x00000000 used 1536 <- FirstFrag
> entry 020 opts1 0x00803ff0 opts2 0x00000000 used 1536
> entry 021 opts1 0x00803ff0 opts2 0x00000000 used 1536
> entry 022 opts1 0x00803ff0 opts2 0x00000000 used 1536
> entry 023 opts1 0x80000600 opts2 0x00000000 used 1524
>                                                  ^^^^
> (apparently we race with the DMA transfer)
>
> More events pop up, starting at 023. They are all identical to 20 / 21 /22.
> It then ends as :
> 
> entry 028 opts1 0x00803ff0 opts2 0x00000000 used 1536
> entry 029 opts1 0x10803ff0 opts2 0x00000000 used 1010 <- LastFrag bit set
> entry 030 opts1 0x80000600 opts2 0x00000000 used 000  <- 0 used byte. Entry
> entry 031 opts1 0x80000600 opts2 0x00000000 used 000     is available.
> entry 032 opts1 0x80000600 opts2 0x00000000 used 000
> 
> The total size of the DMA is not far from 16384 bytes (1536 * 10 + 1010).

My guess is that once the chip starts filling out frags like this,
the signal to trigger what should be the LastFrag entry never
propagates to the DMA engine and thus the descriptor table.

Thus the device just keeps filling packet contents with subsequent
data, with FirstFrag and LastFrag clear, until that ~16K limit is
reached.  At which point it finally sets LastFrag.

> Simply recycling the buffer may work. I'll do a few tests with it : I am
> still unable to corrupt the descriptor ring itself.

Whilst the above will end up gobbling up to (16K - BIG_PACKET_SZ)
worth of innocent frames, the DMA engine seems to keep things at least
self-consistent.

The only bug seems to be the omission of the LastFrag trigger at the
proper place.

About recycling, as far as I can tell that's exactly what the driver
already does in these exact cases, right?  If RxRes is not set, and
we don't see both FirstFrag and LastFrag set, we'll recycle the frame.

		if (unlikely(status & RxRES)) {
 ...
		} else {
 ...
			if (unlikely(rtl8169_fragmented_frame(status))) {
				dev->stats.rx_dropped++;
				dev->stats.rx_length_errors++;
				rtl8169_mark_to_asic(desc, tp->rx_buf_sz);
				continue;
			}

Therefore we shouldn't need to change anything and there is actually
no "bug" or "exploit" at all.  We just end up dropping some RX frames
because the chip didn't DMA them properly.


  reply	other threads:[~2010-01-09  0:02 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-28 19:48 [PATCH RFC] r8169: straighten out overlength frame detection Neil Horman
2009-12-28 19:50 ` Neil Horman
2009-12-28 21:31   ` François romieu
2009-12-28 23:49     ` Neil Horman
2009-12-29  0:24     ` David Dillow
2009-12-29  1:20       ` Neil Horman
2009-12-29  0:51     ` Ben Hutchings
2009-12-29  1:16       ` Neil Horman
2009-12-29  1:29         ` Ben Hutchings
2009-12-29 15:35     ` Neil Horman
2010-01-05 13:57 ` [PATCH RFC] r8169: straighten out overlength frame detection (v3) Neil Horman
2010-01-05 15:15   ` Eric Dumazet
2010-01-05 20:40     ` David Miller
2010-01-05 21:38       ` Neil Horman
2010-01-05 21:45         ` David Miller
2010-01-05 22:04           ` Neil Horman
2010-01-07  1:01       ` Francois Romieu
2010-01-07  1:15         ` David Miller
2010-01-08 23:48           ` Francois Romieu
2010-01-09  0:02             ` David Miller [this message]
2010-01-10  1:57               ` Ben Hutchings
2010-01-10 23:50                 ` Francois Romieu
2010-01-11  6:45                   ` David Miller
2010-01-12  0:16                     ` Francois Romieu
2010-01-12  6:24                       ` David Miller
2010-01-26 22:07                         ` Brandon Philips
2010-01-30 21:50                       ` Neil Horman
2010-02-18 19:37                         ` Brandon Philips

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=20100108.160252.189352309.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.com \
    --cc=romieu@fr.zoreil.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).