]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Initialize storage pointers to NULL to prevent freeing garbage pointer
authorAndrii Nakryiko <andriin@fb.com>
Mon, 9 Mar 2020 22:27:55 +0000 (15:27 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Apr 2020 09:02:11 +0000 (11:02 +0200)
commitac9aef0ebe4828180ab7c805d11098b2919f48d3
tree4c5d68d6be18e729ce96ff192abb57ed4ee0593a
parent3f23aeceb0a018a80159fd5d8f0901cef6e085c7
bpf: Initialize storage pointers to NULL to prevent freeing garbage pointer

commit 0da6e9fb26b2b99128d5f3a1b8b356c6d00b505d upstream.

Local storage array isn't initialized, so if cgroup storage allocation fails
for BPF_CGROUP_STORAGE_SHARED, error handling code will attempt to free
uninitialized pointer for BPF_CGROUP_STORAGE_PERCPU storage type. Avoid this
by always initializing storage pointers to NULLs.

Fixes: 6f317e33a148 ("bpf: extend cgroup bpf core to allow multiple cgroup storage types")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200309222756.1018737-1-andriin@fb.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/bpf/cgroup.c