* [PATCH bpf] libbpf: Fix incorrect module BTF fd index in warning
@ 2026-11-11 6:44 Rahad Bhuiya
0 siblings, 0 replies; only message in thread
From: Rahad Bhuiya @ 2026-11-11 6:44 UTC (permalink / raw)
To: bpf, Andrii Nakryiko, Eduard Zingerman
Cc: Alexei Starovoitov, Daniel Borkmann, Kumar Kartikeya Dwivedi,
Martin KaFai Lau, Song Liu, Yonghong Song, Ihor Solodrai,
linux-kernel, Rahad Bhuiya
When the number of used module BTF slots in fd_array reaches INT16_MAX,
resolving an extern func ksym fails with -E2BIG. However, the warning
message logs mod_btf->fd_array_idx, which is guaranteed to be 0 at this
point because it has not yet been assigned from obj->fd_array_used.
Use obj->fd_array_used with the %zu format specifier instead so that the
actual overflowing index is logged.
Fixes: 9dbe6015636c ("libbpf: Support kernel module function calls")
Signed-off-by: Rahad Bhuiya <rahadbhuiya2021@gmail.com>
---
tools/lib/bpf/libbpf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 0e2a93a42908..d71e8ca199bc 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -9553,8 +9553,8 @@ static int bpf_object__resolve_ksym_func_btf_id(struct bpf_object *obj,
if (mod_btf && !mod_btf->fd_array_idx) {
/* insn->off is s16 */
if (obj->fd_array_used == INT16_MAX) {
- pr_warn("extern (func ksym) '%s': module BTF fd index %d too big to fit in bpf_insn offset\n",
- ext->name, mod_btf->fd_array_idx);
+ pr_warn("extern (func ksym) '%s': module BTF fd index %zu too big to fit in bpf_insn offset\n",
+ ext->name, obj->fd_array_used);
return -E2BIG;
}
/* Cannot use index 0 for module BTF fd */
--
2.55.0.windows.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-11 6:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 6:44 [PATCH bpf] libbpf: Fix incorrect module BTF fd index in warning Rahad Bhuiya
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®