BPF List
 help / color / mirror / Atom feed
From: "Florent Revest" <florent.revest@linux.dev>
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
	"Alexei Starovoitov" <alexei.starovoitov@gmail.com>
Cc: "bpf" <bpf@vger.kernel.org>,
	"Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Martin KaFai Lau" <martin.lau@linux.dev>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"Jiri Olsa" <jolsa@kernel.org>, "KP Singh" <kpsingh@kernel.org>,
	"Emil Tsalapatis" <emil@etsalapatis.com>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	"Jose Fernandez" <jose.fernandez@linux.dev>,
	"LKML" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH bpf] bpf: Keep progs alive until the trampoline image calling them is freed
Date: Mon, 31 Aug 2026 20:58:29 +0000	[thread overview]
Message-ID: <DL3FIBQNP6AU.1HO08FMI292UX@linux.dev> (raw)
In-Reply-To: <DL2S878KSOI5.1SZMLIAWMCNUJ@gmail.com>

On Mon Aug 31, 2026 at 2:43 AM UTC, Kumar Kartikeya Dwivedi wrote:
> On Sun Aug 30, 2026 at 3:21 PM CEST, Alexei Starovoitov wrote:
> > On Sun, Aug 30, 2026 at 3:41 AM Kumar Kartikeya Dwivedi
> > <memxor@gmail.com> wrote:
> >>
> >> Overall, looks good to me. Thanks for the fix!
> >>
> >> Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> >>
> >> Note for whoever applies this: please add Reported-by: tag for Sechang as well.
> >> Optionally, wordsmith the commit log with the suggestion above.
> >
> > Hold on. I don't think we can proceed with this fix.
> > It defeats the point of fexit jmp patching and keeps progs
> > pinned until a sleepable kernel function that were attached to
> > will return. Which means that the tracing prog attached to "unlucky" kernel
> > function that sleeps for an hour will stay pinned for an hour.
> > Let's think of a different way of fixing the race.
>
> I don't have background on the original commit being fixed, but is that really
> realistic? Or worrisome even if it happens in practice, since worst case the
> program refcounts remains raised for that duration?
>
> We have similar worst case for programs too (e.g. using bpf_copy_from_user on
> user controlled buffer in, say, LSM progs). At least here we won't be extending
> any RCU flavored GP.
>
> That said I will think about alternative fixes in the meantime, if we accept the
> premise that we don't want to pin program references in the image and keep their
> lifetimes decoupled.

How about having old trampolines skip freed programs instead of keeping
them alive ?

For example, bpf_tramp_image could hold one RCU managed prog pointer per
prog it calls and we could JIT trampolines that'd pass that slot to
__bpf_prog_enter*() instead of the prog itself.

The enter helpers could rcu_dereference() the prog under their
rcu_read_lock()/rcu_read_lock_trace() and return 0 when it is NULL.
Would that work ?

  reply	other threads:[~2026-08-31 20:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-19 12:22 [PATCH bpf] bpf: Keep progs alive until the trampoline image calling them is freed Florent Revest (Anthropic)
2026-08-20 15:26 ` Junseo Lim
     [not found]   ` <bc0edb11e07e0f6147e9c552805d0029c7aec7fc@linux.dev>
2026-08-21  7:58     ` Junseo Lim
2026-08-31 21:07       ` Florent Revest
2026-08-20 16:19 ` Leon Hwang
2026-08-30 10:40 ` Kumar Kartikeya Dwivedi
2026-08-30 13:21   ` Alexei Starovoitov
2026-08-31  2:43     ` Kumar Kartikeya Dwivedi
2026-08-31 20:58       ` Florent Revest [this message]
2026-09-02  5:57         ` Alexei Starovoitov
2026-09-02 10:15           ` Florent Revest
2026-09-02 22:06             ` Alexei Starovoitov
2026-09-02 23:25               ` Florent Revest
2026-09-03  0:48                 ` Alexei Starovoitov
2026-08-31 16:40 ` Jiri Olsa
2026-08-31 20:43   ` Florent Revest

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=DL3FIBQNP6AU.1HO08FMI292UX@linux.dev \
    --to=florent.revest@linux.dev \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=jose.fernandez@linux.dev \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=paulmck@kernel.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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