From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Borkmann Subject: [PATCH bpf 2/3] bpf, s390: fix potential memleak when later bpf_jit_prog fails Date: Thu, 28 Jun 2018 23:34:58 +0200 Message-ID: <20180628213459.28631-3-daniel@iogearbox.net> References: <20180628213459.28631-1-daniel@iogearbox.net> Cc: netdev@vger.kernel.org, Daniel Borkmann , Martin Schwidefsky To: ast@kernel.org Return-path: Received: from www62.your-server.de ([213.133.104.62]:36482 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965643AbeF1VfI (ORCPT ); Thu, 28 Jun 2018 17:35:08 -0400 In-Reply-To: <20180628213459.28631-1-daniel@iogearbox.net> Sender: netdev-owner@vger.kernel.org List-ID: 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 Cc: Martin Schwidefsky Acked-by: Alexei Starovoitov --- arch/s390/net/bpf_jit_comp.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c index d2db8ac..5f0234e 100644 --- a/arch/s390/net/bpf_jit_comp.c +++ b/arch/s390/net/bpf_jit_comp.c @@ -1286,6 +1286,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp) goto free_addrs; } if (bpf_jit_prog(&jit, fp)) { + bpf_jit_binary_free(header); fp = orig_fp; goto free_addrs; } -- 2.9.5