mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Florent Revest" <florent.revest@linux.dev>
To: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>,
	<bpf@vger.kernel.org>, "Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>
Cc: "Martin KaFai Lau" <martin.lau@linux.dev>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
	"Song Liu" <song@kernel.org>,
	"Yonghong Song" <yonghong.song@linux.dev>,
	"Jiri Olsa" <jolsa@kernel.org>, "KP Singh" <kpsingh@kernel.org>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Leon Hwang" <leon.hwang@linux.dev>,
	"Junseo Lim" <zirajs7@gmail.com>,
	"Sechang Lim" <rhkrqnwk98@gmail.com>,
	"Puranjay Mohan" <puranjay@kernel.org>,
	"Xu Kuohai" <xukuohai@huaweicloud.com>,
	"Ilya Leoshkevich" <iii@linux.ibm.com>,
	"Hari Bathini" <hbathini@linux.ibm.com>,
	"Christophe Leroy" <chleroy@kernel.org>,
	"Naveen N Rao" <naveen@kernel.org>,
	"Björn Töpel" <bjorn@kernel.org>, "Pu Lehui" <pulehui@huawei.com>,
	"Tiezhu Yang" <yangtiezhu@loongson.cn>,
	"Hengqi Chen" <hengqi.chen@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf v2 1/2] bpf: Skip detached progs in trampoline images that are still in use
Date: Tue, 15 Sep 2026 18:39:30 +0000	[thread overview]
Message-ID: <DLG3Y32QQ9JU.3LNSYXLJIGH17@linux.dev> (raw)
In-Reply-To: <DLDHKKLCOAVR.3PHQ832S121Q2@gmail.com>

On Sat Sep 12, 2026 at 4:42 PM UTC, Alexei Starovoitov wrote:
> On Sat Sep 12, 2026 at 2:59 AM PDT, Florent Revest (Anthropic) wrote:
> > +struct bpf_tramp_skip {
> > +	struct bpf_prog *prog;
>
> prog pointer shouldn't be necessary.

[...]

> > +	void *nop;
> > +	void *target;
> > +};
> > +
> >  struct bpf_tramp_image {
> >  	void *image;
> >  	int size;
> > @@ -1374,8 +1389,27 @@ struct bpf_tramp_image {
> >  		struct rcu_head rcu;
> >  		struct work_struct work;
> >  	};
> > +	/* entry in tr->images, the image holds a reference on tr */
> > +	struct bpf_trampoline *tr;
> > +	struct list_head list;
> > +	struct bpf_tramp_skip *skips;
> > +	int nr_skips;
>
> I don't follow why you need link list and 'tr' pointer here.
> Also why keep ip_after_call ?
>
> Replace ip_after_call with array of bpf_tramp_skip { void *nop, *target; }
> and then in bpf_tramp_image_put() instead of ip_after_call do:
> for (i = 0; i < im->nr_skips; i++) {
> 	struct bpf_tramp_skip *skip = &im->skips[i];
>
> 	err = bpf_arch_text_poke(skip->nop, BPF_MOD_NOP, BPF_MOD_JUMP,
> 				 NULL, skip->target);
> }
>
> what am I missing?

Ah yeah, I tried to address that in the cover letter. Basically, if we patch
all the nops, tasks running in the old image could skip some progs that are
still attached. For fexit, that's already what happens with ip_after_call but
for fmod_ret it would be new and this would cause for example an LSM prog's
verdict to get skipped when another prog gets attached to the same hook. That's
why I thought that patching only the detached prog's nop would be better and
needed these extra pointers. But it's a bit of an edge case and I don't have a
strong opinion on it.

If you'd prefer the simpler version, I can do what you suggested here in v3. If
you'd rather only skip the detached progs, then yeah, I think ip_after_call
wasn't needed anymore and I should have dropped it too.

  reply	other threads:[~2026-09-15 18:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-12  9:59 [PATCH bpf v2 0/2] bpf: Fix use-after-free of progs detached from busy trampolines Florent Revest (Anthropic)
2026-09-12  9:59 ` [PATCH bpf v2 1/2] bpf: Skip detached progs in trampoline images that are still in use Florent Revest (Anthropic)
2026-09-12 11:11   ` bot+bpf-ci
2026-09-15 19:13     ` Florent Revest
2026-09-12 16:42   ` Alexei Starovoitov
2026-09-15 18:39     ` Florent Revest [this message]
2026-09-16  5:29       ` Alexei Starovoitov
2026-09-16  7:52         ` Florent Revest
2026-09-16 18:03           ` Alexei Starovoitov
2026-09-14  4:13   ` Junseo Lim
2026-09-15 17:59     ` Florent Revest
2026-09-12  9:59 ` [PATCH bpf v2 2/2] selftests/bpf: Detach a trampoline prog while a task sleeps before it Florent Revest (Anthropic)
2026-09-12 10:53   ` bot+bpf-ci
2026-09-15 19:14     ` 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=DLG3Y32QQ9JU.3LNSYXLJIGH17@linux.dev \
    --to=florent.revest@linux.dev \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chleroy@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=hbathini@linux.ibm.com \
    --cc=hengqi.chen@gmail.com \
    --cc=iii@linux.ibm.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=leon.hwang@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=naveen@kernel.org \
    --cc=pulehui@huawei.com \
    --cc=puranjay@kernel.org \
    --cc=rhkrqnwk98@gmail.com \
    --cc=song@kernel.org \
    --cc=xukuohai@huaweicloud.com \
    --cc=yangtiezhu@loongson.cn \
    --cc=yonghong.song@linux.dev \
    --cc=zirajs7@gmail.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

all inboxes | Powered by JetHome®