All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox.net>
To: Arnd Bergmann <arnd@arndb.de>,
	linux-kernel@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
	Hannes Frederic Sowa <hannes@stressinduktion.org>,
	"David S. Miller" <davem@davemloft.net>
Cc: "Brad Spengler" <spender@grsecurity.net>,
	"Daniel Borkmann" <dborkman@redhat.com>,
	"Alexei Starovoitov" <ast@plumgrid.com>,
	"Kees Cook" <keescook@chromium.org>,
	"Martin KaFai Lau" <kafai@fb.com>,
	"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
	"Andrii Nakryiko" <andriin@fb.com>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"KP Singh" <kpsingh@chromium.org>,
	"Stanislav Fomichev" <sdf@google.com>,
	"Ilya Leoshkevich" <iii@linux.ibm.com>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>,
	"Björn Töpel" <bjorn.topel@intel.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Jiri Olsa" <jolsa@kernel.org>,
	"Pankaj Bharadiya" <pankaj.laxminarayan.bharadiya@intel.com>,
	netdev@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH 05/15] bpf: avoid gcc-10 stringop-overflow warning
Date: Mon, 4 May 2020 23:06:59 +0200	[thread overview]
Message-ID: <f1ffd814-538b-1913-5b67-266060abfa7a@iogearbox.net> (raw)
In-Reply-To: <20200430213101.135134-6-arnd@arndb.de>

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@arndb.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!

  reply	other threads:[~2020-05-04 21:07 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-30 21:30 [PATCH 00/15] gcc-10 warning fixes Arnd Bergmann
2020-04-30 21:30 ` Arnd Bergmann
2020-04-30 21:30 ` Arnd Bergmann
2020-04-30 21:30 ` [PATCH 01/15] crypto - Avoid free() namespace collision Arnd Bergmann
2020-05-08  6:06   ` Herbert Xu
2020-04-30 21:30 ` [PATCH 02/15] iwlwifi: mvm: fix gcc-10 zero-length-bounds warning Arnd Bergmann
2020-06-10 12:18   ` Luciano Coelho
2020-04-30 21:30 ` [PATCH 03/15] mwifiex: avoid -Wstringop-overflow warning Arnd Bergmann
2020-05-06  8:43   ` Kalle Valo
2020-04-30 21:30 ` [PATCH 04/15] ath10k: fix gcc-10 zero-length-bounds warnings Arnd Bergmann
2020-04-30 21:30   ` Arnd Bergmann
2020-04-30 21:45   ` Gustavo A. R. Silva
2020-04-30 21:45     ` Gustavo A. R. Silva
2020-04-30 21:44     ` Arnd Bergmann
2020-04-30 21:44       ` Arnd Bergmann
2020-05-04 11:54     ` Kalle Valo
2020-05-04 11:54       ` Kalle Valo
2020-05-04 16:09       ` Gustavo A. R. Silva
2020-05-04 16:09         ` Gustavo A. R. Silva
2020-05-05  4:56         ` Kalle Valo
2020-05-05  4:56           ` Kalle Valo
2020-04-30 21:30 ` [PATCH 05/15] bpf: avoid gcc-10 stringop-overflow warning Arnd Bergmann
2020-05-04 21:06   ` Daniel Borkmann [this message]
2020-04-30 21:30 ` [PATCH 06/15] netfilter: conntrack: avoid gcc-10 zero-length-bounds warning Arnd Bergmann
2020-05-10 21:48   ` Pablo Neira Ayuso
2020-04-30 21:30 ` [PATCH 07/15] drop_monitor: work around gcc-10 stringop-overflow warning Arnd Bergmann
2020-05-01 11:28   ` Neil Horman
2020-04-30 21:30 ` [PATCH 08/15] usb: ehci: avoid gcc-10 zero-length-bounds warning Arnd Bergmann
2020-05-01  2:42   ` Alan Stern
2020-05-01 20:06     ` Arnd Bergmann
2020-05-01 20:10       ` Alan Stern
2020-04-30 21:30 ` [PATCH 09/15] udf: avoid gcc-10 zero-length-bounds warnings Arnd Bergmann
2020-04-30 21:54   ` Pali Rohár
2020-05-01 20:30     ` Arnd Bergmann
2020-05-01 20:48       ` Jan Kara
2020-05-01 20:57       ` Pali Rohár
2020-04-30 21:30 ` [PATCH 10/15] hpfs: avoid gcc-10 zero-length-bounds warning Arnd Bergmann
2020-04-30 21:30 ` [PATCH 11/15] omfs: avoid gcc-10 stringop-overflow warning Arnd Bergmann
2020-04-30 21:30 ` [PATCH 12/15] media: s5k5baf: avoid gcc-10 zero-length-bounds warning Arnd Bergmann
2020-04-30 21:46   ` Gustavo A. R. Silva
2020-04-30 21:30 ` [PATCH 13/15] scsi: sas: " Arnd Bergmann
2020-05-01  7:47   ` John Garry
2020-05-01  7:54     ` Arnd Bergmann
2020-05-01 14:53       ` James Bottomley
2020-05-01 17:36         ` Arnd Bergmann
2020-04-30 21:30 ` [PATCH 14/15] isci: " Arnd Bergmann
2020-04-30 21:30 ` [PATCH 15/15] nvme: " Arnd Bergmann
2020-04-30 21:30   ` Arnd Bergmann
2020-05-01  7:32   ` Christoph Hellwig
2020-05-01  7:32     ` Christoph Hellwig

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=f1ffd814-538b-1913-5b67-266060abfa7a@iogearbox.net \
    --to=daniel@iogearbox.net \
    --cc=andriin@fb.com \
    --cc=arnd@arndb.de \
    --cc=ast@kernel.org \
    --cc=ast@plumgrid.com \
    --cc=bjorn.topel@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=dborkman@redhat.com \
    --cc=hannes@stressinduktion.org \
    --cc=iii@linux.ibm.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kafai@fb.com \
    --cc=keescook@chromium.org \
    --cc=kpsingh@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pankaj.laxminarayan.bharadiya@intel.com \
    --cc=sdf@google.com \
    --cc=songliubraving@fb.com \
    --cc=spender@grsecurity.net \
    --cc=tglx@linutronix.de \
    --cc=toke@redhat.com \
    --cc=yhs@fb.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.