Skip to content

Commit 2f3480e

Browse files
liu-song-6gregkh
authored andcommitted
bpf: fix panic in stack_map_get_build_id() on i386 and arm32
[ Upstream commit beaf3d1 ] 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: 615755a (" 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 06b919a commit 2f3480e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎kernel/bpf/stackmap.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ static int stack_map_get_build_id(struct vm_area_struct *vma,
260260
return -EFAULT; /* page not mapped */
261261

262262
ret = -EINVAL;
263-
page_addr = page_address(page);
263+
page_addr = kmap_atomic(page);
264264
ehdr = (Elf32_Ehdr *)page_addr;
265265

266266
/* compare magic x7f "ELF" */
@@ -276,6 +276,7 @@ static int stack_map_get_build_id(struct vm_area_struct *vma,
276276
else if (ehdr->e_ident[EI_CLASS] == ELFCLASS64)
277277
ret = stack_map_get_build_id_64(page_addr, build_id);
278278
out:
279+
kunmap_atomic(page_addr);
279280
put_page(page);
280281
return ret;
281282
}

0 commit comments

Comments
 (0)