From: catalin.marinas@arm.com (Catalin Marinas)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH arm64-next] net: bpf: arm64: fix module memory leak when JIT image build fails
Date: Fri, 12 Sep 2014 16:33:37 +0100 [thread overview]
Message-ID: <20140912153337.GC5532@arm.com> (raw)
In-Reply-To: <20140911104513.GC6158@arm.com>
On Thu, Sep 11, 2014 at 11:45:13AM +0100, Will Deacon wrote:
> On Thu, Sep 11, 2014 at 10:36:48AM +0100, Daniel Borkmann wrote:
> > On ARM64, when the BPF JIT compiler fills the JIT image body with
> > opcodes during translation of eBPF into ARM64 opcodes, we may fail
> > for several reasons during that phase: one being that we jump to
> > the notyet label for not yet supported eBPF instructions such as
> > BPF_ST. In that case we only free offsets, but not the actual
> > allocated target image where opcodes are being stored. Fix it by
> > calling module_free() on dismantle time in case of errors.
> >
> > Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
> > Cc: Zi Shen Lim <zlim.lnx@gmail.com>
> > Cc: Alexei Starovoitov <ast@plumgrid.com>
> > Cc: Will Deacon <will.deacon@arm.com>
> > ---
> > [ Compile-tested only. ]
> >
> > arch/arm64/net/bpf_jit_comp.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
> > index 38c4296..7ae3354 100644
> > --- a/arch/arm64/net/bpf_jit_comp.c
> > +++ b/arch/arm64/net/bpf_jit_comp.c
> > @@ -651,8 +651,10 @@ void bpf_int_jit_compile(struct bpf_prog *prog)
> > build_prologue(&ctx);
> >
> > ctx.body_offset = ctx.idx;
> > - if (build_body(&ctx))
> > + if (build_body(&ctx)) {
> > + module_free(NULL, ctx.image);
> > goto out;
> > + }
> >
>
> Looks good to me:
>
> Acked-by: Will Deacon <will.deacon@arm.com>
>
> Catalin, can you apply this on the for-next/core branch, please?
Applied, thanks.
--
Catalin
WARNING: multiple messages have this Message-ID (diff)
From: Catalin Marinas <catalin.marinas@arm.com>
To: Will Deacon <will.deacon@arm.com>
Cc: Daniel Borkmann <dborkman@redhat.com>,
Zi Shen Lim <zlim.lnx@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"davem@davemloft.net" <davem@davemloft.net>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
Alexei Starovoitov <ast@plumgrid.com>
Subject: Re: [PATCH arm64-next] net: bpf: arm64: fix module memory leak when JIT image build fails
Date: Fri, 12 Sep 2014 16:33:37 +0100 [thread overview]
Message-ID: <20140912153337.GC5532@arm.com> (raw)
In-Reply-To: <20140911104513.GC6158@arm.com>
On Thu, Sep 11, 2014 at 11:45:13AM +0100, Will Deacon wrote:
> On Thu, Sep 11, 2014 at 10:36:48AM +0100, Daniel Borkmann wrote:
> > On ARM64, when the BPF JIT compiler fills the JIT image body with
> > opcodes during translation of eBPF into ARM64 opcodes, we may fail
> > for several reasons during that phase: one being that we jump to
> > the notyet label for not yet supported eBPF instructions such as
> > BPF_ST. In that case we only free offsets, but not the actual
> > allocated target image where opcodes are being stored. Fix it by
> > calling module_free() on dismantle time in case of errors.
> >
> > Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
> > Cc: Zi Shen Lim <zlim.lnx@gmail.com>
> > Cc: Alexei Starovoitov <ast@plumgrid.com>
> > Cc: Will Deacon <will.deacon@arm.com>
> > ---
> > [ Compile-tested only. ]
> >
> > arch/arm64/net/bpf_jit_comp.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
> > index 38c4296..7ae3354 100644
> > --- a/arch/arm64/net/bpf_jit_comp.c
> > +++ b/arch/arm64/net/bpf_jit_comp.c
> > @@ -651,8 +651,10 @@ void bpf_int_jit_compile(struct bpf_prog *prog)
> > build_prologue(&ctx);
> >
> > ctx.body_offset = ctx.idx;
> > - if (build_body(&ctx))
> > + if (build_body(&ctx)) {
> > + module_free(NULL, ctx.image);
> > goto out;
> > + }
> >
>
> Looks good to me:
>
> Acked-by: Will Deacon <will.deacon@arm.com>
>
> Catalin, can you apply this on the for-next/core branch, please?
Applied, thanks.
--
Catalin
next prev parent reply other threads:[~2014-09-12 15:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-11 9:36 [PATCH arm64-next] net: bpf: arm64: fix module memory leak when JIT image build fails Daniel Borkmann
2014-09-11 9:36 ` Daniel Borkmann
2014-09-11 10:45 ` Will Deacon
2014-09-11 10:45 ` Will Deacon
2014-09-11 14:59 ` Z Lim
2014-09-11 14:59 ` Z Lim
2014-09-12 15:33 ` Catalin Marinas [this message]
2014-09-12 15:33 ` Catalin Marinas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140912153337.GC5532@arm.com \
--to=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.