aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/bpf/syscall.c
diff options
context:
space:
mode:
authorSong Liu <songliubraving@fb.com>2018-12-12 12:37:46 -0500
committerDaniel Borkmann <daniel@iogearbox.net>2018-12-13 06:22:28 -0500
commitc872bdb38febb4c31ece3599c52cf1f833b89f4e (patch)
treec1c80b2023415abfa68f19e8ac66d6f36f3a35bb /kernel/bpf/syscall.c
parent0ad379ffd654aa4348fdffa33aada4c9de76a22e (diff)
bpf: include sub program tags in bpf_prog_info
Changes v2 -> v3: 1. remove check for bpf_dump_raw_ok(). Changes v1 -> v2: 1. Fix error path as Martin suggested. This patch adds nr_prog_tags and prog_tags to bpf_prog_info. This is a reliable way for user space to get tags of all sub programs. Before this patch, user space need to find sub program tags via kallsyms. This feature will be used in BPF introspection, where user space queries information about BPF programs via sys_bpf. Signed-off-by: Song Liu <songliubraving@fb.com> Acked-by: Martin KaFai Lau <kafai@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'kernel/bpf/syscall.c')
-rw-r--r--kernel/bpf/syscall.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index b7c585838c72..7f1410d6fbe9 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -2315,6 +2315,28 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
2315 } 2315 }
2316 } 2316 }
2317 2317
2318 ulen = info.nr_prog_tags;
2319 info.nr_prog_tags = prog->aux->func_cnt ? : 1;
2320 if (ulen) {
2321 __u8 __user (*user_prog_tags)[BPF_TAG_SIZE];
2322 u32 i;
2323
2324 user_prog_tags = u64_to_user_ptr(info.prog_tags);
2325 ulen = min_t(u32, info.nr_prog_tags, ulen);
2326 if (prog->aux->func_cnt) {
2327 for (i = 0; i < ulen; i++) {
2328 if (copy_to_user(user_prog_tags[i],
2329 prog->aux->func[i]->tag,
2330 BPF_TAG_SIZE))
2331 return -EFAULT;
2332 }
2333 } else {
2334 if (copy_to_user(user_prog_tags[0],
2335 prog->tag, BPF_TAG_SIZE))
2336 return -EFAULT;
2337 }
2338 }
2339
2318done: 2340done:
2319 if (copy_to_user(uinfo, &info, info_len) || 2341 if (copy_to_user(uinfo, &info, info_len) ||
2320 put_user(info_len, &uattr->info.info_len)) 2342 put_user(info_len, &uattr->info.info_len))