bpf: Add gpl_compatible flag to struct bpf_prog_info
authorJiri Olsa <jolsa@kernel.org>
Wed, 25 Apr 2018 17:41:06 +0000 (19:41 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 26 Apr 2018 20:36:11 +0000 (22:36 +0200)
Adding gpl_compatible flag to struct bpf_prog_info
so it can be dumped via bpf_prog_get_info_by_fd and
displayed via bpftool progs dump.

Alexei noticed 4-byte hole in struct bpf_prog_info,
so we put the u32 flags field in there, and we can
keep adding bit fields in there without breaking
user space.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
include/uapi/linux/bpf.h
kernel/bpf/syscall.c

index e6679393b6877801651640d66857c4899c41beea..da8801860c7d98f889a96ca1e0421c57c81159b6 100644 (file)
@@ -1060,6 +1060,7 @@ struct bpf_prog_info {
        __aligned_u64 map_ids;
        char name[BPF_OBJ_NAME_LEN];
        __u32 ifindex;
+       __u32 gpl_compatible:1;
        __u64 netns_dev;
        __u64 netns_ino;
 } __attribute__((aligned(8)));
index fe23dc5a3ec48be4215c39ef742c50a2bf3203bb..7bb4ff1c770a70394b261248bf42b9ebf24363c1 100644 (file)
@@ -1914,6 +1914,7 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
        info.load_time = prog->aux->load_time;
        info.created_by_uid = from_kuid_munged(current_user_ns(),
                                               prog->aux->user->uid);
+       info.gpl_compatible = prog->gpl_compatible;
 
        memcpy(info.tag, prog->tag, sizeof(prog->tag));
        memcpy(info.name, prog->aux->name, sizeof(prog->aux->name));