libbpf: Fix uprobe symbol file offset calculation logic
authorAndrii Nakryiko <andrii@kernel.org>
Mon, 6 Jun 2022 22:01:43 +0000 (15:01 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 9 Jun 2022 12:09:41 +0000 (14:09 +0200)
commitfe92833524e368e59bba9c57e00f7359f133667f
tree99190a8f63b41fdce6cb0224dd1b36b5dcc9a5bc
parent492f99e4190a4574a4e015507e0466ab6d8d5d88
libbpf: Fix uprobe symbol file offset calculation logic

Fix libbpf's bpf_program__attach_uprobe() logic of determining
function's *file offset* (which is what kernel is actually expecting)
when attaching uprobe/uretprobe by function name. Previously calculation
was determining virtual address offset relative to base load address,
which (offset) is not always the same as file offset (though very
frequently it is which is why this went unnoticed for a while).

Fixes: 433966e3ae04 ("libbpf: Support function name-based attach uprobes")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Riham Selim <rihams@fb.com>
Cc: Alan Maguire <alan.maguire@oracle.com>
Link: https://lore.kernel.org/bpf/20220606220143.3796908-1-andrii@kernel.org
tools/lib/bpf/libbpf.c