Thread (15 messages) 15 messages, 7 authors, 2022-06-28

Re: [PATCH][next] treewide: uapi: Replace zero-length arrays with flexible-array members

From: Kees Cook <hidden>
Date: 2022-06-28 18:05:58
Also in: bpf, dm-devel, dri-devel, intel-gfx, io-uring, kvm, linux-arm-kernel, linux-btrfs, linux-can, linux-fsdevel, linux-hardening, linux-m68k, linux-mips, linux-mmc, linux-perf-users, linux-raid, linux-rdma, linux-s390, linux-scsi, linux-sctp, linux-usb, lkml, lvs-devel, netfilter-devel, nvdimm, target-devel, virtualization

On Tue, Jun 28, 2022 at 09:27:21AM +0200, Geert Uytterhoeven wrote:
Hi Gustavo,

Thanks for your patch!

On Mon, Jun 27, 2022 at 8:04 PM Gustavo A. R. Silva
[off-list ref] wrote:
quoted
There is a regular need in the kernel to provide a way to declare
having a dynamically sized set of trailing elements in a structure.
Kernel code should always use “flexible array members”[1] for these
cases. The older style of one-element or zero-length arrays should
no longer be used[2].
These rules apply to the kernel, but uapi is not considered part of the
kernel, so different rules apply.  Uapi header files should work with
whatever compiler that can be used for compiling userspace.
Right, userspace isn't bound by these rules, but the kernel ends up
consuming these structures, so we need to fix them. The [0] -> []
changes (when they are not erroneously being used within other
structures) is valid for all compilers. Flexible arrays are C99; it's
been 23 years. :)

But, yes, where we DO break stuff we need to workaround it, etc.

-- 
Kees Cook
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help