From: Ben Hutchings <bhutchings@solarflare.com>
To: David Laight <David.Laight@ACULAB.COM>
Cc: 'Ben Hutchings' <ben@decadent.org.uk>,
Florian Fainelli <florian@openwrt.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"davem@davemloft.net" <davem@davemloft.net>
Subject: Re: [PATCH net-next 2/2] r6040: use ETH_ZLEN instead of MISR for SKB length checking
Date: Thu, 16 Jan 2014 17:33:24 +0000 [thread overview]
Message-ID: <1389893604.11912.47.camel@bwh-desktop.uk.level5networks.com> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6D45D812@AcuExch.aculab.com>
On Thu, 2014-01-16 at 09:10 +0000, David Laight wrote:
> From: Ben Hutchings
> > On Wed, 2014-01-15 at 13:04 -0800, Florian Fainelli wrote:
> > > Ever since this driver was merged the following code was included:
> ...
> > > - if (skb->len < MISR)
> > > - descptr->len = MISR;
> > > + if (skb->len < ETH_ZLEN)
> > > + descptr->len = ETH_ZLEN;
> >
> > It looks like this is just increasing the TX descriptor length so the
> > packet is tail-padded with whatever happens to come next in the skb.
> > This is absolutely incorrect behaviour and may leak sensitive
> > information.
>
> And possibly page fault if the data is right at the end of a page.
If the CPU was accessing it, it would be fine as the skb linear area
ends with struct skb_shared_info. (sfc actually takes advantage of that
in efx_enqueue_skb_pio() which can add padding (*not* transmitted) to
ensure that the CPU does write-combining.)
But the NIC, if it's connected through an IOMMU, might get a page fault
due to the incorrect length of the DMA mapping.
> > Presumably it is necessary to pad the frame because the MAC is too lame
> > to do it, and the correct way to do that is using skb_padto(skb,
> > ETH_ZLEN). But this may fail as it might have to allocate memory
>
> Alternatively use two ring entries with the 'more' bit set on
> the first one and transmit the padding from a permanently allocated
> and dma-mapped block of zeros.
> Assuming the hardware support SG transmit and doesn't have a
> constraint on the length of the first fragment.
Do you see NETIF_F_SG in this driver?
Ben.
> Or have a pre-allocated an dma-mapped array of short buffers (one
> for each ring slot) and copy short packets into the array instead
> of dma-mapping the skb data.
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
next prev parent reply other threads:[~2014-01-16 17:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-15 21:04 [PATCH net-next 0/2] r6040: misc fixes Florian Fainelli
2014-01-15 21:04 ` [PATCH net-next 1/2] r6040: add delays in MDIO read/write polling loops Florian Fainelli
2014-01-15 21:04 ` [PATCH net-next 2/2] r6040: use ETH_ZLEN instead of MISR for SKB length checking Florian Fainelli
2014-01-16 7:23 ` Ben Hutchings
2014-01-16 9:10 ` David Laight
2014-01-16 17:33 ` Ben Hutchings [this message]
2014-01-16 19:30 ` Florian Fainelli
2014-01-17 0:24 ` [PATCH net-next 0/2] r6040: misc fixes David Miller
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=1389893604.11912.47.camel@bwh-desktop.uk.level5networks.com \
--to=bhutchings@solarflare.com \
--cc=David.Laight@ACULAB.COM \
--cc=ben@decadent.org.uk \
--cc=davem@davemloft.net \
--cc=florian@openwrt.org \
--cc=netdev@vger.kernel.org \
/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