diff options
author | Feng Zhou <[email protected]> | 2023-04-20 11:27:34 +0800 |
---|---|---|
committer | Alexei Starovoitov <[email protected]> | 2023-04-19 21:29:39 -0700 |
commit | 2569c7b8726fc06d946a4f999fb1be15b68f3f3c (patch) | |
tree | 527655701fd522478922029e1af75d45352df4c0 | |
parent | 2ddade322925641ee2a75f13665c51f2e74d7791 (diff) |
bpf: support access variable length array of integer type
After this commit:
bpf: Support variable length array in tracing programs (9c5f8a1008a1)
Trace programs can access variable length array, but for structure
type. This patch adds support for integer type.
Example:
Hook load_balance
struct sched_domain {
...
unsigned long span[];
}
The access: sd->span[0].
Co-developed-by: Chengming Zhou <[email protected]>
Signed-off-by: Chengming Zhou <[email protected]>
Signed-off-by: Feng Zhou <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
-rw-r--r-- | kernel/bpf/btf.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 027f9f8a3551..a0887ee44e89 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -6157,11 +6157,13 @@ again: if (off < moff) goto error; - /* Only allow structure for now, can be relaxed for - * other types later. - */ + /* allow structure and integer */ t = btf_type_skip_modifiers(btf, array_elem->type, NULL); + + if (btf_type_is_int(t)) + return WALK_SCALAR; + if (!btf_type_is_struct(t)) goto error; |