From: Eric Dumazet <eric.dumazet@gmail.com>
To: Raffaele Recalcati <raffaele.recalcati@bticino.it>
Cc: Davide Ciminaghi <ciminaghi@gnudd.com>,
"David S. Miller" <davem@davemloft.net>,
Alexey Dobriyan <adobriyan@gmail.com>,
Thomas Meyer <thomas@m3y3r.de>,
Wan ZongShun <mcuos.com@gmail.com>,
Lucas De Marchi <lucas.demarchi@profusion.mobi>,
netdev@vger.kernel.org
Subject: Re: [PATCH] net/ethernet: ks8851_mll fix rx frame buffer overflow
Date: Wed, 28 Mar 2012 09:39:51 +0200 [thread overview]
Message-ID: <1332920391.3547.46.camel@edumazet-glaptop> (raw)
In-Reply-To: <20120328070540.GA4892@recalcati>
On Wed, 2012-03-28 at 09:05 +0200, Raffaele Recalcati wrote:
> Hi Eric,
>
> On 07:39 Tue 27 Mar , Eric Dumazet wrote:
> > Le mardi 27 mars 2012 à 15:01 +0200, Davide Ciminaghi a écrit :
> > > If interrupts are disabled long enough to allow for more than
> > > 32 frames to accumulate in the MAC's internal buffers, a buffer
> > > overflow occurs. This patch fixes the problem by making the
> > > driver's frame_head_info buffer bigger enough.
> > >
> > > Signed-off-by: Davide Ciminaghi <ciminaghi@gnudd.com>
> > > Signed-off-by: Raffaele Recalcati <raffaele.recalcati@bticino.it>
> > > ---
> > > drivers/net/ethernet/micrel/ks8851_mll.c | 2 +-
> > > 1 files changed, 1 insertions(+), 1 deletions(-)
> > >
> > > diff --git a/drivers/net/ethernet/micrel/ks8851_mll.c b/drivers/net/ethernet/micrel/ks8851_mll.c
> > > index 2784bc7..a158e89 100644
> > > --- a/drivers/net/ethernet/micrel/ks8851_mll.c
> > > +++ b/drivers/net/ethernet/micrel/ks8851_mll.c
> > > @@ -40,7 +40,7 @@
> > > #define DRV_NAME "ks8851_mll"
> > >
> > > static u8 KS_DEFAULT_MAC_ADDRESS[] = { 0x00, 0x10, 0xA1, 0x86, 0x95, 0x11 };
> > > -#define MAX_RECV_FRAMES 32
> > > +#define MAX_RECV_FRAMES 256
> > > #define MAX_BUF_SIZE 2048
> > > #define TX_BUF_SIZE 2000
> > > #define RX_BUF_SIZE 2000
> >
> > How can this fix the problem for good ?
>
> You can see in ks_rcv function,
> ks->frame_cnt = ks_rdreg16(ks, KS_RXFCTR) >> 8;
> so "RXFC RX Frame Count" is a byte, maximum 256 total frames.
> but we have the threshold ..
>
> As you can see also in ks_setup the
> /* Setup Receive Frame Threshold - 1 frame (RXFCTFC) */
> ks_wrreg16(ks, KS_RXFCTR, 1 & RXFCTR_THRESHOLD_MASK);
>
> In conclusion what happen is that if we stop system interrupts for a while,
> when we are back the ks_rcv function starts reading the frames, and
> the
> while (ks->frame_cnt--) {
> ..
> frame_hdr++;
> }
> loop goes out of the malloc'ed area.
>
> We experienced so strange bugs in the last weeks that we are so happy that it seems fixed, but I need
> some weeks to confirm it is robust enough.
> The 'load setup' is like the following:
> - nfs rootfs
> - host $ sudo ping -f $TARGET_IP_ADDRESS
> - host $ scp -r BIG_DIR user@$TARGET_IP_ADDRESS:
> But I'm not sure to create the bug in a mathematical way, it seems to depend on packets on the corporate lan.
>
> Surely if I stop with jtag and restart after some seconds I have buffer overflow, with same errors in ram that I
> obtain randomically with 'load setup'.
>
> Hoping it helps,
Sure it does.
So the limit should be 255, not 256.
(0xFFFF >> 8 -> 0xFF)
ks->frame_cnt = ks_rdreg16(ks, KS_RXFCTR) >> 8;
I cant see how 256 can be stored in a 8bit field ?
You see, explaining things in Changelog can actually help a lot, since
we now understand chip has this 8bit limit for the frame counter.
Thanks
next prev parent reply other threads:[~2012-03-28 7:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-27 13:01 [PATCH] net/ethernet: ks8851_mll fix rx frame buffer overflow Davide Ciminaghi
2012-03-27 14:39 ` Eric Dumazet
2012-03-27 21:31 ` David Miller
2012-03-28 7:05 ` Raffaele Recalcati
2012-03-28 7:12 ` David Miller
2012-03-28 7:39 ` Eric Dumazet [this message]
2012-03-28 10:51 ` Davide Ciminaghi
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=1332920391.3547.46.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=adobriyan@gmail.com \
--cc=ciminaghi@gnudd.com \
--cc=davem@davemloft.net \
--cc=lucas.demarchi@profusion.mobi \
--cc=mcuos.com@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=raffaele.recalcati@bticino.it \
--cc=thomas@m3y3r.de \
/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