Commit a4dc1ce0 authored by Song Liu's avatar Song Liu Committed by Greg Kroah-Hartman

bpf: fix panic in stack_map_get_build_id() on i386 and arm32

[ Upstream commit beaf3d19 ]

As Naresh reported, test_stacktrace_build_id() causes panic on i386 and
arm32 systems. This is caused by page_address() returns NULL in certain

This patch fixes this error by using kmap_atomic/kunmap_atomic instead
of page_address.

Fixes: 615755a7 (" bpf: extend stackmap to save binary_build_id+offset instead of address")
Reported-by: Naresh Kamboju's avatarNaresh Kamboju <>
Signed-off-by: 's avatarSong Liu <>
Signed-off-by: 's avatarDaniel Borkmann <>
Signed-off-by: 's avatarSasha Levin <>
parent 5938484d
......@@ -260,7 +260,7 @@ static int stack_map_get_build_id(struct vm_area_struct *vma,
return -EFAULT; /* page not mapped */
ret = -EINVAL;
page_addr = page_address(page);
page_addr = kmap_atomic(page);
ehdr = (Elf32_Ehdr *)page_addr;
/* compare magic x7f "ELF" */
......@@ -276,6 +276,7 @@ static int stack_map_get_build_id(struct vm_area_struct *vma,
else if (ehdr->e_ident[EI_CLASS] == ELFCLASS64)
ret = stack_map_get_build_id_64(page_addr, build_id);
return ret;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment