bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Stanislav Fomichev <sdf@google.com>
Cc: Network Development <netdev@vger.kernel.org>,
	bpf <bpf@vger.kernel.org>, David Miller <davem@davemloft.net>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Willem de Bruijn <willemb@google.com>,
	Petar Penkov <ppenkov@google.com>
Subject: Re: [PATCH bpf 1/2] flow_dissector: support FLOW_DISSECTOR_KEY_ETH_ADDRS with BPF
Date: Mon, 13 May 2019 16:33:06 -0400	[thread overview]
Message-ID: <CAF=yD-LO6o=uZ-aT-J9uPiBcO4f2Zc9uyGZ+f7M7mPtRSB44gA@mail.gmail.com> (raw)
In-Reply-To: <20190513185402.220122-1-sdf@google.com>

On Mon, May 13, 2019 at 3:53 PM Stanislav Fomichev <sdf@google.com> wrote:
>
> If we have a flow dissector BPF program attached to the namespace,
> FLOW_DISSECTOR_KEY_ETH_ADDRS won't trigger because we exit early.

I suppose that this is true for a variety of keys? For instance, also
FLOW_DISSECTOR_KEY_IPV4_ADDRS.

We originally intended BPF flow dissection for all paths except
tc_flower. As that catches all the vulnerable cases on the ingress
path on the one hand and it is infeasible to support all the
flower features, now and future. I think that is the real fix.

>
> Handle FLOW_DISSECTOR_KEY_ETH_ADDRS before BPF and only if we have
> an skb (used by tc-flower only).
>
> Fixes: d58e468b1112 ("flow_dissector: implements flow dissector BPF hook")
> Signed-off-by: Stanislav Fomichev <sdf@google.com>
> ---
>  net/core/flow_dissector.c | 23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
>
> diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
> index 9ca784c592ac..ba76d9168c8b 100644
> --- a/net/core/flow_dissector.c
> +++ b/net/core/flow_dissector.c
> @@ -825,6 +825,18 @@ bool __skb_flow_dissect(const struct net *net,
>                         else if (skb->sk)
>                                 net = sock_net(skb->sk);
>                 }
> +
> +               if (dissector_uses_key(flow_dissector,
> +                                      FLOW_DISSECTOR_KEY_ETH_ADDRS)) {
> +                       struct ethhdr *eth = eth_hdr(skb);

Here as well as in the original patch: is it safe to just cast to
eth_hdr? In the same file, __skb_flow_dissect_gre does test for
(encapsulated) protocol first.

  parent reply	other threads:[~2019-05-13 20:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-13 18:54 [PATCH bpf 1/2] flow_dissector: support FLOW_DISSECTOR_KEY_ETH_ADDRS with BPF Stanislav Fomichev
2019-05-13 18:54 ` [PATCH bpf 2/2] selftests/bpf: test L2 dissection in flow dissector Stanislav Fomichev
2019-05-13 20:33 ` Willem de Bruijn [this message]
2019-05-13 21:02   ` [PATCH bpf 1/2] flow_dissector: support FLOW_DISSECTOR_KEY_ETH_ADDRS with BPF Stanislav Fomichev
2019-05-13 21:21     ` Willem de Bruijn
2019-05-13 22:47       ` Willem de Bruijn
2019-05-13 23:05         ` Stanislav Fomichev
2019-05-13 23:21           ` Stanislav Fomichev
2019-05-13 23:44             ` Willem de Bruijn

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='CAF=yD-LO6o=uZ-aT-J9uPiBcO4f2Zc9uyGZ+f7M7mPtRSB44gA@mail.gmail.com' \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=ppenkov@google.com \
    --cc=sdf@google.com \
    --cc=willemb@google.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).