bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf] bpftool: Fix printing incorrect pointer in btf_dump_ptr
@ 2020-01-10 23:16 Martin KaFai Lau
  2020-01-11 20:07 ` Quentin Monnet
  0 siblings, 1 reply; 3+ messages in thread
From: Martin KaFai Lau @ 2020-01-10 23:16 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Daniel Borkmann, David Miller, kernel-team,
	netdev, Quentin Monnet

For plain text output, it incorrectly prints the pointer value
"void *data".  The "void *data" is actually pointing to memory that
contains a bpf-map's value.  The intention is to print the content of
the bpf-map's value instead of printing the pointer pointing to the
bpf-map's value.

In this case, a member of the bpf-map's value is a pointer type.
Thus, it should print the "*(void **)data".

Fixes: 22c349e8db89 ("tools: bpftool: fix format strings and arguments for jsonw_printf()")
Cc: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
---
 tools/bpf/bpftool/btf_dumper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/bpf/bpftool/btf_dumper.c b/tools/bpf/bpftool/btf_dumper.c
index d66131f69689..397e5716ab6d 100644
--- a/tools/bpf/bpftool/btf_dumper.c
+++ b/tools/bpf/bpftool/btf_dumper.c
@@ -26,7 +26,7 @@ static void btf_dumper_ptr(const void *data, json_writer_t *jw,
 			   bool is_plain_text)
 {
 	if (is_plain_text)
-		jsonw_printf(jw, "%p", data);
+		jsonw_printf(jw, "%p", *(void **)data);
 	else
 		jsonw_printf(jw, "%lu", *(unsigned long *)data);
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf] bpftool: Fix printing incorrect pointer in btf_dump_ptr
  2020-01-10 23:16 [PATCH bpf] bpftool: Fix printing incorrect pointer in btf_dump_ptr Martin KaFai Lau
@ 2020-01-11 20:07 ` Quentin Monnet
  2020-01-12  3:09   ` Alexei Starovoitov
  0 siblings, 1 reply; 3+ messages in thread
From: Quentin Monnet @ 2020-01-11 20:07 UTC (permalink / raw)
  To: Martin KaFai Lau, bpf
  Cc: Alexei Starovoitov, Daniel Borkmann, David Miller, kernel-team, netdev

2020-01-10 15:16 UTC-0800 ~ Martin KaFai Lau <kafai@fb.com>
> For plain text output, it incorrectly prints the pointer value
> "void *data".  The "void *data" is actually pointing to memory that
> contains a bpf-map's value.  The intention is to print the content of
> the bpf-map's value instead of printing the pointer pointing to the
> bpf-map's value.
> 
> In this case, a member of the bpf-map's value is a pointer type.
> Thus, it should print the "*(void **)data".
> 
> Fixes: 22c349e8db89 ("tools: bpftool: fix format strings and arguments for jsonw_printf()")
> Cc: Quentin Monnet <quentin.monnet@netronome.com>
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>

My bad, thank you for the fix!

Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf] bpftool: Fix printing incorrect pointer in btf_dump_ptr
  2020-01-11 20:07 ` Quentin Monnet
@ 2020-01-12  3:09   ` Alexei Starovoitov
  0 siblings, 0 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2020-01-12  3:09 UTC (permalink / raw)
  To: Quentin Monnet
  Cc: Martin KaFai Lau, bpf, Alexei Starovoitov, Daniel Borkmann,
	David Miller, Kernel Team, Network Development

On Sat, Jan 11, 2020 at 12:07 PM Quentin Monnet
<quentin.monnet@netronome.com> wrote:
>
> 2020-01-10 15:16 UTC-0800 ~ Martin KaFai Lau <kafai@fb.com>
> > For plain text output, it incorrectly prints the pointer value
> > "void *data".  The "void *data" is actually pointing to memory that
> > contains a bpf-map's value.  The intention is to print the content of
> > the bpf-map's value instead of printing the pointer pointing to the
> > bpf-map's value.
> >
> > In this case, a member of the bpf-map's value is a pointer type.
> > Thus, it should print the "*(void **)data".
> >
> > Fixes: 22c349e8db89 ("tools: bpftool: fix format strings and arguments for jsonw_printf()")
> > Cc: Quentin Monnet <quentin.monnet@netronome.com>
> > Signed-off-by: Martin KaFai Lau <kafai@fb.com>
>
> My bad, thank you for the fix!
>
> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>

Applied to bpf tree. Thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-12  3:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-10 23:16 [PATCH bpf] bpftool: Fix printing incorrect pointer in btf_dump_ptr Martin KaFai Lau
2020-01-11 20:07 ` Quentin Monnet
2020-01-12  3:09   ` Alexei Starovoitov

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).