aboutsummaryrefslogtreecommitdiffstats
path: root/tools/bpf/bpftool/prog.c
diff options
context:
space:
mode:
authorYonghong Song <[email protected]>2022-11-20 19:54:37 +0000
committerAlexei Starovoitov <[email protected]>2022-11-20 23:45:26 +0000
commita35b9af4ec2c7f69286ef861fd2074a577e354cb (patch)
tree260c91a59720dc30887556f629b4851af8efedcb /tools/bpf/bpftool/prog.c
parentbpf: Add a kfunc to type cast from bpf uapi ctx to kernel ctx (diff)
downloadkernel-a35b9af4ec2c7f69286ef861fd2074a577e354cb.tar.gz
kernel-a35b9af4ec2c7f69286ef861fd2074a577e354cb.zip
bpf: Add a kfunc for generic type cast
Implement bpf_rdonly_cast() which tries to cast the object to a specified type. This tries to support use case like below: #define skb_shinfo(SKB) ((struct skb_shared_info *)(skb_end_pointer(SKB))) where skb_end_pointer(SKB) is a 'unsigned char *' and needs to be casted to 'struct skb_shared_info *'. The signature of bpf_rdonly_cast() looks like void *bpf_rdonly_cast(void *obj, __u32 btf_id) The function returns the same 'obj' but with PTR_TO_BTF_ID with btf_id. The verifier will ensure btf_id being a struct type. Since the supported type cast may not reflect what the 'obj' represents, the returned btf_id is marked as PTR_UNTRUSTED, so the return value and subsequent pointer chasing cannot be used as helper/kfunc arguments. Signed-off-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
Diffstat (limited to 'tools/bpf/bpftool/prog.c')
0 files changed, 0 insertions, 0 deletions