bpf, s390: fix potential memleak when later bpf_jit_prog fails
authorDaniel Borkmann <daniel@iogearbox.net>
Thu, 28 Jun 2018 21:34:58 +0000 (23:34 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 Aug 2018 11:12:34 +0000 (13:12 +0200)
commit36b0779e9e289aeaf7efc7db977b1e4e5b95aaeb
tree50d64cd261e1a999d44c7fb2c74afb901096f9eb
parent1db00def7103c388efdaaba96e16b0b07e7cf9c1
bpf, s390: fix potential memleak when later bpf_jit_prog fails

[ Upstream commit f605ce5eb26ac934fb8106d75d46a2c875a2bf23 ]

If we would ever fail in the bpf_jit_prog() pass that writes the
actual insns to the image after we got header via bpf_jit_binary_alloc()
then we also need to make sure to free it through bpf_jit_binary_free()
again when bailing out. Given we had prior bpf_jit_prog() passes to
initially probe for clobbered registers, program size and to fill in
addrs arrray for jump targets, this is more of a theoretical one,
but at least make sure this doesn't break with future changes.

Fixes: 054623105728 ("s390/bpf: Add s390x eBPF JIT compiler backend")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/s390/net/bpf_jit_comp.c