BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next 1/2] libbpf: never interpret subprogs in .text as entry programs
@ 2024-10-10 21:17 Andrii Nakryiko
  2024-10-10 21:17 ` [PATCH bpf-next 2/2] selftests/bpf: add subprog to BPF object file with no " Andrii Nakryiko
  2024-10-11 18:32 ` [PATCH bpf-next 1/2] libbpf: never interpret subprogs in .text as " patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Andrii Nakryiko @ 2024-10-10 21:17 UTC (permalink / raw)
  To: bpf, ast, daniel, martin.lau; +Cc: andrii, kernel-team

Libbpf pre-1.0 had a legacy logic of allowing singular non-annotated
(i.e., not having explicit SEC() annotation) function to be treated as
sole entry BPF program (unless there were other explicit entry
programs).

This behavior was dropped during libbpf 1.0 transition period (unless
LIBBPF_STRICT_SEC_NAME flag was unset in libbpf_mode). When 1.0 was
released and all the legacy behavior was removed, the bug slipped
through leaving this legacy behavior around.

Fix this for good, as it actually causes very confusing behavior if BPF
object file only has subprograms, but no entry programs.

Fixes: bd054102a8c7 ("libbpf: enforce strict libbpf 1.0 behaviors")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 05ad264ff09b..7c40286c3948 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -4417,7 +4417,7 @@ static int bpf_object__collect_externs(struct bpf_object *obj)
 
 static bool prog_is_subprog(const struct bpf_object *obj, const struct bpf_program *prog)
 {
-	return prog->sec_idx == obj->efile.text_shndx && obj->nr_programs > 1;
+	return prog->sec_idx == obj->efile.text_shndx;
 }
 
 struct bpf_program *
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-11 18:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-10 21:17 [PATCH bpf-next 1/2] libbpf: never interpret subprogs in .text as entry programs Andrii Nakryiko
2024-10-10 21:17 ` [PATCH bpf-next 2/2] selftests/bpf: add subprog to BPF object file with no " Andrii Nakryiko
2024-10-10 21:22   ` Andrii Nakryiko
2024-10-11 18:32 ` [PATCH bpf-next 1/2] libbpf: never interpret subprogs in .text as " patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox