netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V3 net-next] ixgbe: Avoid unaligned access in ixgbe_atr() for LLC packets
@ 2016-03-14 19:47 Sowmini Varadhan
  2016-03-16 22:58 ` Jeff Kirsher
  0 siblings, 1 reply; 4+ messages in thread
From: Sowmini Varadhan @ 2016-03-14 19:47 UTC (permalink / raw)
  To: intel-wired-lan, netdev, alexander.duyck
  Cc: jeffrey.t.kirsher, jesse.brandeburg, shannon.nelson,
	carolyn.wyborny, donald.c.skidmore, bruce.w.allan, john.ronciak,
	mitch.a.williams, sowmini.varadhan


For LLC based protocols like lldp, stp etc., the ethernet header
is an 802.3 header with a h_proto that is not 0x800, 0x86dd, or
even 0x806.  In this world, the skb_network_header() points at
the DSAP/SSAP/..  and is not likely to be NET_IP_ALIGNed in
ixgbe_atr().

With LLC, drivers are not likely to correctly find IPVERSION,
or "6", at hdr.ipv4->version, but will instead just needlessly
trigger an unaligned access. (IPv4/IPv6 over LLC is almost never
implemented).

The unaligned access is thus avoidable: bail out quickly after
examining skb->protocol. The only Ethernet II protocols handled
are IPv4 and IPv6

Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
---
v2: Alexander Duyck comments
v3: filter out all ethertypes  except for Ethernet II and (IPv4 or IPv6)

 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 4d6223d..aeab2fe 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -7574,6 +7574,11 @@ static void ixgbe_atr(struct ixgbe_ring *ring,
 	if (!ring->atr_sample_rate)
 		return;
 
+	/* this function only handles IPv4 or IPv6 */
+	if (first->protocol != htons(ETH_P_IP) &&
+	    first->protocol != htons(ETH_P_IPV6))
+		return;
+
 	ring->atr_count++;
 
 	/* snag network header to get L4 type and address */
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH V3 net-next] ixgbe: Avoid unaligned access in ixgbe_atr() for LLC packets
  2016-03-14 19:47 [PATCH V3 net-next] ixgbe: Avoid unaligned access in ixgbe_atr() for LLC packets Sowmini Varadhan
@ 2016-03-16 22:58 ` Jeff Kirsher
  2016-03-16 23:01   ` Sowmini Varadhan
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Kirsher @ 2016-03-16 22:58 UTC (permalink / raw)
  To: Sowmini Varadhan, intel-wired-lan, netdev, alexander.duyck
  Cc: jesse.brandeburg, shannon.nelson, carolyn.wyborny,
	donald.c.skidmore, bruce.w.allan, john.ronciak, mitch.a.williams

[-- Attachment #1: Type: text/plain, Size: 2503 bytes --]

On Mon, 2016-03-14 at 15:47 -0400, Sowmini Varadhan wrote:
> 
> For LLC based protocols like lldp, stp etc., the ethernet header
> is an 802.3 header with a h_proto that is not 0x800, 0x86dd, or
> even 0x806.  In this world, the skb_network_header() points at
> the DSAP/SSAP/..  and is not likely to be NET_IP_ALIGNed in
> ixgbe_atr().
> 
> With LLC, drivers are not likely to correctly find IPVERSION,
> or "6", at hdr.ipv4->version, but will instead just needlessly
> trigger an unaligned access. (IPv4/IPv6 over LLC is almost never
> implemented).
> 
> The unaligned access is thus avoidable: bail out quickly after
> examining skb->protocol. The only Ethernet II protocols handled
> are IPv4 and IPv6
> 
> Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
> ---
> v2: Alexander Duyck comments
> v3: filter out all ethertypes  except for Ethernet II and (IPv4 or
> IPv6)
> 
>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)

This does not apply since Alex Duyck beat you to the fix.  Here is the
patch he submitted on 3/15 which corrects the issue.  So I am dropping
your patch from the queue.

commit 04b8b51c34837765cf6250f69d419c439dc393bf
Author: Alexander Duyck <aduyck@mirantis.com>
Date:   Tue Mar 15 15:10:22 2016 -0700

    ixgbe: Fix ATR so that it correctly handles IPv6 extension headers
    
    The ATR code was assuming that it would be able to use tcp_hdr for
    every TCP frame that came through.  However this isn't the case as
it
    is possible for a frame to arrive that is TCP but sent through
something
    like a raw socket.  As a result the driver was setting up bad
filters in
    which tcp_hdr was really pointing to the network header so the data
was
    all invalid.
    
    In order to correct this I have added a bit of parsing logic that
will
    determine the TCP header location based off of the network header
and
    either the offset in the case of the IPv4 header, or a walk through
the
    IPv6 extension headers until it encounters the header that
indicates
    IPPROTO_TCP.  In addition I have added checks to verify that the
lowest
    protocol provided is recognized as IPv4 or IPv6 to help mitigate
raw
    sockets using ETH_P_ALL from having ATR applied to them.
    
    Signed-off-by: Alexander Duyck <aduyck@mirantis.com>

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V3 net-next] ixgbe: Avoid unaligned access in ixgbe_atr() for LLC packets
  2016-03-16 22:58 ` Jeff Kirsher
@ 2016-03-16 23:01   ` Sowmini Varadhan
  2016-03-17  1:31     ` Alexander Duyck
  0 siblings, 1 reply; 4+ messages in thread
From: Sowmini Varadhan @ 2016-03-16 23:01 UTC (permalink / raw)
  To: Jeff Kirsher
  Cc: intel-wired-lan, netdev, alexander.duyck, jesse.brandeburg,
	shannon.nelson, carolyn.wyborny, donald.c.skidmore, bruce.w.allan,
	john.ronciak, mitch.a.williams

On (03/16/16 15:58), Jeff Kirsher wrote:
> 
> This does not apply since Alex Duyck beat you to the fix.  Here is the
> patch he submitted on 3/15 which corrects the issue.  So I am dropping
> your patch from the queue.
> 

That's weird because Alexander was reviewing my fix on the various
lists yesterday, so he could have just told me about this.

But, whatever.

--sowmini

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH V3 net-next] ixgbe: Avoid unaligned access in ixgbe_atr() for LLC packets
  2016-03-16 23:01   ` Sowmini Varadhan
@ 2016-03-17  1:31     ` Alexander Duyck
  0 siblings, 0 replies; 4+ messages in thread
From: Alexander Duyck @ 2016-03-17  1:31 UTC (permalink / raw)
  To: Sowmini Varadhan
  Cc: Jeff Kirsher, intel-wired-lan, Netdev, Brandeburg, Jesse,
	shannon nelson, Carolyn Wyborny, Skidmore, Donald C,
	Bruce W Allan, John Ronciak, Mitch Williams

On Wed, Mar 16, 2016 at 4:01 PM, Sowmini Varadhan
<sowmini.varadhan@oracle.com> wrote:
> On (03/16/16 15:58), Jeff Kirsher wrote:
>>
>> This does not apply since Alex Duyck beat you to the fix.  Here is the
>> patch he submitted on 3/15 which corrects the issue.  So I am dropping
>> your patch from the queue.
>>
>
> That's weird because Alexander was reviewing my fix on the various
> lists yesterday, so he could have just told me about this.
>
> But, whatever.

Sowmini,

Just for the record I didn't submit it on March 15 I submitted it on
January 26th as per the log in patchwork,
http://patchwork.ozlabs.org/patch/573058/.

Sorry I didn't realize the patch was not against the next-queue.  Back
when I made that fix I was focused on the IPv6 portion of it so that
piece of it had slipped my mind.  If it is any consolation at least my
patch is 7+ weeks ahead in the queue so hopefully the fix will make it
into net-next as soon as the merge window opens.

- Alex

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-03-17  1:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-14 19:47 [PATCH V3 net-next] ixgbe: Avoid unaligned access in ixgbe_atr() for LLC packets Sowmini Varadhan
2016-03-16 22:58 ` Jeff Kirsher
2016-03-16 23:01   ` Sowmini Varadhan
2016-03-17  1:31     ` Alexander Duyck

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).