]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: fix leaking uninitialized memory on pop/peek helpers
authorDaniel Borkmann <daniel@iogearbox.net>
Wed, 24 Oct 2018 20:05:48 +0000 (22:05 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 26 Oct 2018 00:02:06 +0000 (17:02 -0700)
commitb043e04455bb0b831de8527a63ae6f7e67704c0b
tree44d9067866b5d740959eb95d33ffef600fd04b38
parentdfd1f8df8ce222eeb971d044c10cc21bb7de0447
bpf: fix leaking uninitialized memory on pop/peek helpers

Commit 3f0ed437d88f ("bpf: add queue and stack maps") added helpers
with ARG_PTR_TO_UNINIT_MAP_VALUE. Meaning, the helper is supposed to
fill the map value buffer with data instead of reading from it like
in other helpers such as map update. However, given the buffer is
allowed to be uninitialized (since we fill it in the helper anyway),
it also means that the helper is obliged to wipe the memory in case
of an error in order to not allow for leaking uninitialized memory.
Given pop/peek is both handled inside __{stack,queue}_map_get(),
lets wipe it there on error case, that is, empty stack/queue.

Fixes: 3f0ed437d88f ("bpf: add queue and stack maps")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Cc: Mauricio Vasquez B <mauricio.vasquez@polito.it>
Acked-by: Mauricio Vasquez B<mauricio.vasquez@polito.it>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/queue_stack_maps.c