public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 2/4] bpf: Introduce __bpf_kfunc_mark_deprecated annotation
Date: Sat, 18 Apr 2026 18:06:41 +0000	[thread overview]
Message-ID: <20260418180642.14D95C19424@smtp.kernel.org> (raw)
In-Reply-To: <20260418171701.610025-3-memxor@gmail.com>

Sashiko AI review found 1 potential issue(s):
- [Medium] Programs loaded without BTF will silently bypass deprecation warnings.
--

commit 90e501a1948d112dbb3b96a16249f1f76f84b290
Author: Kumar Kartikeya Dwivedi <memxor@gmail.com>

bpf: Introduce __bpf_kfunc_mark_deprecated annotation

This commit introduces the __bpf_kfunc_mark_deprecated macro to annotate
deprecated kfuncs with a replacement. It applies this annotation to existing
impl-suffixed kfuncs and modifies the verifier to emit warnings when these
deprecated kfuncs are used.

> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c

[ ... ]

> @@ -12987,6 +12987,45 @@ static int check_return_code(struct bpf_verifier_env *env, int regno, const char
>  static int process_bpf_exit_full(struct bpf_verifier_env *env,
>  				 bool *do_print_state, bool exception_exit);
>  
> +static void warn_for_deprecated_kfuncs(struct bpf_verifier_env *env,
> +				       struct bpf_kfunc_call_arg_meta *meta,
> +				       int insn_idx, s16 offset)
> +{
> +	const struct bpf_line_info *linfo;
> +	const char *replacement;
> +	const struct btf_type *t;
> +	struct bpf_kfunc_desc *desc;
> +	const char *file;
> +	int line_num;
> +
> +	if (!env->prog->aux->btf)
> +		return;

Will programs loaded without BTF silently bypass the deprecation warning?

The kfunc deprecation tags are stored in the kernel or module BTF
(meta->btf), not the program's BTF.

If we return early here, we skip evaluating the tag entirely. There is a
fallback branch below that handles missing line info which could be used to
emit the warning even if the program doesn't have BTF.

> +
> +	t = btf_type_by_id(meta->btf, meta->func_id);
> +	replacement = btf_find_decl_tag_value(meta->btf, t, -1, BPF_KFUNC_DECL_TAG_DEPRECATED);

[ ... ]

> +	linfo = bpf_find_linfo(env->prog, insn_idx);
> +	if (linfo) {
> +		bpf_get_linfo_file_line(env->prog->aux->btf, linfo, &file, NULL, &line_num);
> +		warn(env, "%s:%d (insn #%d) uses deprecated kfunc %s(), which will be removed.\n",
> +		     file, line_num, insn_idx, meta->func_name);
> +	} else {
> +		warn(env, "(insn #%d) uses deprecated kfunc %s(), which will be removed.\n",
> +		     insn_idx, meta->func_name);
> +	}
> +
> +	warn(env, "Switch to kfunc %s() instead.\n", replacement);
> +	warn(env, "For older kernels, choose the correct kfunc using bpf_ksym_exists().\n");
> +
> +	desc->warned_deprecated = true;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260418171701.610025-1-memxor@gmail.com?part=2

  reply	other threads:[~2026-04-18 18:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-18 17:16 [PATCH bpf-next v3 0/4] Add support to emit verifier warnings Kumar Kartikeya Dwivedi
2026-04-18 17:16 ` [PATCH bpf-next v3 1/4] bpf: Add support for verifier warning messages Kumar Kartikeya Dwivedi
2026-04-18 17:42   ` sashiko-bot
2026-04-18 20:33     ` Kumar Kartikeya Dwivedi
2026-04-20 13:37   ` Mykyta Yatsenko
2026-04-20 15:26     ` Kumar Kartikeya Dwivedi
2026-04-18 17:16 ` [PATCH bpf-next v3 2/4] bpf: Introduce __bpf_kfunc_mark_deprecated annotation Kumar Kartikeya Dwivedi
2026-04-18 18:06   ` sashiko-bot [this message]
2026-04-18 20:34     ` Kumar Kartikeya Dwivedi
2026-04-20 14:21   ` Mykyta Yatsenko
2026-04-20 15:27     ` Kumar Kartikeya Dwivedi
2026-04-20 18:15   ` David Faust
2026-04-20 18:19     ` Kumar Kartikeya Dwivedi
2026-04-18 17:16 ` [PATCH bpf-next v3 3/4] libbpf: Request verifier warnings for object loads Kumar Kartikeya Dwivedi
2026-04-18 18:35   ` sashiko-bot
2026-04-18 20:38     ` Kumar Kartikeya Dwivedi
2026-04-20 13:57   ` Mykyta Yatsenko
2026-04-20 15:23     ` Kumar Kartikeya Dwivedi
2026-04-20 15:49       ` Alexei Starovoitov
2026-04-18 17:16 ` [PATCH bpf-next v3 4/4] selftests/bpf: Test verifier warning logging Kumar Kartikeya Dwivedi
2026-04-18 18:45   ` sashiko-bot
2026-04-18 20:39     ` Kumar Kartikeya Dwivedi

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=20260418180642.14D95C19424@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=memxor@gmail.com \
    --cc=sashiko@lists.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