Re: [PATCH] bpf, cgroup: fix cgroup struct_ops query for a second attach type
From: Amery Hung
Date: Wed Sep 30 2026 - 18:19:33 EST
On Wed, Sep 30, 2026 at 6:52 AM Shakeel Butt <shakeel.butt@xxxxxxxxx> wrote:
>
> Two things in __cgroup_bpf_query() work only because CGROUP_TCP_SOCK_OPS is
> the only one struct_ops attach type.
>
> It calls cgroup_bpf_enabled(atype) with an atype that
> find_atype_by_struct_ops_id() works out at runtime. That macro is an asm
> goto and needs a constant. Today the compiler can see there is only one
> value; add a second type and the build breaks with "impossible constraint in
> 'asm'". Add cgroup_bpf_enabled_runtime(), which reads the key instead, and
> use it here. This is a syscall path, so the cost does not matter.
>
> And find_atype_by_struct_ops_id() matches on type_id alone. An attach type
> whose subsystem is not built keeps type_id 0, so a query for type 0 finds it
> and returns success with nothing instead of -ENOENT. Skip such slots.
>
> Fixes: 369d9dcd8fb8 ("bpf: Add infrastructure to support attaching struct_ops to cgroups")
> Signed-off-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>
> Acked-by: Yafang Shao <laoar.shao@xxxxxxxxx>
Reviewed-by: Amery Hung <ameryhung@xxxxxxxxx>