LVS
lvs-devel
Google
 
Web LinuxVirtualServer.org

Re: [PATCH][next] treewide: uapi: Replace zero-length arrays with flexib

To: Jason Gunthorpe <jgg@xxxxxxxx>
Subject: Re: [PATCH][next] treewide: uapi: Replace zero-length arrays with flexible-array members
Cc: Daniel Borkmann <daniel@xxxxxxxxxxxxx>, Kees Cook <keescook@xxxxxxxxxxxx>, linux-kernel@xxxxxxxxxxxxxxx, x86@xxxxxxxxxx, dm-devel@xxxxxxxxxx, linux-m68k@xxxxxxxxxxxxxxxxxxxx, linux-mips@xxxxxxxxxxxxxxx, linux-s390@xxxxxxxxxxxxxxx, kvm@xxxxxxxxxxxxxxx, intel-gfx@xxxxxxxxxxxxxxxxxxxxx, dri-devel@xxxxxxxxxxxxxxxxxxxxx, netdev@xxxxxxxxxxxxxxx, bpf@xxxxxxxxxxxxxxx, linux-btrfs@xxxxxxxxxxxxxxx, linux-can@xxxxxxxxxxxxxxx, linux-fsdevel@xxxxxxxxxxxxxxx, linux1394-devel@xxxxxxxxxxxxxxxxxxxxx, io-uring@xxxxxxxxxxxxxxx, lvs-devel@xxxxxxxxxxxxxxx, linux-mtd@xxxxxxxxxxxxxxxxxxx, kasan-dev@xxxxxxxxxxxxxxxx, linux-mmc@xxxxxxxxxxxxxxx, nvdimm@xxxxxxxxxxxxxxx, netfilter-devel@xxxxxxxxxxxxxxx, coreteam@xxxxxxxxxxxxx, linux-perf-users@xxxxxxxxxxxxxxx, linux-raid@xxxxxxxxxxxxxxx, linux-sctp@xxxxxxxxxxxxxxx, linux-stm32@xxxxxxxxxxxxxxxxxxxxxxxxxxxx, linux-arm-kernel@xxxxxxxxxxxxxxxxxxx, linux-scsi@xxxxxxxxxxxxxxx, target-devel@xxxxxxxxxxxxxxx, linux-usb@xxxxxxxxxxxxxxx, virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx, v9fs-developer@xxxxxxxxxxxxxxxxxxxxx, linux-rdma@xxxxxxxxxxxxxxx, alsa-devel@xxxxxxxxxxxxxxxx, linux-hardening@xxxxxxxxxxxxxxx
From: "Gustavo A. R. Silva" <gustavoars@xxxxxxxxxx>
Date: Tue, 28 Jun 2022 15:56:23 +0200
On Tue, Jun 28, 2022 at 10:36:51AM -0300, Jason Gunthorpe wrote:
> On Tue, Jun 28, 2022 at 04:21:29AM +0200, Gustavo A. R. Silva wrote:
> 
> > > > Though maybe we could just switch off 
> > > > -Wgnu-variable-sized-type-not-at-end  during configuration ?
> 
> > We need to think in a different strategy.
> 
> I think we will need to switch off the warning in userspace - this is
> doable for rdma-core.
> 
> On the other hand, if the goal is to enable the array size check
> compiler warning I would suggest focusing only on those structs that
> actually hit that warning in the kernel. IIRC infiniband doesn't
> trigger it because it just pointer casts the flex array to some other
> struct.

Yep; this is actually why I reverted those changes in rdma (before
sending out the patch) when 0-day reported the same problems you pointed
out[1].

Also, that's the strategy I'm following right now with the one-element
array into flex-array member transformations. I'm addressing those cases
in which the trailing array is actually being iterated over, first.

I just added the patch to my -next tree, so it can be build-tested by
other people, and let's see what else is reported this week. :)

--
Gustavo

[1] https://lore.kernel.org/lkml/620ca2a5.NkAEIDEfiYoxE9%2Fu%25lkp@xxxxxxxxx/

> 
> It isn't actually an array it is a placeholder for a trailing
> structure, so it is never indexed.
> 
> This is also why we hit the warning because the convient way for
> userspace to compose the message is to squash the header and trailer
> structs together in a super struct on the stack, then invoke the
> ioctl.
> 
> Jason 

<Prev in Thread] Current Thread [Next in Thread>