diff options
author | Stanislav Fomichev <sdf@google.com> | 2019-01-16 17:03:16 -0500 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2019-01-17 10:42:35 -0500 |
commit | 4af396ae4836c4ecab61e975b8e61270c551894d (patch) | |
tree | 3ea744486f9d9c3582f038e5a04d0aac47812e3d | |
parent | 0b698005a9d11c0e91141ec11a2c4918a129f703 (diff) |
bpf: zero out build_id for BPF_STACK_BUILD_ID_IP
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>
-rw-r--r-- | kernel/bpf/stackmap.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c index f9df545e92f6..d43b14535827 100644 --- a/kernel/bpf/stackmap.c +++ b/kernel/bpf/stackmap.c | |||
@@ -314,6 +314,7 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs, | |||
314 | for (i = 0; i < trace_nr; i++) { | 314 | for (i = 0; i < trace_nr; i++) { |
315 | id_offs[i].status = BPF_STACK_BUILD_ID_IP; | 315 | id_offs[i].status = BPF_STACK_BUILD_ID_IP; |
316 | id_offs[i].ip = ips[i]; | 316 | id_offs[i].ip = ips[i]; |
317 | memset(id_offs[i].build_id, 0, BPF_BUILD_ID_SIZE); | ||
317 | } | 318 | } |
318 | return; | 319 | return; |
319 | } | 320 | } |
@@ -324,6 +325,7 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs, | |||
324 | /* per entry fall back to ips */ | 325 | /* per entry fall back to ips */ |
325 | id_offs[i].status = BPF_STACK_BUILD_ID_IP; | 326 | id_offs[i].status = BPF_STACK_BUILD_ID_IP; |
326 | id_offs[i].ip = ips[i]; | 327 | id_offs[i].ip = ips[i]; |
328 | memset(id_offs[i].build_id, 0, BPF_BUILD_ID_SIZE); | ||
327 | continue; | 329 | continue; |
328 | } | 330 | } |
329 | id_offs[i].offset = (vma->vm_pgoff << PAGE_SHIFT) + ips[i] | 331 | id_offs[i].offset = (vma->vm_pgoff << PAGE_SHIFT) + ips[i] |