From: Anton Protopopov <a.s.protopopov@gmail.com>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v2 bpf-next 7/7] selftests/bpf: Test functions which must have no fmod_ret tag
Date: Thu, 26 Nov 2026 14:48:34 +0000 [thread overview]
Message-ID: <awhGwnquBmvvliHf@mail.gmail.com> (raw)
In-Reply-To: <sashiko-outbox-235702@kernel.org>
On 26/11/26 02:27PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Low] selftests/bpf: fmodret_untagged.c duplicates fmodret_retval.c
> BTF tag test
> --
>
> commit 6b9f59cbaa78b14e32ed408a9747440fae862df8
> Author: Anton Protopopov <a.s.protopopov@gmail.com>
>
> selftests/bpf: Test functions which must have no fmod_ret tag
>
> This commit adds a BPF selftest that loads vmlinux BTF and verifies that
> specific kernel functions are not tagged with bpf_fmodret_retval:.
>
> > diff --git a/tools/testing/selftests/bpf/prog_tests/fmodret_untagged.c b/tools/testing/selftests/bpf/prog_tests/fmodret_untagged.c
> > new file mode 100644
> > index 0000000000000..9f4b0586fe8f0
> > --- /dev/null
> > +++ b/tools/testing/selftests/bpf/prog_tests/fmodret_untagged.c
> > @@ -0,0 +1,58 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/* Functions which return errors, but which the build must not tag as fmod_ret targets */
> > +#include <test_progs.h>
> > +#include <bpf/btf.h>
> > +
> > +#define TAG "bpf_fmodret_retval:"
>
> [ ... ]
>
> > +/* Has the build tagged the function FUNC_ID, or any function if FUNC_ID is 0? */
> > +static bool tagged(const struct btf *btf, int func_id)
> > +{
> > + int id;
> > +
> > + for (id = 1; id < btf__type_cnt(btf); id++) {
> > + const struct btf_type *t = btf__type_by_id(btf, id);
> > + const char *name = btf__name_by_offset(btf, t->name_off);
> > +
> > + if (btf_is_decl_tag(t) && (!func_id || t->type == func_id) &&
> > + !strncmp(name, TAG, strlen(TAG)))
> > + return true;
> > + }
> > + return false;
> > +}
> > +
> > +void test_fmodret_untagged(void)
> > +{
> > + struct btf *btf;
> > + int i, id;
> > +
> > + btf = btf__load_vmlinux_btf();
> > + if (!ASSERT_OK_PTR(btf, "btf__load_vmlinux_btf"))
> > + return;
> > + if (!tagged(btf, 0)) {
> > + printf("%s:SKIP:no CONFIG_BPF_FMODRET_SCAN\n", __func__);
> > + test__skip();
> > + goto out;
> > + }
> > + for (i = 0; i < ARRAY_SIZE(funcs); i++) {
> > + id = btf__find_by_name_kind(btf, funcs[i], BTF_KIND_FUNC);
> > + if (ASSERT_GT(id, 0, funcs[i]))
> > + ASSERT_FALSE(tagged(btf, id), funcs[i]);
> > + }
> > +out:
> > + btf__free(btf);
> > +}
>
> [Severity: Low]
> This isn't a bug, but could these untagged vmlinux function checks be folded
> into tools/testing/selftests/bpf/prog_tests/fmodret_retval.c instead of adding
> a separate standalone test file?
>
> test_fmodret_retval() in that file already loads vmlinux_btf, checks for
> CONFIG_BPF_FMODRET_SCAN, and scans BTF_KIND_DECL_TAG entries for
> bpf_fmodret_retval: via tagged_errors(). Adjusting tagged_errors() to start at
> id = btf__base_btf(btf) ? btf__type_cnt(btf__base_btf(btf)) : 1 would let
> test_fmodret_retval() check these vmlinux functions directly without
> duplicating the BTF load, tag lookup, and skip handling.
Will do if v3 will be needed.
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20261126142915.1106330-1-a.s.protopopov@gmail.com?part=7
prev parent reply other threads:[~2026-11-26 14:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 14:29 [PATCH v2 bpf-next 0/7] Do not tag selected functions as fmodret targets Anton Protopopov
2026-11-26 14:29 ` [PATCH v2 bpf-next 1/7] selftests/bpf: Test the tag of vmlinux with do_epoll_create() Anton Protopopov
2026-11-26 14:29 ` [PATCH v2 bpf-next 2/7] resolve_btfids: Do not tag functions which work on BPF objects Anton Protopopov
2026-11-26 14:27 ` sashiko-bot
2026-11-26 14:42 ` Anton Protopopov
2026-11-26 14:29 ` [PATCH v2 bpf-next 3/7] resolve_btfids: Do not tag kfuncs and helpers Anton Protopopov
2026-11-26 14:29 ` [PATCH v2 bpf-next 4/7] resolve_btfids: Exclude a set of functions by name Anton Protopopov
2026-11-26 14:26 ` sashiko-bot
2026-11-26 14:44 ` Anton Protopopov
2026-11-26 14:29 ` [PATCH v2 bpf-next 5/7] resolve_btfids: Exclude bpf_*() and __bpf_*() of vmlinux Anton Protopopov
2026-11-26 15:01 ` bot+bpf-ci
2026-11-26 14:29 ` [PATCH v2 bpf-next 6/7] resolve_btfids: Exclude the code of kernel/bpf and of the JIT Anton Protopopov
2026-11-26 14:29 ` [PATCH v2 bpf-next 7/7] selftests/bpf: Test functions which must have no fmod_ret tag Anton Protopopov
2026-11-26 14:27 ` sashiko-bot
2026-11-26 14:48 ` Anton Protopopov [this message]
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=awhGwnquBmvvliHf@mail.gmail.com \
--to=a.s.protopopov@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@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