]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Fix values type used in test_maps
authorDavid Miller <davem@davemloft.net>
Thu, 20 Apr 2017 19:20:16 +0000 (15:20 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 21 Apr 2017 19:16:46 +0000 (15:16 -0400)
commitc6878714ac1a666e6c3ba4323187fa6148e4496e
treeed26db1aef0514d46d969bf21b45e0c52f7d7972
parent846b13a8f5b46ea543fa9b1e109fb223024871a4
bpf: Fix values type used in test_maps

Maps of per-cpu type have their value element size adjusted to 8 if it
is specified smaller during various map operations.

This makes test_maps as a 32-bit binary fail, in fact the kernel
writes past the end of the value's array on the user's stack.

To be quite honest, I think the kernel should reject creation of a
per-cpu map that doesn't have a value size of at least 8 if that's
what the kernel is going to silently adjust to later.

If the user passed something smaller, it is a sizeof() calcualtion
based upon the type they will actually use (just like in this testcase
code) in later calls to the map operations.

Fixes: d8b5db0204e0 ("samples/bpf: unit test for BPF_MAP_TYPE_PERCPU_ARRAY")
Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/test_maps.c