lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAADnVQLvVBKkeGXp5PBKHVNDwfsV7T5YmMtqEexZqjFK3Kz_=w@mail.gmail.com>
Date:   Tue, 6 Sep 2022 11:29:38 -0700
From:   Alexei Starovoitov <alexei.starovoitov@...il.com>
To:     Jules Irenge <jbi.octave@...il.com>
Cc:     Martin KaFai Lau <martin.lau@...ux.dev>,
        Elana.Copperman@...ileye.com, Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Song Liu <song@...nel.org>, Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>,
        LKML <linux-kernel@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
        Stanislav Fomichev <sdf@...gle.com>,
        Hao Luo <haoluo@...gle.com>
Subject: Re: [PATCH 2/2] bpf: Fix warning of incorrect type in return expression

On Sat, Sep 3, 2022 at 12:02 PM Jules Irenge <jbi.octave@...il.com> wrote:
>
> Sparse reports a warning at bpf_array_map_seq_start()
>
> "warning: incorrect type in return expression (different address spaces)"
>
> The root cause is the function expect a return of type void *
> but instead got a percpu value in one of the return.
>
> To fix this a variable of type void * is created
> and the complainining return value is saved into the variable and return.
>
> Fix incorrect type in return expression
>
> Signed-off-by: Jules Irenge <jbi.octave@...il.com>
> ---
>  kernel/bpf/arraymap.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
> index 624527401d4d..b1914168c23a 100644
> --- a/kernel/bpf/arraymap.c
> +++ b/kernel/bpf/arraymap.c
> @@ -548,6 +548,7 @@ static void *bpf_array_map_seq_start(struct seq_file *seq, loff_t *pos)
>         struct bpf_map *map = info->map;
>         struct bpf_array *array;
>         u32 index;
> +       void *pptrs;
>
>         if (info->index >= map->max_entries)
>                 return NULL;
> @@ -556,8 +557,10 @@ static void *bpf_array_map_seq_start(struct seq_file *seq, loff_t *pos)
>                 ++*pos;
>         array = container_of(map, struct bpf_array, map);
>         index = info->index & array->index_mask;
> -       if (info->percpu_value_buf)
> -              return array->pptrs[index];
> +       if (info->percpu_value_buf) {
> +               pptrs = &array->pptrs[index];
> +               return pptrs;
> +       }

Somebody will surely send a patch to optimize above back
to original code.
Please find a different way to shut up sparse or just ignore it.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ