From: John Fastabend <john.r.fastabend@intel.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: netdev <netdev@vger.kernel.org>,
e1000-devel@lists.sourceforge.net, jeffrey.t.kirsher@intel.com
Subject: Re: ixgbevf: suspicious skb->pkt_type check
Date: Thu, 19 Dec 2013 12:35:20 -0800 [thread overview]
Message-ID: <52B35888.9050506@intel.com> (raw)
In-Reply-To: <CAGVrzcbYgy--jh_C6op39+DZqqkS5=Dmuu57uUGSnEr0TZ6DUw@mail.gmail.com>
On 12/19/2013 10:08 AM, Florian Fainelli wrote:
> Hi John,
>
> In commit 815cccbf ("ixgbe: add setlink, getlink support to ixgbe and
> ixgbevf") this line was added:
>
>
> + if ((skb->pkt_type & (PACKET_BROADCAST | PACKET_MULTICAST)) &&
> + !(compare_ether_addr(adapter->netdev->dev_addr,
> + eth_hdr(skb)->h_source))) {
>
> This looks suspicious to me since skb->pkt_type is not a bitmask, but
> holds only one value at a time, and with this check you would also
> match any value which has the lower two bits set, so PACKET_OTHERHOST,
> PACKET_LOOPBACK and PACKET_FASTROUTE are also matching the first part
> of the check.
>
Yep, it is poorly coded I'll send a fix to Jeff to make it readable.
Note it doesn't actually break anything in practice because the only
types that can be set at this point are broadcast, multicast or
otherhost. And because this virtual function is behind the embedded
switch in the nic only packets with the correct destination address
or multicast addresses will make it to the virtual function. The
virtual function doesn't currently support promisc mode further promisc
mode in the context of a switch that doesn't support flooding is sort
of non-sense to start with. All that said a much better check would
be 'if (skb->pkt_type && ...) ' thanks for catching it.
Thanks,
John
prev parent reply other threads:[~2013-12-19 20:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-19 18:08 ixgbevf: suspicious skb->pkt_type check Florian Fainelli
2013-12-19 20:35 ` John Fastabend [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=52B35888.9050506@intel.com \
--to=john.r.fastabend@intel.com \
--cc=e1000-devel@lists.sourceforge.net \
--cc=f.fainelli@gmail.com \
--cc=jeffrey.t.kirsher@intel.com \
--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;
as well as URLs for NNTP newsgroup(s).