History

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.

Song Liu committed 7 years ago

Commit beaf3d11 parent f98937c1 file · +2 −1Browse files

Showing the changes to kernel/bpf/stackmap.c (1 of 1 file). Show all

Unified · Split

kernel/bpf/stackmap.c+2−1
@@ -260,7 +260,7 @@ static int stack_map_get_build_id(struct vm_area_struct *vma, · 259 unmodified lines
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, · 9 unmodified lines
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 }