]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: fix mlock precharge on arraymaps
authorDaniel Borkmann <daniel@iogearbox.net>
Fri, 16 Feb 2018 00:10:29 +0000 (01:10 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 16 Feb 2018 05:34:33 +0000 (21:34 -0800)
commit7c175da76df984b02a448ae6f3690059a2af1c21
treec1696b8aa7d31d16a505006a102ca3381161c109
parent63f13bbba1e77961fb4918fd348954be0d90e37c
bpf: fix mlock precharge on arraymaps

syzkaller recently triggered OOM during percpu map allocation;
while there is work in progress by Dennis Zhou to add __GFP_NORETRY
semantics for percpu allocator under pressure, there seems also a
missing bpf_map_precharge_memlock() check in array map allocation.

Given today the actual bpf_map_charge_memlock() happens after the
find_and_alloc_map() in syscall path, the bpf_map_precharge_memlock()
is there to bail out early before we go and do the map setup work
when we find that we hit the limits anyway. Therefore add this for
array map as well.

Fixes: ad97dd3b1903 ("bpf: pre-allocate hash map elements")
Fixes: 787ec2838b4a ("bpf: introduce BPF_MAP_TYPE_PERCPU_ARRAY map")
Reported-by: syzbot+adb03f3f0bb57ce3acda@syzkaller.appspotmail.com
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Dennis Zhou <dennisszhou@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/arraymap.c