]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
bpf: Allow type tag BTF records to succeed other modifier records
authorEmil Tsalapatis <emil@etsalapatis.com>
Tue, 16 Jun 2026 06:14:54 +0000 (02:14 -0400)
committerAlexei Starovoitov <ast@kernel.org>
Mon, 22 Jun 2026 00:59:44 +0000 (17:59 -0700)
commit39799c63578ec64488e14aced9ea07af6f958f35
treeefc1942a47940cc0142faa8d4b56b5e9aa752cf7
parenta933bade82b9cd9197c6c9a390623cfb1f8c0da7
bpf: Allow type tag BTF records to succeed other modifier records

llvm commit [1] allowed attaching type tag records to modifier BTF
records. This is useful for using typedefs that encompass a base type
and a type tag, e.g.:

typedef struct rbtree __arena rbtree_t;

Modify btf_check_type_tags() so that it allows this sequence of records.
The function now only checks for record loops in BTF modifier record
chains. Rename to btf_check_modifier_chain_length to reflect this.

Also expand the BTF modifier traversal code to take into account that
type record can be interleaved with other modifier records. In effect
this means traversing all modifiers to collect the type tags.

Also modify existing selftests to now accept modifier records (const,
typedef) that point to type tag records.

[1] https://github.com/llvm/llvm-project/pull/203089

Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com>
Link: https://lore.kernel.org/r/20260616061454.7869-1-emil@etsalapatis.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/btf.c
tools/testing/selftests/bpf/prog_tests/btf.c