Skip to content

Commit

Permalink
libbpf-tools: Avoid virtual memory area [uprobes] warning
Browse files Browse the repository at this point in the history
Refer to kernel commit 704bde3cc26a ("uprobes: Use vm_special_mapping to
name the XOL vma"), processes setup the [uprobes] special virtual memory
area with uprobe events to excute original instruction out of line.

open_elf() would throw a warning of 'Could not open [uprobes]' when
attaching uprobes. For example, use memleak to trace userspace apps
allocations with command 'memleak -c <command>' or 'memleak -p <pid>':

    ~ # ps | grep dropbear
       76 root      2100 S    dropbear
       79 root      2340 S    grep dropbear
    ~ # memleak -p 76
    using default object: libc.so.6
    using page size: 4096
    tracing kernel: false
    Tracing outstanding memory allocs...  Hit Ctrl-C to end
    [0:18:54] Top 3 stacks with outstanding allocations:
    147 bytes in 1 allocations from stack
    Could not open [uprobes]
            0 [<000000000001b3bc>] free+0x7b2c [/bin/dropbear]
    64 bytes in 1 allocations from stack
            0 [<00000000000288c8>] free+0x15038 [/bin/dropbear]

So remove '[uprobes]' from get_elf_type() to avoid this warning.

Signed-off-by: mickey_zhu <[email protected]>
  • Loading branch information
michael-chuh authored and yonghong-song committed Jun 26, 2023
1 parent e4dc8b2 commit ed02a14
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libbpf-tools/trace_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ static bool is_file_backed(const char *mapname)
STARTS_WITH(mapname, "[stack") ||
STARTS_WITH(mapname, "/SYSV") ||
STARTS_WITH(mapname, "[heap]") ||
STARTS_WITH(mapname, "[uprobes]") ||
STARTS_WITH(mapname, "[vsyscall]"));
}

Expand All @@ -256,6 +257,11 @@ static bool is_vdso(const char *path)
return !strcmp(path, "[vdso]");
}

static bool is_uprobes(const char *path)
{
return !strcmp(path, "[uprobes]");
}

static int get_elf_type(const char *path)
{
GElf_Ehdr hdr;
Expand All @@ -265,6 +271,8 @@ static int get_elf_type(const char *path)

if (is_vdso(path))
return -1;
if (is_uprobes(path))
return -1;
e = open_elf(path, &fd);
if (!e)
return -1;
Expand Down

0 comments on commit ed02a14

Please sign in to comment.