Skip to content

Commit b293dcc

Browse files
htbeginanakryiko
authored andcommitted
bpf: Use VM_MAP instead of VM_ALLOC for ringbuf
After commit 2fd3fb0 ("kasan, vmalloc: unpoison VM_ALLOC pages after mapping"), non-VM_ALLOC mappings will be marked as accessible in __get_vm_area_node() when KASAN is enabled. But now the flag for ringbuf area is VM_ALLOC, so KASAN will complain out-of-bound access after vmap() returns. Because the ringbuf area is created by mapping allocated pages, so use VM_MAP instead. After the change, info in /proc/vmallocinfo also changes from [start]-[end] 24576 ringbuf_map_alloc+0x171/0x290 vmalloc user to [start]-[end] 24576 ringbuf_map_alloc+0x171/0x290 vmap user Fixes: 457f443 ("bpf: Implement BPF ring buffer and verifier support for it") Reported-by: [email protected] Signed-off-by: Hou Tao <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent b7892f7 commit b293dcc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/bpf/ringbuf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static struct bpf_ringbuf *bpf_ringbuf_area_alloc(size_t data_sz, int numa_node)
104104
}
105105

106106
rb = vmap(pages, nr_meta_pages + 2 * nr_data_pages,
107-
VM_ALLOC | VM_USERMAP, PAGE_KERNEL);
107+
VM_MAP | VM_USERMAP, PAGE_KERNEL);
108108
if (rb) {
109109
kmemleak_not_leak(pages);
110110
rb->pages = pages;

0 commit comments

Comments
 (0)