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

Mateusz Bieganski posted 1 patch 8 months, 3 weeks ago
tools/lib/bpf/elf.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH] libbpf: fix multi-uprobe attach not working with dynamic symbols
Posted by Mateusz Bieganski 8 months, 3 weeks ago
ENOENT is incorrectly propagated to caller, if requested symbol is
present in dynamic linker symbol table and not present in symbol table.

Signed-off-by: Mateusz Bieganski <bieganski.gm@gmail.com>
---
 tools/lib/bpf/elf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/lib/bpf/elf.c b/tools/lib/bpf/elf.c
index 823f83ad819c..41839ef5bc97 100644
--- a/tools/lib/bpf/elf.c
+++ b/tools/lib/bpf/elf.c
@@ -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;
 
-- 
2.39.5
Re: [PATCH] libbpf: fix multi-uprobe attach not working with dynamic symbols
Posted by Andrii Nakryiko 8 months, 3 weeks ago
On Thu, Mar 27, 2025 at 3:08 AM Mateusz Bieganski
<bieganski.gm@gmail.com> wrote:
>
> ENOENT is incorrectly propagated to caller, if requested symbol is
> present in dynamic linker symbol table and not present in symbol table.
>
> Signed-off-by: Mateusz Bieganski <bieganski.gm@gmail.com>
> ---
>  tools/lib/bpf/elf.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/elf.c b/tools/lib/bpf/elf.c
> index 823f83ad819c..41839ef5bc97 100644
> --- a/tools/lib/bpf/elf.c
> +++ b/tools/lib/bpf/elf.c
> @@ -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

>                 if (err)
>                         goto out;
>
> --
> 2.39.5
>
Re: [PATCH] libbpf: fix multi-uprobe attach not working with dynamic symbols
Posted by Jiri Olsa 8 months, 2 weeks ago
On Fri, Mar 28, 2025 at 11:14:54AM -0700, Andrii Nakryiko wrote:
> On Thu, Mar 27, 2025 at 3:08 AM Mateusz Bieganski
> <bieganski.gm@gmail.com> wrote:
> >
> > ENOENT is incorrectly propagated to caller, if requested symbol is
> > present in dynamic linker symbol table and not present in symbol table.
> >
> > Signed-off-by: Mateusz Bieganski <bieganski.gm@gmail.com>
> > ---
> >  tools/lib/bpf/elf.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/lib/bpf/elf.c b/tools/lib/bpf/elf.c
> > index 823f83ad819c..41839ef5bc97 100644
> > --- a/tools/lib/bpf/elf.c
> > +++ b/tools/lib/bpf/elf.c
> > @@ -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.

+1, thanks for the fix

jirka

> 
> pw-bot: cr
> 
> >                 if (err)
> >                         goto out;
> >
> > --
> > 2.39.5
> >