lkml.org 
[lkml]   [2022]   [Oct]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 6.0 244/862] bpftool: Fix a wrong type cast in btf_dumper_int
    Date
    From: Lam Thai <lamthai@arista.com>

    [ Upstream commit 7184aef9c0f7a81db8fd18d183ee42481d89bf35 ]

    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.

    Fixes: b12d6ec09730 ("bpf: btf: add btf print functionality")
    Signed-off-by: Lam Thai <lamthai@arista.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Reviewed-by: Quentin Monnet <quentin@isovalent.com>
    Acked-by: John Fastabend <john.fastabend@gmail.com>
    Link: https://lore.kernel.org/bpf/20220824225859.9038-1-lamthai@arista.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    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 */
    --
    2.35.1


    \
     
     \ /
      Last update: 2022-10-19 15:59    [W:4.126 / U:1.160 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site