]> git.baikalelectronics.ru Git - kernel.git/commit
bpf, xskmap: fix crash in xsk_map_alloc error path handling
authorDaniel Borkmann <daniel@iogearbox.net>
Fri, 4 May 2018 14:27:53 +0000 (16:27 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 4 May 2018 21:55:54 +0000 (14:55 -0700)
commitb2997f99bef45d3e525b2e25da46c3f1c9c966c5
treec49a617e7a4e12030e511cb5f296439e58155d37
parent99cffd0bb2ae48ec1b791992c65a2014b88307d0
bpf, xskmap: fix crash in xsk_map_alloc error path handling

If bpf_map_precharge_memlock() did not fail, then we set err to zero.
However, any subsequent failure from either alloc_percpu() or the
bpf_map_area_alloc() will return ERR_PTR(0) which in find_and_alloc_map()
will cause NULL pointer deref.

In devmap we have the convention that we return -EINVAL on page count
overflow, so keep the same logic here and just set err to -ENOMEM
after successful bpf_map_precharge_memlock().

Fixes: 052e8f1622ae ("bpf: introduce new bpf AF_XDP map type BPF_MAP_TYPE_XSKMAP")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Björn Töpel <bjorn.topel@intel.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/xskmap.c