]> 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)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 10 Mar 2020 02:56:48 +0000 (19:56 -0700)
commit130fa0c32ed1384f653d3b764c43bbb58561c6d9
tree7eaf14dc8ca1e1c1751eb54448f63f7ad35bc002
parentdf7a9e441fad62a2222fc2bde0b44313ff1127a1
bpf: Initialize storage pointers to NULL to prevent freeing garbage pointer

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: 2b0afd24f505 ("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
kernel/bpf/cgroup.c