This patch adds special BPF_RB_{ROOT,NODE} btf_field_types similar to BPF_LIST_{HEAD,NODE}, adds the necessary plumbing to detect the new types, and adds bpf_rb_root_free function for freeing bpf_rb_root in map_values. structs bpf_rb_root and bpf_rb_node are opaque types meant to obscure structs rb_root_cached rb_node, respectively. btf_struct_access will prevent BPF programs from touching these special fields automatically now that they're recognized. btf_check_and_fixup_fields now groups list_head and rb_root together as "graph root" fields and {list,rb}_node as "graph node", and does same ownership cycle checking as before. Note that this function does _not_ prevent ownership type mixups (e.g. rb_root owning list_node) - that's handled by btf_parse_graph_root. After this patch, a bpf program can have a struct bpf_rb_root in a map_value, but not add anything to nor do anything useful with it.
Showing the changes to include/uapi (1 of 8 files). Show all
Unified · Split
| @@ -6917,6 +6917,17 @@ struct bpf_list_node { · 6916 unmodified lines | |||
| 6917 | __u64 :64; | 6917 | __u64 :64; |
| 6918 | } __attribute__((aligned(8))); | 6918 | } __attribute__((aligned(8))); |
| 6919 | 6919 | ||
| 6920 | struct bpf_rb_root { | ||
| 6921 | __u64 :64; | ||
| 6922 | __u64 :64; | ||
| 6923 | } __attribute__((aligned(8))); | ||
| 6924 | |||
| 6925 | struct bpf_rb_node { | ||
| 6926 | __u64 :64; | ||
| 6927 | __u64 :64; | ||
| 6928 | __u64 :64; | ||
| 6929 | } __attribute__((aligned(8))); | ||
| 6930 | |||
| 6920 | struct bpf_sysctl { | 6931 | struct bpf_sysctl { |
| 6921 | __u32 write; /* Sysctl is being read (= 0) or written (= 1). | 6932 | __u32 write; /* Sysctl is being read (= 0) or written (= 1). |
| 6922 | * Allows 1,2,4-byte read, but no write. | 6933 | * Allows 1,2,4-byte read, but no write. |