]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpf: Don't leak memory in bpf getsockopt when optlen == 0
authorStanislav Fomichev <sdf@google.com>
Tue, 12 Jan 2021 16:28:29 +0000 (08:28 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Jan 2021 14:57:56 +0000 (15:57 +0100)
commit79ce12cfa56a5b5a256b1c92e98a8a3a3425d131
treeb1cf7d36c5edaee57a04c2f5350df9626b04d919
parent4aef760c28e8bd1860a27fd78067b4ea77124987
bpf: Don't leak memory in bpf getsockopt when optlen == 0

commit 4be34f3d0731b38a1b24566b37fbb39500aaf3a2 upstream.

optlen == 0 indicates that the kernel should ignore BPF buffer
and use the original one from the user. We, however, forget
to free the temporary buffer that we've allocated for BPF.

Fixes: d8fe449a9c51 ("bpf: Don't return EINVAL from {get,set}sockopt when optlen > PAGE_SIZE")
Reported-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20210112162829.775079-1-sdf@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/bpf/cgroup.c