* [PATCH bpf-next] selftests/bpf: Fix test_attach_probe
@ 2019-12-19 2:04 Alexei Starovoitov
2019-12-19 3:44 ` Yonghong Song
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alexei Starovoitov @ 2019-12-19 2:04 UTC (permalink / raw)
To: davem; +Cc: daniel, netdev, bpf, kernel-team
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: 1e8611bbdfc9 ("selftests/bpf: add kprobe/uprobe selftests")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
tools/testing/selftests/bpf/prog_tests/attach_probe.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/attach_probe.c b/tools/testing/selftests/bpf/prog_tests/attach_probe.c
index 5ed90ede2f1d..a0ee87c8e1ea 100644
--- a/tools/testing/selftests/bpf/prog_tests/attach_probe.c
+++ b/tools/testing/selftests/bpf/prog_tests/attach_probe.c
@@ -3,7 +3,7 @@
#include "test_attach_probe.skel.h"
ssize_t get_base_addr() {
- size_t start;
+ size_t start, offset;
char buf[256];
FILE *f;
@@ -11,10 +11,11 @@ ssize_t get_base_addr() {
if (!f)
return -errno;
- while (fscanf(f, "%zx-%*x %s %*s\n", &start, buf) == 2) {
+ while (fscanf(f, "%zx-%*x %s %zx %*[^\n]\n",
+ &start, buf, &offset) == 3) {
if (strcmp(buf, "r-xp") == 0) {
fclose(f);
- return start;
+ return start - offset;
}
}
--
2.23.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: Fix test_attach_probe
2019-12-19 2:04 [PATCH bpf-next] selftests/bpf: Fix test_attach_probe Alexei Starovoitov
@ 2019-12-19 3:44 ` Yonghong Song
2019-12-19 5:52 ` Andrii Nakryiko
2019-12-19 16:01 ` Daniel Borkmann
2 siblings, 0 replies; 4+ messages in thread
From: Yonghong Song @ 2019-12-19 3:44 UTC (permalink / raw)
To: Alexei Starovoitov, davem; +Cc: daniel, netdev, bpf, Kernel Team
On 12/18/19 6:04 PM, Alexei Starovoitov wrote:
> 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: 1e8611bbdfc9 ("selftests/bpf: add kprobe/uprobe selftests")
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: Fix test_attach_probe
2019-12-19 2:04 [PATCH bpf-next] selftests/bpf: Fix test_attach_probe Alexei Starovoitov
2019-12-19 3:44 ` Yonghong Song
@ 2019-12-19 5:52 ` Andrii Nakryiko
2019-12-19 16:01 ` Daniel Borkmann
2 siblings, 0 replies; 4+ messages in thread
From: Andrii Nakryiko @ 2019-12-19 5:52 UTC (permalink / raw)
To: Alexei Starovoitov
Cc: David S. Miller, Daniel Borkmann, Networking, bpf, Kernel Team
On Wed, Dec 18, 2019 at 6:04 PM Alexei Starovoitov <ast@kernel.org> wrote:
>
> 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: 1e8611bbdfc9 ("selftests/bpf: add kprobe/uprobe selftests")
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
> ---
Thanks for fixing!
Acked-by: Andrii Nakryiko <andriin@fb.com>
> tools/testing/selftests/bpf/prog_tests/attach_probe.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/attach_probe.c b/tools/testing/selftests/bpf/prog_tests/attach_probe.c
> index 5ed90ede2f1d..a0ee87c8e1ea 100644
> --- a/tools/testing/selftests/bpf/prog_tests/attach_probe.c
> +++ b/tools/testing/selftests/bpf/prog_tests/attach_probe.c
> @@ -3,7 +3,7 @@
> #include "test_attach_probe.skel.h"
>
> ssize_t get_base_addr() {
> - size_t start;
> + size_t start, offset;
> char buf[256];
> FILE *f;
>
> @@ -11,10 +11,11 @@ ssize_t get_base_addr() {
> if (!f)
> return -errno;
>
> - while (fscanf(f, "%zx-%*x %s %*s\n", &start, buf) == 2) {
> + while (fscanf(f, "%zx-%*x %s %zx %*[^\n]\n",
never new [^<chars>] is possible, very nice!
> + &start, buf, &offset) == 3) {
> if (strcmp(buf, "r-xp") == 0) {
> fclose(f);
> - return start;
> + return start - offset;
> }
> }
>
> --
> 2.23.0
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] selftests/bpf: Fix test_attach_probe
2019-12-19 2:04 [PATCH bpf-next] selftests/bpf: Fix test_attach_probe Alexei Starovoitov
2019-12-19 3:44 ` Yonghong Song
2019-12-19 5:52 ` Andrii Nakryiko
@ 2019-12-19 16:01 ` Daniel Borkmann
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2019-12-19 16:01 UTC (permalink / raw)
To: Alexei Starovoitov; +Cc: davem, netdev, bpf, kernel-team
On Wed, Dec 18, 2019 at 06:04:42PM -0800, Alexei Starovoitov wrote:
> 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: 1e8611bbdfc9 ("selftests/bpf: add kprobe/uprobe selftests")
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Applied, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-12-19 16:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-19 2:04 [PATCH bpf-next] selftests/bpf: Fix test_attach_probe Alexei Starovoitov
2019-12-19 3:44 ` Yonghong Song
2019-12-19 5:52 ` Andrii Nakryiko
2019-12-19 16:01 ` Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).