Skip to contentSkip to conversation

libbpf: fix multi-uprobe attach not working with dynamic symbols

PATCH In review Mateusz Bieganski 3 participants 3 messages Mar 27, 2025 – Apr 3, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libbpf: fix multi-uprobe attach not working with dynamic symbols

ENOENT is incorrectly propagated to caller, if requested symbol is present in dynamic linker symbol table and not present in symbol table.

---
 tools/lib/bpf/elf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/lib/bpf/elf.c +3 -1
index 823f83ad819c..41839ef5bc97 100644
@@ -439,8 +439,10 @@ int elf_resolve_syms_offsets(const char *binary_path, int cnt,
 		struct elf_sym *sym;
 
 		err = elf_sym_iter_new(&iter, elf_fd.elf, binary_path, sh_types[i], st_type);
-		if (err == -ENOENT)
+		if (err == -ENOENT) {
+			err = 0;
 			continue;
+		}
 		if (err)
 			goto out;
 
Signature · 1 line
2.39.5
#1 lore raw
Quoted 14 lines · Mateusz Bieganski

ENOENT is incorrectly propagated to caller, if requested symbol is present in dynamic linker symbol table and not present in symbol table.

---
 tools/lib/bpf/elf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/lib/bpf/elf.c +0 -0
index 823f83ad819c..41839ef5bc97 100644

tools/lib/bpf/elf.c int elf_resolve_syms_offsets(const char *binary_path, int cnt, · line 445

Quoted 8 lines
tools/lib/bpf/elf.c +3 -1
@@ -439,8 +439,10 @@ int elf_resolve_syms_offsets(const char *binary_path, int cnt,
                struct elf_sym *sym;
 
                err = elf_sym_iter_new(&iter, elf_fd.elf, binary_path, sh_types[i], st_type);
-               if (err == -ENOENT)
+               if (err == -ENOENT) {
+                       err = 0;
                        continue;
+               }

Don't we have the same problem in elf_resolve_pattern_offsets() as well? Can you please fix both issues in one go?

It seems it's only elf_find_func_offset() that do want to preserve that -ENOENT, all others are just error-prone implementations.

pw-bot: cr

Quoted 6 lines
tools/lib/bpf/elf.c +0 -1
                if (err)
                        goto out;
 
--

2.39.5

#2 lore raw
Quoted 28 lines · Andrii Nakryiko
Quoted 14 lines · Mateusz Bieganski

ENOENT is incorrectly propagated to caller, if requested symbol is present in dynamic linker symbol table and not present in symbol table.

---
 tools/lib/bpf/elf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/lib/bpf/elf.c +0 -0
index 823f83ad819c..41839ef5bc97 100644

tools/lib/bpf/elf.c int elf_resolve_syms_offsets(const char *binary_path, int cnt, · line 445

Quoted 8 lines
tools/lib/bpf/elf.c +3 -1
@@ -439,8 +439,10 @@ int elf_resolve_syms_offsets(const char *binary_path, int cnt,
                struct elf_sym *sym;
 
                err = elf_sym_iter_new(&iter, elf_fd.elf, binary_path, sh_types[i], st_type);
-               if (err == -ENOENT)
+               if (err == -ENOENT) {
+                       err = 0;
                        continue;
+               }

Don't we have the same problem in elf_resolve_pattern_offsets() as well? Can you please fix both issues in one go?

Quoted 2 lines

It seems it's only elf_find_func_offset() that do want to preserve that -ENOENT, all others are just error-prone implementations.

+1, thanks for the fix

jirka

Quoted 9 lines

pw-bot: cr

Quoted 6 lines
tools/lib/bpf/elf.c +0 -1
                if (err)
                        goto out;
 
--

2.39.5