]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
bpf: zero out build_id for BPF_STACK_BUILD_ID_IP
authorStanislav Fomichev <sdf@google.com>
Wed, 16 Jan 2019 22:03:16 +0000 (14:03 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 17 Jan 2019 15:42:35 +0000 (16:42 +0100)
When returning BPF_STACK_BUILD_ID_IP from stack_map_get_build_id_offset,
make sure that build_id field is empty. Since we are using percpu
free list, there is a possibility that we might reuse some previous
bpf_stack_build_id with non-zero build_id.

Fixes: 615755a77b24 ("bpf: extend stackmap to save binary_build_id+offset instead of address")
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/stackmap.c

index f9df545e92f6e7307c3871c6addc24f74450f62f..d43b145358275d314d02939f674a2ecc719852b2 100644 (file)
@@ -314,6 +314,7 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,
                for (i = 0; i < trace_nr; i++) {
                        id_offs[i].status = BPF_STACK_BUILD_ID_IP;
                        id_offs[i].ip = ips[i];
+                       memset(id_offs[i].build_id, 0, BPF_BUILD_ID_SIZE);
                }
                return;
        }
@@ -324,6 +325,7 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,
                        /* per entry fall back to ips */
                        id_offs[i].status = BPF_STACK_BUILD_ID_IP;
                        id_offs[i].ip = ips[i];
+                       memset(id_offs[i].build_id, 0, BPF_BUILD_ID_SIZE);
                        continue;
                }
                id_offs[i].offset = (vma->vm_pgoff << PAGE_SHIFT) + ips[i]