mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Florent Revest" <florent.revest@linux.dev>
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>,
	"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>,
	LKML <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: Wed, 16 Sep 2026 18:03:06 +0000	[thread overview]
Message-ID: <DLGXSR1YQPQS.3SMAU8ECAYUW1@gmail.com> (raw)
In-Reply-To: <DLGKT6Z7ULBJ.3SKG7CYVTUAJF@linux.dev>

On Wed Sep 16, 2026 at 7:52 AM UTC, Florent Revest wrote:
> On Wed Sep 16, 2026 at 5:29 AM UTC, Alexei Starovoitov wrote:
> > On Tue, Sep 15, 2026 at 11:39 AM Florent Revest
> > <florent.revest@linux.dev> wrote:
> > >
> > >
> > > 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.
> >
> > Hmm. Not sure I agree with your reasoning.
> > fmod_ret progs are called _before_ orig_call.
> > So fentry+fmod_ret are in the same category.
> > Adding/removing a prog to the trampoline causes regeneration
> > of the trampoline.
> > So cpus may execute different numbers of progs already.
> > The race is inevitable.
> > With 'patch all nops in old tramp' approach the only
> > additional race is some of the fentry/fmod_ret progs
> > will get skipped in old tramp.
> >
> > If the concern of a tiny window where old tramp is started
> > to be destroyed, then fentry prog is called and we patched
> > another fentry, but tramp will continue and execute orig_call,
> > then, yes, I see the issue, but it's a lot more subtle.
> > If I understood the concern correctly then let's add
> > another 'jump over the call' nop in addition to
> > 'patch nops in front of all progs' and
> > let's patch 'jump over the call' _first_.
> > This way fentry/fmod_ret progs can never miss
> > execution of orig_call. They can be invoked "unncessarily".
> > They may execute though orig_call will not fire.
> > but that's an acceptable race. Better than not executing
> > fmod_ret while letting orig_call to go through.
> >
> > This is still simpler implementation than link-list all all extra book keeping.
>
> My concern wasn't orig_call running but rather progs that are still attached
> getting skipped. Say, fentry progs A and B are attached to a function and a
> task is sleeping in A. Someone attaches C, the old image gets all its nops
> patched, the task wakes up and skips B even though B was never detached.

so ? the orig call will also be patched and will be skipped.
So no observable difference from B pov.

> But it's a narrow window and it needs an attach/detach on that function to race
> with, so if you're OK with that behavior I'll respin v3 with your simpler
> version.

I don't think above scenario is anything to be concerned about.
So yeah. let's go with simpler solution.

  reply	other threads:[~2026-09-16 18:03 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
2026-09-16  5:29       ` Alexei Starovoitov
2026-09-16  7:52         ` Florent Revest
2026-09-16 18:03           ` Alexei Starovoitov [this message]
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=DLGXSR1YQPQS.3SMAU8ECAYUW1@gmail.com \
    --to=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=florent.revest@linux.dev \
    --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®