Commit 2569c7b8 authored by Feng Zhou's avatar Feng Zhou Committed by Alexei Starovoitov

bpf: support access variable length array of integer type

After this commit:
bpf: Support variable length array in tracing programs (9c5f8a10)
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: default avatarChengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: default avatarChengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: default avatarFeng Zhou <zhoufeng.zf@bytedance.com>
Link: https://lore.kernel.org/r/20230420032735.27760-2-zhoufeng.zf@bytedance.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 2ddade32
...@@ -6157,11 +6157,13 @@ static int btf_struct_walk(struct bpf_verifier_log *log, const struct btf *btf, ...@@ -6157,11 +6157,13 @@ static int btf_struct_walk(struct bpf_verifier_log *log, const struct btf *btf,
if (off < moff) if (off < moff)
goto error; goto error;
/* Only allow structure for now, can be relaxed for /* allow structure and integer */
* other types later.
*/
t = btf_type_skip_modifiers(btf, array_elem->type, t = btf_type_skip_modifiers(btf, array_elem->type,
NULL); NULL);
if (btf_type_is_int(t))
return WALK_SCALAR;
if (!btf_type_is_struct(t)) if (!btf_type_is_struct(t))
goto error; goto error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment