Skip to content

Commit 580205d

Browse files
Alexei Starovoitovborkmann
authored andcommitted
selftests/bpf: Fix test_attach_probe
Fix two issues in test_attach_probe: 1. it was not able to parse /proc/self/maps beyond the first line, since %s means parse string until white space. 2. offset has to be accounted for otherwise uprobed address is incorrect. Fixes: 1e8611b ("selftests/bpf: add kprobe/uprobe selftests") Signed-off-by: Alexei Starovoitov <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Yonghong Song <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 12dd14b commit 580205d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tools/testing/selftests/bpf/prog_tests/attach_probe.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33
#include "test_attach_probe.skel.h"
44

55
ssize_t get_base_addr() {
6-
size_t start;
6+
size_t start, offset;
77
char buf[256];
88
FILE *f;
99

1010
f = fopen("/proc/self/maps", "r");
1111
if (!f)
1212
return -errno;
1313

14-
while (fscanf(f, "%zx-%*x %s %*s\n", &start, buf) == 2) {
14+
while (fscanf(f, "%zx-%*x %s %zx %*[^\n]\n",
15+
&start, buf, &offset) == 3) {
1516
if (strcmp(buf, "r-xp") == 0) {
1617
fclose(f);
17-
return start;
18+
return start - offset;
1819
}
1920
}
2021

0 commit comments

Comments
 (0)