Thread (7 messages) 7 messages, 4 authors, 2022-02-16

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

From: Kees Cook <hidden>
Date: 2022-02-15 18:17:50
Also in: alsa-devel, dri-devel, intel-gfx, linux-acpi, linux-alpha, linux-arch, linux-arm-kernel, linux-bluetooth, linux-cifs, linux-crypto, linux-devicetree, linux-ext4, linux-hardening, linux-i3c, linux-mm, linux-omap, linux-perf-users, linux-rdma, linux-s390, linux-scsi, linux-sh, linux-staging, linux-um, lkml, nouveau, sparclinux, target-devel

On Tue, Feb 15, 2022 at 11:47:43AM -0600, Gustavo A. R. Silva wrote:
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].

This code was transformed with the help of Coccinelle:
(next-20220214$ spatch --jobs $(getconf _NPROCESSORS_ONLN) --sp-file script.cocci --include-headers --dir . > output.patch)

@@
identifier S, member, array;
type T1, T2;
@@

struct S {
  ...
  T1 member;
  T2 array[
- 0
  ];
};
These all look trivially correct to me. Only two didn't have the end of
the struct visible in the patch, and checking those showed them to be
trailing members as well, so:

Reviewed-by: Kees Cook <redacted>

-- 
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