diff options
author | Martin KaFai Lau <kafai@fb.com> | 2018-05-04 17:49:52 -0400 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-05-09 11:25:13 -0400 |
commit | 62dab84c81a487d946a5fc37c6df541dd95cca38 (patch) | |
tree | bcfa804c58e189bf89226ed0c7afa1e23dfeb24c /kernel/bpf/syscall.c | |
parent | 78958fca7ead2f81b60a6827881c4866d1ed0c52 (diff) |
bpf: btf: Add struct bpf_btf_info
During BPF_OBJ_GET_INFO_BY_FD on a btf_fd, the current bpf_attr's
info.info is directly filled with the BTF binary data. It is
not extensible. In this case, we want to add BTF ID.
This patch adds "struct bpf_btf_info" which has the BTF ID as
one of its member. The BTF binary data itself is exposed through
the "btf" and "btf_size" members.
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Alexei Starovoitov <ast@fb.com>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r-- | kernel/bpf/syscall.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index 31c4092da277..e2aeb5e89f44 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c | |||
@@ -2021,6 +2021,21 @@ static int bpf_map_get_info_by_fd(struct bpf_map *map, | |||
2021 | return 0; | 2021 | return 0; |
2022 | } | 2022 | } |
2023 | 2023 | ||
2024 | static int bpf_btf_get_info_by_fd(struct btf *btf, | ||
2025 | const union bpf_attr *attr, | ||
2026 | union bpf_attr __user *uattr) | ||
2027 | { | ||
2028 | struct bpf_btf_info __user *uinfo = u64_to_user_ptr(attr->info.info); | ||
2029 | u32 info_len = attr->info.info_len; | ||
2030 | int err; | ||
2031 | |||
2032 | err = check_uarg_tail_zero(uinfo, sizeof(*uinfo), info_len); | ||
2033 | if (err) | ||
2034 | return err; | ||
2035 | |||
2036 | return btf_get_info_by_fd(btf, attr, uattr); | ||
2037 | } | ||
2038 | |||
2024 | #define BPF_OBJ_GET_INFO_BY_FD_LAST_FIELD info.info | 2039 | #define BPF_OBJ_GET_INFO_BY_FD_LAST_FIELD info.info |
2025 | 2040 | ||
2026 | static int bpf_obj_get_info_by_fd(const union bpf_attr *attr, | 2041 | static int bpf_obj_get_info_by_fd(const union bpf_attr *attr, |
@@ -2044,7 +2059,7 @@ static int bpf_obj_get_info_by_fd(const union bpf_attr *attr, | |||
2044 | err = bpf_map_get_info_by_fd(f.file->private_data, attr, | 2059 | err = bpf_map_get_info_by_fd(f.file->private_data, attr, |
2045 | uattr); | 2060 | uattr); |
2046 | else if (f.file->f_op == &btf_fops) | 2061 | else if (f.file->f_op == &btf_fops) |
2047 | err = btf_get_info_by_fd(f.file->private_data, attr, uattr); | 2062 | err = bpf_btf_get_info_by_fd(f.file->private_data, attr, uattr); |
2048 | else | 2063 | else |
2049 | err = -EINVAL; | 2064 | err = -EINVAL; |
2050 | 2065 | ||