From: Stanislav Fomichev <sdf@google.com>
To: Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
martin.lau@kernel.org, kernel-team@meta.com
Subject: Re: [PATCH v2 bpf-next 1/3] libbpf: disassociate section handler on explicit bpf_program__set_type() call
Date: Fri, 24 Mar 2023 20:01:09 -0700 [thread overview]
Message-ID: <ZB5j9Zcx1F6kSx6v@google.com> (raw)
In-Reply-To: <20230324232745.3959567-2-andrii@kernel.org>
On 03/24, Andrii Nakryiko wrote:
> If user explicitly overrides programs's type with
> bpf_program__set_type() API call, we need to disassociate whatever
> SEC_DEF handler libbpf determined initially based on program's SEC()
> definition, as it's not goind to be valid anymore and could lead to
> crashes and/or confusing failures.
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
> ---
> tools/lib/bpf/libbpf.c | 1 +
> 1 file changed, 1 insertion(+)
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index f6a071db5c6e..a34ebb6b8508 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -8465,6 +8465,7 @@ int bpf_program__set_type(struct bpf_program *prog,
> enum bpf_prog_type type)
> return libbpf_err(-EBUSY);
> prog->type = type;
> + prog->sec_def = NULL;
> return 0;
> }
Surprisingly, but it breaks the following selftest:
serial_test_bpf_obj_id:PASS:get-fd-by-notexist-prog-id 0 nsec
serial_test_bpf_obj_id:PASS:get-fd-by-notexist-map-id 0 nsec
serial_test_bpf_obj_id:PASS:get-fd-by-notexist-link-id 0 nsec
serial_test_bpf_obj_id:FAIL:prog_attach prog #0, err -95
#17 bpf_obj_id:FAIL
(saw in the bot, reproduced locally)
> --
> 2.34.1
next prev parent reply other threads:[~2023-03-25 3:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-24 23:27 [PATCH v2 bpf-next 0/3] veristat: add better support of freplace programs Andrii Nakryiko
2023-03-24 23:27 ` [PATCH v2 bpf-next 1/3] libbpf: disassociate section handler on explicit bpf_program__set_type() call Andrii Nakryiko
2023-03-25 3:01 ` Stanislav Fomichev [this message]
2023-03-27 18:05 ` Andrii Nakryiko
2023-03-24 23:27 ` [PATCH v2 bpf-next 2/3] veristat: add -d debug mode option to see debug libbpf log Andrii Nakryiko
2023-03-24 23:27 ` [PATCH v2 bpf-next 3/3] veristat: guess and substitue underlying program type for freplace (EXT) progs Andrii Nakryiko
2023-03-26 4:59 ` Alexei Starovoitov
2023-03-27 18:47 ` Andrii Nakryiko
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=ZB5j9Zcx1F6kSx6v@google.com \
--to=sdf@google.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@meta.com \
--cc=martin.lau@kernel.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.