]> www.infradead.org Git - users/jedix/linux-maple.git/commit
bpf: look into the types of the fields of a struct type recursively.
authorKui-Feng Lee <thinker.li@gmail.com>
Thu, 23 May 2024 17:41:58 +0000 (10:41 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 4 Jun 2024 03:52:42 +0000 (20:52 -0700)
commit64e8ee814819f21beeeda00d4119221443d77992
tree589335220e243aedf7c9d235ba9cb1a52218ea5a
parent994796c0256c4001633488fd24c3d54691949f8d
bpf: look into the types of the fields of a struct type recursively.

The verifier has field information for specific special types, such as
kptr, rbtree root, and list head. These types are handled
differently. However, we did not previously examine the types of fields of
a struct type variable. Field information records were not generated for
the kptrs, rbtree roots, and linked_list heads that are not located at the
outermost struct type of a variable.

For example,

  struct A {
    struct task_struct __kptr * task;
  };

  struct B {
    struct A mem_a;
  }

  struct B var_b;

It did not examine "struct A" so as not to generate field information for
the kptr in "struct A" for "var_b".

This patch enables BPF programs to define fields of these special types in
a struct type other than the direct type of a variable or in a struct type
that is the type of a field in the value type of a map.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Kui-Feng Lee <thinker.li@gmail.com>
Link: https://lore.kernel.org/r/20240523174202.461236-6-thinker.li@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/btf.c