]> git.baikalelectronics.ru Git - kernel.git/commitdiff
bpf: fix panic in stack_map_get_build_id() on i386 and arm32
authorSong Liu <songliubraving@fb.com>
Tue, 8 Jan 2019 22:20:44 +0000 (14:20 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 10 Jan 2019 15:02:17 +0000 (16:02 +0100)
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: 83a356ec2db3 (" 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>
kernel/bpf/stackmap.c

index 90daf285de032a78d565df9be243f7d2f695f35d..d9e2483669d0b6bf16db813084d10ee17b8bf028 100644 (file)
@@ -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);
 out:
+       kunmap_atomic(page_addr);
        put_page(page);
        return ret;
 }