All of lore.kernel.org
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@fb.com>
To: Martin Lau <kafai@fb.com>
Cc: "bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	Networking <netdev@vger.kernel.org>,
	Alexei Starovoitov <ast@fb.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	David Miller <davem@davemloft.net>,
	Kernel Team <Kernel-team@fb.com>, Craig Gallek <kraig@google.com>
Subject: Re: [PATCH bpf 1/2] bpf: udp: ipv6: Avoid running reuseport's bpf_prog from __udp6_lib_err
Date: Sat, 1 Jun 2019 23:54:52 +0000	[thread overview]
Message-ID: <E1A13752-B9E8-41D8-A44D-12CE1933C46D@fb.com> (raw)
In-Reply-To: <20190531222911.2500496-1-kafai@fb.com>



> On May 31, 2019, at 3:29 PM, Martin KaFai Lau <kafai@fb.com> wrote:
> 
> __udp6_lib_err() may be called when handling icmpv6 message. For example,
> the icmpv6 toobig(type=2).  __udp6_lib_lookup() is then called
> which may call reuseport_select_sock().  reuseport_select_sock() will
> call into a bpf_prog (if there is one).
> 
> reuseport_select_sock() is expecting the skb->data pointing to the
> transport header (udphdr in this case).  For example, run_bpf_filter()
> is pulling the transport header.
> 
> However, in the __udp6_lib_err() path, the skb->data is pointing to the
> ipv6hdr instead of the udphdr.
> 
> One option is to pull and push the ipv6hdr in __udp6_lib_err().
> Instead of doing this, this patch follows how the original
> commit 538950a1b752 ("soreuseport: setsockopt SO_ATTACH_REUSEPORT_[CE]BPF")
> was done in IPv4, which has passed a NULL skb pointer to
> reuseport_select_sock().
> 
> Fixes: 538950a1b752 ("soreuseport: setsockopt SO_ATTACH_REUSEPORT_[CE]BPF")
> Cc: Craig Gallek <kraig@google.com>
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>

Acked-by: Song Liu <songliubraving@fb.com>

> ---
> net/ipv6/udp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
> index 07fa579dfb96..133e6370f89c 100644
> --- a/net/ipv6/udp.c
> +++ b/net/ipv6/udp.c
> @@ -515,7 +515,7 @@ int __udp6_lib_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
> 	struct net *net = dev_net(skb->dev);
> 
> 	sk = __udp6_lib_lookup(net, daddr, uh->dest, saddr, uh->source,
> -			       inet6_iif(skb), inet6_sdif(skb), udptable, skb);
> +			       inet6_iif(skb), inet6_sdif(skb), udptable, NULL);
> 	if (!sk) {
> 		/* No socket for error: try tunnels before discarding */
> 		sk = ERR_PTR(-ENOENT);
> -- 
> 2.17.1
> 


  reply	other threads:[~2019-06-01 23:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-31 22:29 [PATCH bpf 0/2] bpf: udp: A few reuseport's bpf_prog for udp lookup Martin KaFai Lau
2019-05-31 22:29 ` [PATCH bpf 1/2] bpf: udp: ipv6: Avoid running reuseport's bpf_prog from __udp6_lib_err Martin KaFai Lau
2019-06-01 23:54   ` Song Liu [this message]
2019-06-03 13:07   ` Craig Gallek
2019-05-31 22:29 ` [PATCH bpf 2/2] bpf: udp: Avoid calling reuseport's bpf_prog from udp_gro Martin KaFai Lau
2019-06-01 23:54   ` Song Liu
2019-06-02  1:09     ` Martin Lau
2019-06-02  7:05       ` Song Liu
2019-06-03 20:42 ` [PATCH bpf 0/2] bpf: udp: A few reuseport's bpf_prog for udp lookup Alexei Starovoitov

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=E1A13752-B9E8-41D8-A44D-12CE1933C46D@fb.com \
    --to=songliubraving@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=kafai@fb.com \
    --cc=kraig@google.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.