All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Martin Lau <kafai@fb.com>
Cc: Andrii Nakryiko <andriin@fb.com>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Alexei Starovoitov <ast@fb.com>,
	"daniel@iogearbox.net" <daniel@iogearbox.net>,
	"andrii.nakryiko@gmail.com" <andrii.nakryiko@gmail.com>,
	Kernel Team <Kernel-team@fb.com>
Subject: Re: [Potential Spoof] [PATCH bpf-next] libbpf: add bpf_link__disconnect() API to preserve underlying BPF resource
Date: Wed, 18 Dec 2019 17:19:07 -0800	[thread overview]
Message-ID: <CAADnVQLmrvnv=R6shyLwS61s7kO7=X5WbRur2kWu96FZAWidQg@mail.gmail.com> (raw)
In-Reply-To: <20191218231215.kzrdnupxs3ybv2zh@kafai-mbp.dhcp.thefacebook.com>

On Wed, Dec 18, 2019 at 3:13 PM Martin Lau <kafai@fb.com> wrote:
>
> On Wed, Dec 18, 2019 at 02:50:39PM -0800, Andrii Nakryiko wrote:
> > There are cases in which BPF resource (program, map, etc) has to outlive
> > userspace program that "installed" it in the system in the first place.
> > When BPF program is attached, libbpf returns bpf_link object, which
> > is supposed to be destroyed after no longer necessary through
> > bpf_link__destroy() API. Currently, bpf_link destruction causes both automatic
> > detachment and frees up any resources allocated to for bpf_link in-memory
> > representation. This is inconvenient for the case described above because of
> > coupling of detachment and resource freeing.
> >
> > This patch introduces bpf_link__disconnect() API call, which marks bpf_link as
> > disconnected from its underlying BPF resouces. This means that when bpf_link
> > is destroyed later, all its memory resources will be freed, but BPF resource
> > itself won't be detached.
> >
> > This design allows to follow strict and resource-leak-free design by default,
> > while giving easy and straightforward way for user code to opt for keeping BPF
> > resource attached beyond lifetime of a bpf_link. For some BPF programs (i.e.,
> > FS-based tracepoints, kprobes, raw tracepoint, etc), user has to make sure to
> > pin BPF program to prevent kernel to automatically detach it on process exit.
> > This should typically be achived by pinning BPF program (or map in some cases)
> > in BPF FS.
> Thanks for the patch.
>
> Acked-by: Martin KaFai Lau <kafai@fb.com>

Applied. Thanks

      reply	other threads:[~2019-12-19  1:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-18 22:50 [PATCH bpf-next] libbpf: add bpf_link__disconnect() API to preserve underlying BPF resource Andrii Nakryiko
2019-12-18 23:12 ` [Potential Spoof] " Martin Lau
2019-12-19  1:19   ` Alexei Starovoitov [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='CAADnVQLmrvnv=R6shyLwS61s7kO7=X5WbRur2kWu96FZAWidQg@mail.gmail.com' \
    --to=alexei.starovoitov@gmail.com \
    --cc=Kernel-team@fb.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kafai@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 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.