]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Fix bug in mmap() implementation for BPF array map
authorAndrii Nakryiko <andriin@fb.com>
Tue, 12 May 2020 23:59:25 +0000 (16:59 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 14 May 2020 19:40:04 +0000 (12:40 -0700)
commit7ce0d4bf76c2b08ebae6b69c3bbfc358c2da3339
tree27c603d11355ab26e741a267cf52b112b70a91b5
parent47ad512110a4243f27180de728000a55f1763483
bpf: Fix bug in mmap() implementation for BPF array map

mmap() subsystem allows user-space application to memory-map region with
initial page offset. This wasn't taken into account in initial implementation
of BPF array memory-mapping. This would result in wrong pages, not taking into
account requested page shift, being memory-mmaped into user-space. This patch
fixes this gap and adds a test for such scenario.

Fixes: d41da1a54b88 ("bpf: Add mmap() support for BPF_MAP_TYPE_ARRAY")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20200512235925.3817805-1-andriin@fb.com
kernel/bpf/arraymap.c
tools/testing/selftests/bpf/prog_tests/mmap.c