]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: btf: Add BPF_OBJ_GET_INFO_BY_FD support to BTF fd
authorMartin KaFai Lau <kafai@fb.com>
Wed, 18 Apr 2018 22:56:02 +0000 (15:56 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 19 Apr 2018 19:46:25 +0000 (21:46 +0200)
commit34c5c5ea944191851074efdcb184ba6566101d44
treece07ea8aa1bcf4a3c989d8a974a4413a97308c80
parenta69d50ac37521f25899ae3514248d9ff9a762c08
bpf: btf: Add BPF_OBJ_GET_INFO_BY_FD support to BTF fd

This patch adds BPF_OBJ_GET_INFO_BY_FD support to BTF fd.
The original BTF data, which was used to create the BTF fd during
the earlier BPF_BTF_LOAD call, will be returned.

The userspace is expected to allocate buffer
to info.info and the buffer size is set to info.info_len before
calling BPF_OBJ_GET_INFO_BY_FD.

The original BTF data is copied to the userspace buffer (info.info).
Only upto the user's specified info.info_len will be copied.

The original BTF data size is set to info.info_len.  The userspace
needs to check if it is bigger than its allocated buffer size.
If it is, the userspace should realloc with the kernel-returned
info.info_len and call the BPF_OBJ_GET_INFO_BY_FD again.

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Alexei Starovoitov <ast@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
include/linux/btf.h
kernel/bpf/btf.c
kernel/bpf/syscall.c