Re: [PATCH v3 bpf-next 01/18] bpf: Add BTF ID sets for fmod_ret targets

From: Anton Protopopov

Date: Wed Nov 11 2026 - 05:40:20 EST


On Wed, Nov 11, 2026 at 9:01 AM <bot+bpf-ci@xxxxxxxxxx> wrote:
>
> > bpf: Add BTF ID sets for fmod_ret targets
>
> TL;DR: Comment nit only: the BTF_SET8_FMODRET comment (also in tools/include)
> says the set governs fentry/fexit attachment, but non-sleepable fentry/fexit
> never consult it. It could mislead readers.
>
> > diff --git a/include/linux/btf_ids.h b/include/linux/btf_ids.h
> > --- a/include/linux/btf_ids.h
> > +++ b/include/linux/btf_ids.h
>
> [ ... ]
>
> > @@ -13,6 +13,12 @@ struct btf_id_set {
> > /* This flag implies BTF_SET8 holds kfunc(s) */
> > #define BTF_SET8_KFUNCS (1 << 0)
> >
> > +/*
> > + * This flag implies BTF_SET8 holds functions which BPF fmod_ret, fentry and
> > + * fexit programs may attach to. Per-function flags: KF_SLEEPABLE only.
> > + */
> > +#define BTF_SET8_FMODRET (1 << 1)
> > +
>
> This isn't a bug, but does this comment describe the set accurately? It
> says the set holds functions that fmod_ret, fentry and fexit programs may
> attach to, which reads as if the set controls fentry/fexit attachment.
>
> The set is only read through btf_kfunc_is_modify_return(), which has two
> callers. bpf_check_attach_target() uses it for non-sleepable
> BPF_MODIFY_RETURN only:
>
> } else if (prog->expected_attach_type == BPF_MODIFY_RETURN) {
> ...
> if (btf_kfunc_is_modify_return(btf, btf_id, prog) ||
> !check_attach_modify_return(addr, tname))
> ret = 0;
>
> and btf_id_allow_sleepable() uses it for sleepable programs only, and
> requires KF_SLEEPABLE:
>
> u32 *flags = btf_kfunc_is_modify_return(btf, btf_id, prog);
> if (flags && (*flags & KF_SLEEPABLE))
> return 0;
>
> Non-sleepable fentry and fexit programs never look at the set. This
> remains true through the end of the series (6dc8474f6891 has the same two
> callers).
>
> The commit message ("the functions BPF fmod_ret programs may attach to ...
> KF_SLEEPABLE marks targets sleepable programs may attach to") and the
> resolve_btfids header comment ("the targets of BPF fmod_ret programs")
> describe it differently. Someone could read this comment and add a
> function to a BTF_FMODRET set to make fentry/fexit attach work, which would
> also allow fmod_ret programs to override its return value.
>
> Could the wording be along the lines of "the set holds fmod_ret targets,
> and KF_SLEEPABLE additionally lets sleepable fentry, fexit and fmod_ret
> programs attach"? The identical comment in tools/include/linux/btf_ids.h
> has the same problem.

Yes, I will fix it, and send on the next occasion.

>
> ---
> AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
> See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
>
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/42981885558