All of lore.kernel.org
 help / color / mirror / Atom feed
From: Song Liu <song@kernel.org>
To: Eduard Zingerman <eddyz87@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH bpf-next v2 2/3] selftests/bpf: allow BTF specs and func infos in test_verifier tests
Date: Tue, 31 May 2022 21:10:59 -0700	[thread overview]
Message-ID: <CAPhsuW7drtkMj_Yh6FaoGzfAg7K2q4Bpb4a3oG+w0qqACZMo=w@mail.gmail.com> (raw)
In-Reply-To: <b517e19ffbd19b24b630cdeafdb4adb444a8dd56.camel@gmail.com>

On Tue, May 31, 2022 at 4:20 PM Eduard Zingerman <eddyz87@gmail.com> wrote:
>
> > On Tue, 2022-05-31 at 13:52 -0700, Song Liu wrote:
>
> Hi Song,
>
> Thanks a lot for the review, I'll apply the suggested changes and
> provide the v3 in one or two days. My only objection is below.
>
> > >  {
> > > -       int fd_prog, expected_ret, alignment_prevented_execution;
> > > +       int fd_prog, btf_fd, expected_ret, alignment_prevented_execution;
> > >         int prog_len, prog_type = test->prog_type;
> > >         struct bpf_insn *prog = test->insns;
> > >         LIBBPF_OPTS(bpf_prog_load_opts, opts);        __u32 pflags;
> > >         int i, err;
> > >
> > > +       fd_prog = -1;
> >
> > This is not really necessary.
>
> Actually this one is necessary to avoid compiler warning, note the
> following fragment of the do_test_single function below:
>
> static void do_test_single(...)
> {
>         ...
>         if (...) {
>                 btf_fd = load_btf_for_test(...);
>                 if (btf_fd < 0)
>                         goto fail_log;
>                 opts.prog_btf_fd = btf_fd;
>         }
>         ...
>         fd_prog = bpf_prog_load(..., &opts);
>         ...
> close_fds:
>         ...
>         close(fd_prog);
>         close(btf_fd);
>         ...
>         return;
> fail_log:
>         ...
>         goto close_fds;
> }
>
> If load_btf_for_test fails the goto fail_log would eventually jump to
> close_fds, where fd_prog would be in an uninitialised state.

Got it. Thanks for the explanation!

Song

  reply	other threads:[~2022-06-01  4:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-29 22:36 [PATCH bpf-next v2 0/3] bpf_loop inlining Eduard Zingerman
2022-05-29 22:36 ` [PATCH bpf-next v2 1/3] selftests/bpf: specify expected instructions in test_verifier tests Eduard Zingerman
2022-05-31 18:26   ` Song Liu
2022-05-29 22:36 ` [PATCH bpf-next v2 2/3] selftests/bpf: allow BTF specs and func infos " Eduard Zingerman
2022-05-31 20:52   ` Song Liu
2022-05-31 23:20     ` Eduard Zingerman
2022-06-01  4:10       ` Song Liu [this message]
2022-05-29 22:36 ` [PATCH bpf-next v2 3/3] bpf: Inline calls to bpf_loop when callback is known Eduard Zingerman
2022-05-31 22:10   ` Song Liu

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='CAPhsuW7drtkMj_Yh6FaoGzfAg7K2q4Bpb4a3oG+w0qqACZMo=w@mail.gmail.com' \
    --to=song@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=kernel-team@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 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.