netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Duyck, Alexander H" <alexander.h.duyck@intel.com>
To: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"sowmini.varadhan@oracle.com" <sowmini.varadhan@oracle.com>
Subject: Re: [PATCH RFC] ixgbe: ixgbe_atr() must check if network header is available in headlen
Date: Mon, 17 Oct 2016 14:38:48 +0000	[thread overview]
Message-ID: <1476715125.4409.8.camel@intel.com> (raw)
In-Reply-To: <20161015213104.GK31471@oracle.com>

On Sat, 2016-10-15 at 17:31 -0400, Sowmini Varadhan wrote:
> For some Tx paths (e.g., tpacket_snd()), ixgbe_atr may be
> passed down an sk_buff that has the network and transport
> header in the paged data, so it needs to make sure these
> headers are available in the headlen bytes to calculate the
> l4_proto.
> 
> This patch bails out if the headlen is "too short", and does
> not attempt to call skb_header_pointer() to get the needed
> bytes: the assumption is that the caller should set things
> up properly if the l4_proto based tx steering is desired.
> 
> > Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
> ---
>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> index a244d9a..0868de1 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> @@ -7632,6 +7632,7 @@ static void ixgbe_atr(struct ixgbe_ring *ring,
> >  	struct sk_buff *skb;
> >  	__be16 vlan_id;
> >  	int l4_proto;
> > +	int min_hdr_size = 0;
>  
> >  	/* if ring doesn't have a interrupt vector, cannot perform ATR */
> >  	if (!q_vector)
> @@ -7650,6 +7651,14 @@ static void ixgbe_atr(struct ixgbe_ring *ring,
>  
> >  	/* snag network header to get L4 type and address */
> >  	skb = first->skb;
> > +	if (first->protocol == htons(ETH_P_IP))
> > +		min_hdr_size = sizeof(struct iphdr) +
> > +			       sizeof(struct tcphdr);
> > +	else if (first->protocol == htons(ETH_P_IPV6))
> > +		min_hdr_size = sizeof(struct ipv6hdr) +
> > +			       sizeof(struct tcphdr);
> > +	if (min_hdr_size && skb_headlen(skb) < ETH_HLEN + min_hdr_size)
> > +		return;
> >  	hdr.network = skb_network_header(skb);
> >  	if (skb->encapsulation &&
> >  	    first->protocol == htons(ETH_P_IP) &&

So this doesn't really cover all the cases necessary.  There end up
being essentially 3 spots where we need to perform checks to verify the
header size.

The first one is inside the checks for skb->encapsulation, ETH_P_IP,
and IPPROTO_UDP.  We could probably just verify that skb_tail_pointer
is greater than skb_transport_header + (8 + 8 + 14), the minimum size
needed to support VxLAN.

The second block where we need to perform this check would be after
this check once the network header has been updated.  There we need to
verify that hdr.network + 40 is less than or equal to skb_tail_pointer.
 That covers both IPv4 w/ TCP or IPv6.

The third check that needs to be performed is to verify that
hdr.network + hlen is greater than or equal to skb_tail_pointer - 20.
That is needed to verify we have enough room for the tcp header data to
be pulled.

- Alex

      reply	other threads:[~2016-10-17 14:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-15 21:31 [PATCH RFC] ixgbe: ixgbe_atr() must check if network header is available in headlen Sowmini Varadhan
2016-10-17 14:38 ` Duyck, Alexander H [this message]

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=1476715125.4409.8.camel@intel.com \
    --to=alexander.h.duyck@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=sowmini.varadhan@oracle.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).