bpf: Add a kfunc to type cast from bpf uapi ctx to kernel ctx
authorYonghong Song <yhs@fb.com>
Sun, 20 Nov 2022 19:54:32 +0000 (11:54 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 20 Nov 2022 23:43:37 +0000 (15:43 -0800)
commitfd264ca020948a743e4c36731dfdecc4a812153c
tree9a615b76021a3dcebdd178438bab629077e14962
parentcfe1456440c8feaf6558577a400745d774418379
bpf: Add a kfunc to type cast from bpf uapi ctx to kernel ctx

Implement bpf_cast_to_kern_ctx() kfunc which does a type cast
of a uapi ctx object to the corresponding kernel ctx. Previously
if users want to access some data available in kctx but not
in uapi ctx, bpf_probe_read_kernel() helper is needed.
The introduction of bpf_cast_to_kern_ctx() allows direct
memory access which makes code simpler and easier to understand.

Signed-off-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/r/20221120195432.3113982-1-yhs@fb.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/btf.h
kernel/bpf/btf.c
kernel/bpf/helpers.c
kernel/bpf/verifier.c