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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f1ffd814-538b-1913-5b67-266060abfa7a@iogearbox.net>
Date:   Mon, 4 May 2020 23:06:59 +0200
From:   Daniel Borkmann <daniel@...earbox.net>
To:     Arnd Bergmann <arnd@...db.de>, linux-kernel@...r.kernel.org,
        Alexei Starovoitov <ast@...nel.org>,
        Hannes Frederic Sowa <hannes@...essinduktion.org>,
        "David S. Miller" <davem@...emloft.net>
Cc:     Brad Spengler <spender@...ecurity.net>,
        Daniel Borkmann <dborkman@...hat.com>,
        Alexei Starovoitov <ast@...mgrid.com>,
        Kees Cook <keescook@...omium.org>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        Andrii Nakryiko <andriin@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...omium.org>,
        Stanislav Fomichev <sdf@...gle.com>,
        Ilya Leoshkevich <iii@...ux.ibm.com>,
        Toke Høiland-Jørgensen <toke@...hat.com>,
        Björn Töpel <bjorn.topel@...el.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Jiri Olsa <jolsa@...nel.org>,
        Pankaj Bharadiya <pankaj.laxminarayan.bharadiya@...el.com>,
        netdev@...r.kernel.org, bpf@...r.kernel.org
Subject: Re: [PATCH 05/15] bpf: avoid gcc-10 stringop-overflow warning

On 4/30/20 11:30 PM, Arnd Bergmann wrote:
> gcc-10 warns about accesses to zero-length arrays:
> 
> kernel/bpf/core.c: In function 'bpf_patch_insn_single':
> cc1: warning: writing 8 bytes into a region of size 0 [-Wstringop-overflow=]
> In file included from kernel/bpf/core.c:21:
> include/linux/filter.h:550:20: note: at offset 0 to object 'insnsi' with size 0 declared here
>    550 |   struct bpf_insn  insnsi[0];
>        |                    ^~~~~~
> 
> In this case, we really want to have two flexible-array members,
> but that is not possible. Removing the union to make insnsi a
> flexible-array member while leaving insns as a zero-length array
> fixes the warning, as nothing writes to the other one in that way.
> 
> This trick only works on linux-3.18 or higher, as older versions
> had additional members in the union.
> 
> Fixes: 60a3b2253c41 ("net: bpf: make eBPF interpreter images read-only")
> Signed-off-by: Arnd Bergmann <arnd@...db.de>

Not pretty but looks okay to me, both have the same offset afterwards
in the pahole dump as well.

struct bpf_prog {
[...]
         unsigned int               (*bpf_func)(const void  *, const struct bpf_insn  *); /*    48     8 */
         struct sock_filter         insns[0];             /*    56     0 */
         struct bpf_insn            insnsi[];             /*    56     0 */

         /* size: 56, cachelines: 1, members: 21 */
         /* sum members: 50, holes: 1, sum holes: 4 */
         /* sum bitfield members: 10 bits, bit holes: 1, sum bit holes: 6 bits */
         /* last cacheline: 56 bytes */
};

Applied to bpf-next, thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ