aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/bpf/stackmap.c
diff options
context:
space:
mode:
authorSong Liu <songliubraving@fb.com>2019-01-08 17:20:44 -0500
committerDaniel Borkmann <daniel@iogearbox.net>2019-01-10 10:02:17 -0500
commitbeaf3d1901f4ea46fbd5c9d857227d99751de469 (patch)
treef02f6f124dbc337ec1a556ddea4e1907fc556515 /kernel/bpf/stackmap.c
parentf98937c6bb73ae11717a15aec85c187d33ca5d34 (diff)
bpf: fix panic in stack_map_get_build_id() on i386 and arm32
As Naresh reported, test_stacktrace_build_id() causes panic on i386 and arm32 systems. This is caused by page_address() returns NULL in certain cases. This patch fixes this error by using kmap_atomic/kunmap_atomic instead of page_address. Fixes: 615755a77b24 (" bpf: extend stackmap to save binary_build_id+offset instead of address") Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org> Signed-off-by: Song Liu <songliubraving@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'kernel/bpf/stackmap.c')
-rw-r--r--kernel/bpf/stackmap.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
index 90daf285de03..d9e2483669d0 100644
--- a/kernel/bpf/stackmap.c
+++ b/kernel/bpf/stackmap.c
@@ -260,7 +260,7 @@ static int stack_map_get_build_id(struct vm_area_struct *vma,
260 return -EFAULT; /* page not mapped */ 260 return -EFAULT; /* page not mapped */
261 261
262 ret = -EINVAL; 262 ret = -EINVAL;
263 page_addr = page_address(page); 263 page_addr = kmap_atomic(page);
264 ehdr = (Elf32_Ehdr *)page_addr; 264 ehdr = (Elf32_Ehdr *)page_addr;
265 265
266 /* compare magic x7f "ELF" */ 266 /* compare magic x7f "ELF" */
@@ -276,6 +276,7 @@ static int stack_map_get_build_id(struct vm_area_struct *vma,
276 else if (ehdr->e_ident[EI_CLASS] == ELFCLASS64) 276 else if (ehdr->e_ident[EI_CLASS] == ELFCLASS64)
277 ret = stack_map_get_build_id_64(page_addr, build_id); 277 ret = stack_map_get_build_id_64(page_addr, build_id);
278out: 278out:
279 kunmap_atomic(page_addr);
279 put_page(page); 280 put_page(page);
280 return ret; 281 return ret;
281} 282}