netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wei Fu <fuweid89@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: andrii@kernel.org, ast@kernel.org, bpf@vger.kernel.org,
	daniel@iogearbox.net, john.fastabend@gmail.com, kafai@fb.com,
	kpsingh@kernel.org, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, songliubraving@fb.com, yhs@fb.com,
	fuweid89@gmail.com
Subject: Re: [PATCH bpf] tools/bpf: only set obj->skeleton without err
Date: Wed, 12 Jan 2022 01:09:46 +0800	[thread overview]
Message-ID: <20220111170946.GA16663@chaofan> (raw)
In-Reply-To: <CAEf4Bzag+qQOs86t2ESmYvTY8xCip+_GTKqXa0m7MQWjDMO5Mg@mail.gmail.com>

On Sun, Jan 09, 2022 at 06:04:45PM -0800, Andrii Nakryiko wrote:
> On Sat, Jan 8, 2022 at 12:40 AM Wei Fu <fuweid89@gmail.com> wrote:
> >
> > After `bpftool gen skeleton`, the ${bpf_app}.skel.h will provide that
> > ${bpf_app_name}__open helper to load bpf. If there is some error
> > like ENOMEM, the ${bpf_app_name}__open will rollback(free) the allocated
> > object, including `bpf_object_skeleton`.
> >
> > Since the ${bpf_app_name}__create_skeleton set the obj->skeleton first
> > and not rollback it when error, it will cause double-free in
> > ${bpf_app_name}__destory at ${bpf_app_name}__open. Therefore, we should
> > set the obj->skeleton before return 0;
> >
> > Signed-off-by: Wei Fu <fuweid89@gmail.com>
> > ---
> >  tools/bpf/bpftool/gen.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> 
> Great catch! Added (please add it yourself in the future):
> 
> Fixes: 5dc7a8b21144 ("bpftool, selftests/bpf: Embed object file inside
> skeleton")
> 
> Also reworded the subject a bit. Pushed to bpf-next.

Sure! Thanks for the review.

      reply	other threads:[~2022-01-11 17:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-08  8:40 [PATCH bpf] tools/bpf: only set obj->skeleton without err Wei Fu
2022-01-10  2:04 ` Andrii Nakryiko
2022-01-11 17:09   ` Wei Fu [this message]

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=20220111170946.GA16663@chaofan \
    --to=fuweid89@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).