Skip to content

Commit c546218

Browse files
libbpf: don't adjust USDT semaphore address if .stapsdt.base addr is missing
JIRA: https://issues.redhat.com/browse/RHEL-78201 commit 98ebe5e Author: Andrii Nakryiko <andrii@kernel.org> Date: Thu Nov 21 14:45:58 2024 -0800 libbpf: don't adjust USDT semaphore address if .stapsdt.base addr is missing USDT ELF note optionally can record an offset of .stapsdt.base, which is used to make adjustments to USDT target attach address. Currently, libbpf will do this address adjustment unconditionally if it finds .stapsdt.base ELF section in target binary. But there is a corner case where .stapsdt.base ELF section is present, but specific USDT note doesn't reference it. In such case, libbpf will basically just add base address and end up with absolutely incorrect USDT target address. This adjustment has to be done only if both .stapsdt.sema section is present and USDT note is recording a reference to it. Fixes: 74cc631 ("libbpf: Add USDT notes parsing and resolution logic") Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Jiri Olsa <jolsa@kernel.org> Link: https://lore.kernel.org/r/20241121224558.796110-1-andrii@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
1 parent de4a223 commit c546218

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/lib/bpf/usdt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ static int collect_usdt_targets(struct usdt_manager *man, Elf *elf, const char *
661661
* [0] https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation
662662
*/
663663
usdt_abs_ip = note.loc_addr;
664-
if (base_addr)
664+
if (base_addr && note.base_addr)
665665
usdt_abs_ip += base_addr - note.base_addr;
666666

667667
/* When attaching uprobes (which is what USDTs basically are)

0 commit comments

Comments
 (0)