BPF List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Puranjay Mohan <puranjay@kernel.org>, bpf@vger.kernel.org
Cc: Puranjay Mohan <puranjay12@gmail.com>,
	Alexei Starovoitov <ast@kernel.org>,
	 Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau	 <martin.lau@kernel.org>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
		kernel-team@meta.com
Subject: Re: [PATCH bpf-next v2 1/9] bpf: Make KF_TRUSTED_ARGS the default for all kfuncs
Date: Wed, 31 Dec 2025 10:37:56 -0800	[thread overview]
Message-ID: <c1204513fe4da235d6b6b45eca9d0260a31e89ec.camel@gmail.com> (raw)
In-Reply-To: <20251231171118.1174007-2-puranjay@kernel.org>

On Wed, 2025-12-31 at 09:08 -0800, Puranjay Mohan wrote:
> Change the verifier to make trusted args the default requirement for
> all kfuncs by removing is_kfunc_trusted_args() assuming it be to always
> return true.
>
> This works because:
> 1. Context pointers (xdp_md, __sk_buff, etc.) are handled through their
>    own KF_ARG_PTR_TO_CTX case label and bypass the trusted check
> 2. Struct_ops callback arguments are already marked as PTR_TRUSTED during
>    initialization and pass is_trusted_reg()
> 3. KF_RCU kfuncs are handled separately via is_kfunc_rcu() checks at
>    call sites (always checked with || alongside is_kfunc_trusted_args)
>
> This simple change makes all kfuncs require trusted args by default
> while maintaining correct behavior for all existing special cases.
>
> Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
> ---

Acked-by: Eduard Zingerman <eddyz87@gmail.com>

Nit: I found two more textual appearances for KF_TRUSTED_ARGS:

  File: fs/bpf_fs_kfuncs.c
  71:65: * used in place of bpf_d_path() whenever possible. It enforces KF_TRUSTED_ARGS
  379:47:/* bpf_[set|remove]_dentry_xattr.* hooks have KF_TRUSTED_ARGS and

  File: include/linux/bpf.h
  756:15:  * passed to KF_TRUSTED_ARGS kfuncs or BPF helper functions.

  File: kernel/bpf/verifier.c
  12622:39:        * enforce strict matching for plain KF_TRUSTED_ARGS kfuncs by default,

  File: tools/testing/selftests/bpf/progs/cpumask_failure.c
  113:21:  /* NULL passed to KF_TRUSTED_ARGS kfunc. */

>  Documentation/bpf/kfuncs.rst | 35 +++++++++++++++++------------------
>  kernel/bpf/verifier.c        | 14 +++-----------
>  2 files changed, 20 insertions(+), 29 deletions(-)
>
> diff --git a/Documentation/bpf/kfuncs.rst b/Documentation/bpf/kfuncs.rst
> index e38941370b90..22b5a970078c 100644
> --- a/Documentation/bpf/kfuncs.rst
> +++ b/Documentation/bpf/kfuncs.rst
> @@ -241,25 +241,23 @@ both are orthogonal to each other.
>  The KF_RELEASE flag is used to indicate that the kfunc releases the pointer
>  passed in to it. There can be only one referenced pointer that can be passed
>  in. All copies of the pointer being released are invalidated as a result of
> -invoking kfunc with this flag. KF_RELEASE kfuncs automatically receive the
> -protection afforded by the KF_TRUSTED_ARGS flag described below.
> +invoking kfunc with this flag.
>
> -2.4.4 KF_TRUSTED_ARGS flag
> ---------------------------
> +2.4.4 KF_TRUSTED_ARGS (default behavior)
> +-----------------------------------------

Nit:
I think section should be renamed to 'kfunc parameters' and moved to a
separate section before '2.2 Annotating kfunc parameters'.
Sorry, should have commented about this yesterday.

[...]

  parent reply	other threads:[~2025-12-31 18:38 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-31 17:08 [PATCH bpf-next v2 0/9] bpf: Make KF_TRUSTED_ARGS default Puranjay Mohan
2025-12-31 17:08 ` [PATCH bpf-next v2 1/9] bpf: Make KF_TRUSTED_ARGS the default for all kfuncs Puranjay Mohan
2025-12-31 17:37   ` bot+bpf-ci
2025-12-31 18:37   ` Eduard Zingerman [this message]
2025-12-31 19:00     ` Puranjay Mohan
2025-12-31 19:10       ` Eduard Zingerman
2025-12-31 19:15         ` Puranjay Mohan
2026-01-02  0:15   ` Emil Tsalapatis
2025-12-31 17:08 ` [PATCH bpf-next v2 2/9] bpf: net: netfilter: Mark kfuncs accurately Puranjay Mohan
2025-12-31 17:08 ` [PATCH bpf-next v2 3/9] bpf: Remove redundant KF_TRUSTED_ARGS flag from all kfuncs Puranjay Mohan
2025-12-31 19:13   ` Eduard Zingerman
2026-01-02  0:19   ` Emil Tsalapatis
2025-12-31 17:08 ` [PATCH bpf-next v2 4/9] selftests: bpf: Update kfunc_param_nullable test for new error message Puranjay Mohan
2025-12-31 19:21   ` Eduard Zingerman
2026-01-02  1:45   ` Emil Tsalapatis
2025-12-31 17:08 ` [PATCH bpf-next v2 5/9] selftests: bpf: Update failure message for rbtree_fail Puranjay Mohan
2025-12-31 19:27   ` Eduard Zingerman
2025-12-31 19:44     ` Puranjay Mohan
2025-12-31 19:45       ` Eduard Zingerman
2026-01-02  1:44   ` Emil Tsalapatis
2025-12-31 17:08 ` [PATCH bpf-next v2 6/9] selftests: bpf: fix test_kfunc_dynptr_param Puranjay Mohan
2025-12-31 19:29   ` Eduard Zingerman
2025-12-31 19:39     ` Puranjay Mohan
2025-12-31 19:44       ` Eduard Zingerman
2025-12-31 23:29         ` Puranjay Mohan
2026-01-02  1:44   ` Emil Tsalapatis
2025-12-31 17:08 ` [PATCH bpf-next v2 7/9] selftests: bpf: fix cgroup_hierarchical_stats Puranjay Mohan
2025-12-31 19:40   ` Eduard Zingerman
2026-01-02  1:48   ` Emil Tsalapatis
2025-12-31 17:08 ` [PATCH bpf-next v2 8/9] bpf: xfrm: drop dead NULL check in bpf_xdp_get_xfrm_state() Puranjay Mohan
2025-12-31 19:48   ` Eduard Zingerman
2025-12-31 17:08 ` [PATCH bpf-next v2 9/9] HID: bpf: drop dead NULL checks in kfuncs Puranjay Mohan
2025-12-31 18:20   ` Alexei Starovoitov
2025-12-31 18:25     ` Puranjay Mohan
2026-01-05 14:52       ` Benjamin Tissoires

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=c1204513fe4da235d6b6b45eca9d0260a31e89ec.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@meta.com \
    --cc=martin.lau@kernel.org \
    --cc=memxor@gmail.com \
    --cc=puranjay12@gmail.com \
    --cc=puranjay@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox