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
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, · 9 unmodified lines
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}