BPF List
 help / color / mirror / Atom feed
From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Anton Protopopov" <a.s.protopopov@gmail.com>
Cc: "Jose Fernandez (Anthropic)" <jose.fernandez@linux.dev>,
	"KP Singh" <kpsingh@kernel.org>,
	"Matt Bobrowski" <matt@bobrowski.net>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
	<bpf@vger.kernel.org>
Subject: Re: [PATCH bpf-next] bpf, lsm: Make bpf_lsm_get_retval_range() return void
Date: Tue, 24 Nov 2026 19:46:01 +0000	[thread overview]
Message-ID: <DN3P7509U44I.MLLYA1W3M3X9@gmail.com> (raw)
In-Reply-To: <CAGn_itxav5uLkQXCzgkqzgff+ZsFZrhO6rofZJJSqk7K7JPGWw@mail.gmail.com>

On Tue, Nov 24, 2026 at 06:15 AM Anton Protopopov <a.s.protopopov@gmail.com> wrote:
> I think that this makes sense to not list helpers, kfuncs, and
> verifier (and jits), they're building blocks for BPF programs
> themselves. I've checked that most of external functions called by
> verifier (~20 files) are not in the tagged list, five are, but look
> legitimate or "harmless" (security_bpf_prog_load,
> get_callchain_buffers, copy_from_kernel_nofault,
> bpf_set_dentry_xattr_locked, bpf_remove_dentry_xattr_locked).

For the verifier, yes. But copy_from_kernel_nofault() breaks ftrace.
A prog on it returns -EFAULT, and fentry on foo() detaches on x86:

  unregister_fentry()
    update_ftrace_direct_del()    returns 0
      ftrace_replace_code()       ftrace_bug(), no text poke
        ftrace_verify_code()      -EFAULT
    bpf_tramp_image_put()         foo() still calls the freed image

Let's deny it by name.
The two *_locked() are kfuncs without bpf_kfunc tag.
See specialize_kfunc().

The verifier also calls kfunc filters via a pointer. In visit_insn():

	if (ret == 0 && bpf_is_throw_kfunc(insn))
		sub->might_throw = true;

A prog on tracing_iter_filter() makes ret -EACCES for this one call.
Then check_func_call() skips the exception path of a global subprog.
That undoes commit 3d562d35a044.
This filter is in net/core/filter.c and has no "bpf_" prefix.
So funcs that take 'bpf_*' types have to go too.

> Blacklisting these removes about 200 hooks. (Blacklisting all
> kernel/bpf/* removes around 600 hooks. I wonder, maybe this make sense
> to do this, after all?)

Yes. All of kernel/bpf/*. btf_*() cannot stay either.
By the rules in fmodret.c these get tags too:

  target                  error    after the skip
  ----------------------  -------  ---------------------------------------
  btf_kfunc_check_flag()  -ENOENT  fentry/bpf_wq_set_callback saves 3 args
                                   of 4. aux is garbage. That undoes
                                   commit 3917b1012ee2
  bpf_mprog_detach()      -ENOENT  tcx_link_release() only warns.
                                   tcx_run() runs the freed prog

security_bpf*() and the bpf syscall entry need no tag. They stay.
So a prog can still block a bad bpf command.

Could you send a patch for the above?

> (Just in case, I am preparing patch for "fmodret -> functions
> returning pointers", so numbers can be a bit different later.)

Nice. Looking forward.

  reply	other threads:[~2026-11-24 19:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  4:28 [PATCH bpf-next] bpf, lsm: Make bpf_lsm_get_retval_range() return void Jose Fernandez (Anthropic)
2026-11-23 13:08 ` Anton Protopopov
2026-11-24  0:28 ` Alexei Starovoitov
2026-11-24 14:15   ` Anton Protopopov
2026-11-24 19:46     ` Alexei Starovoitov [this message]
2026-11-24 19:50       ` Anton Protopopov
2026-11-24  0:30 ` patchwork-bot+netdevbpf

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=DN3P7509U44I.MLLYA1W3M3X9@gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=a.s.protopopov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=jose.fernandez@linux.dev \
    --cc=kpsingh@kernel.org \
    --cc=matt@bobrowski.net \
    --cc=memxor@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