netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin KaFai Lau <kafai@fb.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	<kernel-team@fb.com>, <netdev@vger.kernel.org>
Subject: Re: [PATCH v2 bpf 1/2] bpf: net: Avoid copying sk_user_data of reuseport_array during sk_clone
Date: Thu, 9 Jul 2020 14:27:16 -0700	[thread overview]
Message-ID: <20200709212716.fvuas7m5dvlotwnj@kafai-mbp> (raw)
In-Reply-To: <7535d0e3-e442-8611-3c35-cbc9f4cace8c@iogearbox.net>

On Thu, Jul 09, 2020 at 10:07:59PM +0200, Daniel Borkmann wrote:
> On 7/9/20 8:11 AM, Martin KaFai Lau wrote:
> > It makes little sense for copying sk_user_data of reuseport_array during
> > sk_clone_lock().  This patch reuses the SK_USER_DATA_NOCOPY bit introduced in
> > commit f1ff5ce2cd5e ("net, sk_msg: Clear sk_user_data pointer on clone if tagged").
> > It is used to mark the sk_user_data is not supposed to be copied to its clone.
> > 
> > Although the cloned sk's sk_user_data will not be used/freed in
> > bpf_sk_reuseport_detach(), this change can still allow the cloned
> > sk's sk_user_data to be used by some other means.
> > 
> > Freeing the reuseport_array's sk_user_data does not require a rcu grace
> > period.  Thus, the existing rcu_assign_sk_user_data_nocopy() is not
> > used.
> 
> nit: Would have been nice though to add a nonrcu API for this nevertheless
> instead of open coding.
Agreed.  I will create a follow-up patch to bpf-next later.

I had created (READ|WRITE)_ONCE_SK_USER_DATA() earlier but then noticed
there is no use on the READ_ONCE in that particular call, so ditched the
idea.  I think it does not matter much and should just use READ_ONCE also.

  reply	other threads:[~2020-07-09 21:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-09  6:10 [PATCH v2 bpf 0/2] bpf: net: Fixes in sk_user_data of reuseport_array Martin KaFai Lau
2020-07-09  6:11 ` [PATCH v2 bpf 1/2] bpf: net: Avoid copying sk_user_data of reuseport_array during sk_clone Martin KaFai Lau
2020-07-09 16:46   ` Jakub Sitnicki
2020-07-09 20:07   ` Daniel Borkmann
2020-07-09 21:27     ` Martin KaFai Lau [this message]
2020-07-09  6:11 ` [PATCH v2 bpf 2/2] bpf: net: Avoid incorrect bpf_sk_reuseport_detach call Martin KaFai Lau
2020-07-09 10:58   ` James Chapman
2020-07-09 18:47     ` Martin KaFai Lau
2020-07-09 20:07 ` [PATCH v2 bpf 0/2] bpf: net: Fixes in sk_user_data of reuseport_array Daniel Borkmann

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=20200709212716.fvuas7m5dvlotwnj@kafai-mbp \
    --to=kafai@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.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).