From: Jiri Olsa <olsajiri@gmail.com>
To: Viktor Malik <vmalik@redhat.com>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
John Fastabend <john.fastabend@gmail.com>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
Luis Chamberlain <mcgrof@kernel.org>
Subject: Re: [PATCH bpf-next v8 2/2] bpf/selftests: Test fentry attachment to shadowed functions
Date: Mon, 27 Feb 2023 13:58:31 +0100 [thread overview]
Message-ID: <Y/yo9xfP9xMKGH6H@krava> (raw)
In-Reply-To: <b66118d393edf071e8acdbfcb22965985192f00b.1677075137.git.vmalik@redhat.com>
On Wed, Feb 22, 2023 at 03:35:29PM +0100, Viktor Malik wrote:
SNIP
> + for (i = 0; i < 2; i++) {
> + load_opts.attach_btf_id = btf_id[i];
> + load_opts.attach_btf_obj_fd = btf_fd[i];
> + prog_fd[i] = bpf_prog_load(BPF_PROG_TYPE_TRACING, NULL, "GPL",
> + trace_program,
> + sizeof(trace_program) / sizeof(struct bpf_insn),
> + &load_opts);
> + if (!ASSERT_GE(prog_fd[i], 0, "bpf_prog_load"))
> + goto out;
> +
> + /* If the verifier incorrectly resolves addresses of the
> + * shadowed functions and uses the same address for both the
> + * vmlinux and the bpf_testmod functions, this will fail on
> + * attempting to create two trampolines for the same address,
> + * which is forbidden.
> + */
> + link_fd[i] = bpf_link_create(prog_fd[i], 0, BPF_TRACE_FENTRY, NULL);
> + if (!ASSERT_GE(link_fd[i], 0, "bpf_link_create"))
> + goto out;
> + }
> +
> + err = bpf_prog_test_run_opts(prog_fd[0], NULL);
> + ASSERT_OK(err, "running test");
> +
> +out:
> + btf__free(vmlinux_btf);
> + btf__free(mod_btf);
> + for (i = 0; i < 2; i++) {
> + if (btf_fd[i])
> + close(btf_fd[i]);
> + if (prog_fd[i])
> + close(prog_fd[i]);
should we check prog_fd[i] > 0 ? same below
jirka
> + if (link_fd[i])
> + close(link_fd[i]);
> + }
> +}
> --
> 2.39.1
>
next prev parent reply other threads:[~2023-02-27 12:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-22 14:35 [PATCH bpf-next v8 0/2] Fix attaching fentry/fexit/fmod_ret/lsm to modules Viktor Malik
2023-02-22 14:35 ` [PATCH bpf-next v8 1/2] bpf: " Viktor Malik
2023-02-23 1:42 ` kernel test robot
2023-02-27 12:58 ` Jiri Olsa
2023-02-22 14:35 ` [PATCH bpf-next v8 2/2] bpf/selftests: Test fentry attachment to shadowed functions Viktor Malik
2023-02-27 12:58 ` Jiri Olsa [this message]
2023-02-27 12:58 ` [PATCH bpf-next v8 0/2] Fix attaching fentry/fexit/fmod_ret/lsm to modules Jiri Olsa
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=Y/yo9xfP9xMKGH6H@krava \
--to=olsajiri@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=kpsingh@kernel.org \
--cc=martin.lau@linux.dev \
--cc=mcgrof@kernel.org \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=vmalik@redhat.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 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.