All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: Lam Thai <lamthai@arista.com>, bpf@vger.kernel.org
Cc: Lam Thai <lamthai@arista.com>
Subject: RE: [PATCH] bpftool: fix a wrong type cast in btf_dumper_int
Date: Wed, 24 Aug 2022 23:29:36 -0700	[thread overview]
Message-ID: <630716d02ebbe_e1c39208c3@john.notmuch> (raw)
In-Reply-To: <20220824225859.9038-1-lamthai@arista.com>

Lam Thai wrote:
> When `data` points to a boolean value, casting it to `int *` is problematic
> and could lead to a wrong value being passed to `jsonw_bool`. Change the
> cast to `bool *` instead.

How is it problematic? Its from BTF_KIND_INT by my quick reading.

> 
> Fixes: b12d6ec09730 ("bpf: btf: add btf print functionality")
> Signed-off-by: Lam Thai <lamthai@arista.com>
> ---

for bpf-next looks like a nice cleanup, I don't think its needed for bpf
tree?

>  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 125798b0bc5d..19924b6ce796 100644
> --- a/tools/bpf/bpftool/btf_dumper.c
> +++ b/tools/bpf/bpftool/btf_dumper.c
> @@ -452,7 +452,7 @@ static int btf_dumper_int(const struct btf_type *t, __u8 bit_offset,
>  					     *(char *)data);
>  		break;
>  	case BTF_INT_BOOL:
> -		jsonw_bool(jw, *(int *)data);
> +		jsonw_bool(jw, *(bool *)data);
>  		break;
>  	default:
>  		/* shouldn't happen */
> 
> base-commit: 6fc2838b148f8fe6aa14fc435e666984a0505018
> -- 
> 2.37.0
> 



  reply	other threads:[~2022-08-25  6:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-24 22:59 [PATCH] bpftool: fix a wrong type cast in btf_dumper_int Lam Thai
2022-08-25  6:29 ` John Fastabend [this message]
2022-08-25  8:56   ` Quentin Monnet
2022-08-25 15:54     ` John Fastabend
2022-08-25 18:44     ` Andrii Nakryiko
2022-08-25 18:50 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=630716d02ebbe_e1c39208c3@john.notmuch \
    --to=john.fastabend@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=lamthai@arista.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.