Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace zero-length arrays with flexible-array members #78

Closed
GustavoARSilva opened this issue Jun 3, 2020 · 9 comments
Closed

Replace zero-length arrays with flexible-array members #78

GustavoARSilva opened this issue Jun 3, 2020 · 9 comments
Assignees
Labels
compiler Needs compiler support [Idiom] fake flexible array [Linux] v5.18 Released in Linux kernel v5.18 [PATCH] Exists A patch exists to address the issue

Comments

@GustavoARSilva
Copy link
Collaborator

GustavoARSilva commented Jun 3, 2020

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” for these cases. The older style of
one-element or zero-length arrays should no longer be used.

In older C code, dynamically sized trailing elements were done by specifying
a one-element array at the end of a structure:

struct something {
        size_t count;
        struct foo items[1];
};

This led to fragile size calculations via sizeof() (which would need to remove
the size of the single trailing element to get a correct size of the “header”).
A GNU C extension was introduced to allow for zero-length arrays, to avoid
these kinds of size problems:

struct something {
        size_t count;
        struct foo items[0];
};

But this led to other problems, and didn’t solve some problems shared by both
styles, like not being able to detect when such an array is accidentally being
used not at the end of a structure (which could happen directly, or when
such a struct was in unions, structs of structs, etc).

C99 introduced “flexible array members”, which lacks a numeric size for the
array declaration entirely:

struct something {
        size_t count;
        struct foo items[];
};

This is the way the kernel expects dynamically sized trailing elements to be
declared. It allows the compiler to generate errors when the flexible array
does not occur last in the structure, which helps to prevent some kind of
undefined behavior bugs from being inadvertently introduced to the codebase.
It also allows the compiler to correctly analyze array sizes (via sizeof(),
CONFIG_FORTIFY_SOURCE, and CONFIG_UBSAN_BOUNDS). For instance, there is no
mechanism that warns us that the following application of the sizeof() operator
to a zero-length array always results in zero:

struct something {
        size_t count;
        struct foo items[0];
};

struct something *instance;

instance = kmalloc(struct_size(instance, items, count), GFP_KERNEL);
instance->count = count;

size = sizeof(instance->items) * instance->count;
memcpy(instance->items, source, size);

At the last line of code above, size turns out to be zero, when one might have
thought it represents the total size in bytes of the dynamic memory recently
allocated for the trailing array items. Here are a couple examples of this
issue: link 1, link 2. Instead, flexible array members have incomplete type, and so the
sizeof() operator may not be applied
, so any misuse of such operators will
be immediately noticed at build time.

With respect to one-element arrays, one has to be acutely aware that such
arrays occupy at least as much space as a single object of the type, hence they
contribute to the size of the enclosing structure
. This is prone to error every
time people want to calculate the total size of dynamic memory to allocate for
a structure containing an array of this kind as a member:

struct something {
        size_t count;
        struct foo items[1];
};

struct something *instance;

instance = kmalloc(struct_size(instance, items, count - 1), GFP_KERNEL);
instance->count = count;

size = sizeof(instance->items) * instance->count;
memcpy(instance->items, source, size);

In the example above, we had to remember to calculate count - 1 when using the
struct_size() helper, otherwise we would have –unintentionally– allocated memory
for one too many items objects. The cleanest and least error-prone way to
implement this is through the use of a flexible array member, instead:

struct something {
        size_t count;
        struct foo items[];
};

struct something *instance;

instance = kmalloc(struct_size(instance, items, count), GFP_KERNEL);
instance->count = count;

size = sizeof(instance->items[0]) * instance->count;
memcpy(instance->items, source, size);

NOTE: this documentation will be merged into mainline for Linux 5.9 (https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=68e4cd17e218971a2fd60c30fe14078dc0d8a68e)

@GustavoARSilva GustavoARSilva added [PATCH] Exists A patch exists to address the issue compiler Needs compiler support [Refactor] 0-element array Conversion away from zero-length array labels Jun 3, 2020
@GustavoARSilva GustavoARSilva self-assigned this Jun 3, 2020
@kees
Copy link

kees commented Aug 21, 2020

See also #25 (comment) with regard to adding compiler warnings.

@kees
Copy link

kees commented Sep 21, 2020

See also commit 5a76021 for re-enabling stringop-overflow warnings.

@GustavoARSilva
Copy link
Collaborator Author

The documentation is already in mainline v5.9 and the official document has been generated:

https://www.kernel.org/doc/html/v5.9/process/deprecated.html#zero-length-and-one-element-arrays

@kees kees added [Idiom] fake flexible array and removed [Refactor] 0-element array Conversion away from zero-length array labels Sep 16, 2021
tiwai pushed a commit to tiwai/sound that referenced this issue Sep 30, 2021
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].

Also, make use of the struct_size() helper in kzalloc().

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.10/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP#78
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20210929191504.GA337268@embeddedor
Signed-off-by: Takashi Iwai <tiwai@suse.de>
ammarfaizi2 pushed a commit to ammarfaizi2/linux-block that referenced this issue Oct 5, 2021
One-element and zero-length arrays are deprecated and should be
replaced with flexible-array members[1].

Replace zero-length array with flexible-array member and make use
of the struct_size() helper.

[1] https://www.kernel.org/doc/html/v5.10/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Link: KSPP/linux#160
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20210929194118.GA340431@embeddedor
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ammarfaizi2 pushed a commit to ammarfaizi2/linux-block that referenced this issue Oct 5, 2021
One-element and zero-length arrays are deprecated and should be
replaced with flexible-array members[1].

Replace zero-length array with flexible-array member and make use
of the struct_size() helper in kmalloc().

[1] https://www.kernel.org/doc/html/v5.10/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Link: KSPP/linux#160
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20210929193658.GA339070@embeddedor
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fengguang pushed a commit to 0day-ci/linux that referenced this issue Oct 24, 2021
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].

Also, make use of the struct_size() helper in kzalloc().

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.10/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP#78
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20210929191504.GA337268@embeddedor
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
ColinIanKing pushed a commit to ColinIanKing/linux-next that referenced this issue Oct 25, 2021
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].

Also, make use of the struct_size() helper in kzalloc().

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.10/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20210929191504.GA337268@embeddedor
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this issue Oct 28, 2021
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].

Also, make use of the struct_size() helper in kzalloc().

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.10/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20210929191504.GA337268@embeddedor
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
fengguang pushed a commit to 0day-ci/linux that referenced this issue Nov 1, 2021
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].

Also, make use of the struct_size() helper in kzalloc().

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.10/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP#78
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20210929191504.GA337268@embeddedor
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
@JoseExposito
Copy link

Hi! I'd like to get involved in the KSPP project.

I found a couple of places in linux-next where we could take advantage of flexible array members. For example in drivers/net/ethernet/marvell/prestera/prestera_hw.c we could use both flexible array members and struct_size.

I wasn't able to find any related work in patchwork, but since I'm new to the project I decided to ask before emailing the patch and also say hello :)

Is this bug fully addressed or should I email the patch?

Also, if there is a task for newcomers that I can look into, feel free to send me the link, I'll be happy to help.

@kees
Copy link

kees commented Dec 4, 2021

Welcome!

Yeah, I say go for it. @GustavoARSilva has been working on a treewide change too:
https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git/commit/?h=for-next/kspp-misc-fixes&id=fb29d640e9640985e307deaee123e83144305633
But I don't see that driver listed. Make a patch and send it out, we can get it reviewed, etc.

JoseExposito added a commit to JoseExposito/linux that referenced this issue Dec 4, 2021
One-element and zero-length arrays are deprecated and should be
replaced with flexible-array members:
https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays

Replace zero-length array with flexible-array member and make use
of the struct_size() helper.

Link: KSPP/linux#78
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
fengguang pushed a commit to 0day-ci/linux that referenced this issue Dec 4, 2021
One-element and zero-length arrays are deprecated and should be
replaced with flexible-array members:
https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays

Replace zero-length array with flexible-array member and make use
of the struct_size() helper.

Link: KSPP#78
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
@JoseExposito
Copy link

Thanks a lot Kees,

I just emailed the patch:

https://lore.kernel.org/linux-hardening/VI1P190MB07344B3C160E9A73165422A28F6B9@VI1P190MB0734.EURP190.PROD.OUTLOOK.COM/T/#t

I'm going to have a look to the issue tracker and see where l can help.

Jose

@GustavoARSilva
Copy link
Collaborator Author

Welcome!

Yeah, I say go for it. @GustavoARSilva has been working on a treewide change too: https://git.kernel.org/pub/scm/linux/kernel/git/gustavoars/linux.git/commit/?h=for-next/kspp-misc-fixes&id=fb29d640e9640985e307deaee123e83144305633 But I don't see that driver listed.

Yep; my patch is applied on top of v5.16-rc2, and the code José mentions was recently added and only appears in linux-next.

ammarfaizi2 pushed a commit to ammarfaizi2/linux-block that referenced this issue Dec 7, 2021
One-element and zero-length arrays are deprecated and should be
replaced with flexible-array members:
https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays

Replace zero-length array with flexible-array member and make use
of the struct_size() helper.

Link: KSPP/linux#78
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Reviewed-by: Volodymyr Mytnyk <vmytnyk@marvell.com>
Tested-by: Volodymyr Mytnyk <vmytnyk@marvell.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20211204171349.22776-1-jose.exposito89@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
pcmoore pushed a commit to linux-audit/audit-kernel that referenced this issue Dec 20, 2021
Zero-length arrays are deprecated and should be replaced with
flexible-array members.

Link: KSPP/linux#78
Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
fengguang pushed a commit to 0day-ci/linux that referenced this issue Feb 15, 2022
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
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP#78
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
github-actions bot pushed a commit to BluezTestBot/bluetooth-next that referenced this issue Feb 15, 2022
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
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
ColinIanKing pushed a commit to ColinIanKing/linux-next that referenced this issue Feb 16, 2022
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
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
eiffel-fl pushed a commit to eiffel-fl/linux-azure that referenced this issue Aug 30, 2024
BugLink: https://bugs.launchpad.net/bugs/2036450

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
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry picked from commit 5224f79)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
eiffel-fl pushed a commit to eiffel-fl/linux-azure that referenced this issue Aug 30, 2024
BugLink: https://bugs.launchpad.net/bugs/2036450

Zero-length arrays are deprecated[1] and we are moving towards
adopting C99 flexible-array members instead. So, replace zero-length
arrays in a couple of structures with flex-array members.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [2].

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays [1]
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [2]
Link: KSPP/linux#78
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Paulo Alcantara <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry picked from commit 4e551db)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
eiffel-fl pushed a commit to eiffel-fl/linux-azure that referenced this issue Aug 30, 2024
BugLink: https://bugs.launchpad.net/bugs/1970977

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
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry-picked from 92f0697ecd664e753515509689e96b40e750b5ed git://git.samba.org/sfrench/cifs-2.6.git)
[rtg - the full treewide commit was much more carnage then was needed for cifs]
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Philip Cox <philip.cox@canonical.com>
Acked-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
eiffel-fl pushed a commit to eiffel-fl/linux-azure that referenced this issue Aug 30, 2024
BugLink: https://bugs.launchpad.net/bugs/2036450

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
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry picked from commit 5224f79)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
eiffel-fl pushed a commit to eiffel-fl/linux-azure that referenced this issue Aug 30, 2024
BugLink: https://bugs.launchpad.net/bugs/2036450

Zero-length arrays are deprecated[1] and we are moving towards
adopting C99 flexible-array members instead. So, replace zero-length
arrays in a couple of structures with flex-array members.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [2].

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays [1]
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [2]
Link: KSPP/linux#78
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Paulo Alcantara <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry picked from commit 4e551db)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
eiffel-fl pushed a commit to eiffel-fl/linux-azure that referenced this issue Aug 30, 2024
BugLink: https://bugs.launchpad.net/bugs/1970977

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
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry-picked from 92f0697ecd664e753515509689e96b40e750b5ed git://git.samba.org/sfrench/cifs-2.6.git)
[rtg - the full treewide commit was much more carnage then was needed for cifs]
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Philip Cox <philip.cox@canonical.com>
Acked-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
eiffel-fl pushed a commit to eiffel-fl/linux-azure that referenced this issue Aug 30, 2024
BugLink: https://bugs.launchpad.net/bugs/2036450

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
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry picked from commit 5224f79)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
eiffel-fl pushed a commit to eiffel-fl/linux-azure that referenced this issue Aug 30, 2024
BugLink: https://bugs.launchpad.net/bugs/2036450

Zero-length arrays are deprecated[1] and we are moving towards
adopting C99 flexible-array members instead. So, replace zero-length
arrays in a couple of structures with flex-array members.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [2].

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays [1]
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [2]
Link: KSPP/linux#78
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Paulo Alcantara <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry picked from commit 4e551db)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
eiffel-fl pushed a commit to eiffel-fl/linux-azure that referenced this issue Aug 30, 2024
BugLink: https://bugs.launchpad.net/bugs/1970977

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
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry-picked from 92f0697ecd664e753515509689e96b40e750b5ed git://git.samba.org/sfrench/cifs-2.6.git)
[rtg - the full treewide commit was much more carnage then was needed for cifs]
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Philip Cox <philip.cox@canonical.com>
Acked-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
eiffel-fl pushed a commit to eiffel-fl/linux-azure that referenced this issue Aug 30, 2024
BugLink: https://bugs.launchpad.net/bugs/2036450

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
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry picked from commit 5224f79)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
eiffel-fl pushed a commit to eiffel-fl/linux-azure that referenced this issue Aug 30, 2024
BugLink: https://bugs.launchpad.net/bugs/2036450

Zero-length arrays are deprecated[1] and we are moving towards
adopting C99 flexible-array members instead. So, replace zero-length
arrays in a couple of structures with flex-array members.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [2].

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays [1]
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [2]
Link: KSPP/linux#78
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Paulo Alcantara <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry picked from commit 4e551db)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
PlaidCat pushed a commit to ctrliq/kernel-src-tree that referenced this issue Sep 12, 2024
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2040643

commit 5224f79
Author: Gustavo A. R. Silva <gustavoars@kernel.org>
Date:   Mon Feb 14 19:11:44 2022 -0600

    treewide: Replace zero-length arrays with flexible-array members

    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
      ];
    };

    UAPI and wireless changes were intentionally excluded from this patch
    and will be sent out separately.

    [1] https://en.wikipedia.org/wiki/Flexible_array_member
    [2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

    Link: KSPP/linux#78
    Reviewed-by: Kees Cook <keescook@chromium.org>
    Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>

Conflicts:
	Only octeontx2 hunks.
PlaidCat added a commit to ctrliq/kernel-src-tree that referenced this issue Sep 13, 2024
jira LE-1907
Rebuild_History Non-Buildable kernel-4.18.0-408.el8
commit-author Xiu Jianfeng <xiujianfeng@huawei.com>
commit ed98ea2

Zero-length arrays are deprecated and should be replaced with
flexible-array members.

Link: KSPP/linux#78
	Signed-off-by: Xiu Jianfeng <xiujianfeng@huawei.com>
	Signed-off-by: Paul Moore <paul@paul-moore.com>
(cherry picked from commit ed98ea2)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
PlaidCat added a commit to ctrliq/kernel-src-tree that referenced this issue Sep 13, 2024
jira LE-1907
Rebuild_History Non-Buildable kernel-4.18.0-512.el8
commit-author Gustavo A. R. Silva <gustavoars@kernel.org>
commit 2631c5b

Zero-length arrays are deprecated [1] and have to be replaced by C99
flexible-array members.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines
on memcpy() and help to make progress towards globally enabling
-fstrict-flex-arrays=3 [2]

Link: KSPP/linux#78 [1]
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [2]
	Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
	Reviewed-by: Simon Horman <simon.horman@corigine.com>
	Signed-off-by: Felix Fietkau <nbd@nbd.name>
(cherry picked from commit 2631c5b)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
PlaidCat added a commit to ctrliq/kernel-src-tree that referenced this issue Sep 13, 2024
jira LE-1907
Rebuild_History Non-Buildable kernel-4.18.0-546.el8
commit-author Gustavo A. R. Silva <gustavoars@kernel.org>
commit 4e551db

Zero-length arrays are deprecated[1] and we are moving towards
adopting C99 flexible-array members instead. So, replace zero-length
arrays in a couple of structures with flex-array members.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [2].

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays [1]
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [2]
Link: KSPP/linux#78
	Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
	Reviewed-by: Kees Cook <keescook@chromium.org>
	Reviewed-by: Paulo Alcantara <pc@cjr.nz>
	Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry picked from commit 4e551db)
	Signed-off-by: Jonathan Maple <jmaple@ciq.com>
delphix-devops-bot pushed a commit to delphix/linux-kernel-azure that referenced this issue Sep 18, 2024
BugLink: https://bugs.launchpad.net/bugs/1970977

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
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry-picked from 92f0697ecd664e753515509689e96b40e750b5ed git://git.samba.org/sfrench/cifs-2.6.git)
[rtg - the full treewide commit was much more carnage then was needed for cifs]
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Philip Cox <philip.cox@canonical.com>
Acked-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
delphix-devops-bot pushed a commit to delphix/linux-kernel-azure that referenced this issue Sep 18, 2024
BugLink: https://bugs.launchpad.net/bugs/2036450

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
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry picked from commit 5224f79)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
delphix-devops-bot pushed a commit to delphix/linux-kernel-azure that referenced this issue Sep 18, 2024
BugLink: https://bugs.launchpad.net/bugs/2036450

Zero-length arrays are deprecated[1] and we are moving towards
adopting C99 flexible-array members instead. So, replace zero-length
arrays in a couple of structures with flex-array members.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [2].

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays [1]
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [2]
Link: KSPP/linux#78
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Paulo Alcantara <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry picked from commit 4e551db)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
namjaejeon pushed a commit to namjaejeon/ksmbd that referenced this issue Oct 7, 2024
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 8 --sp-file script.cocci --include-headers --dir . > output.patch)

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

struct S {
  ...
  T1 member;
  T2 array[
- 0
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon pushed a commit to namjaejeon/ksmbd that referenced this issue Oct 7, 2024
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 8 --sp-file script.cocci --include-headers --dir . > output.patch)

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

struct S {
  ...
  T1 member;
  T2 array[
- 0
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
namjaejeon pushed a commit to namjaejeon/ksmbd that referenced this issue Oct 13, 2024
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 8 --sp-file script.cocci --include-headers --dir . > output.patch)

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

struct S {
  ...
  T1 member;
  T2 array[
- 0
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
delphix-devops-bot pushed a commit to delphix/linux-kernel-azure that referenced this issue Oct 20, 2024
BugLink: https://bugs.launchpad.net/bugs/1970977

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
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry-picked from 92f0697ecd664e753515509689e96b40e750b5ed git://git.samba.org/sfrench/cifs-2.6.git)
[rtg - the full treewide commit was much more carnage then was needed for cifs]
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Philip Cox <philip.cox@canonical.com>
Acked-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
delphix-devops-bot pushed a commit to delphix/linux-kernel-azure that referenced this issue Oct 20, 2024
BugLink: https://bugs.launchpad.net/bugs/2036450

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
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry picked from commit 5224f79)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
delphix-devops-bot pushed a commit to delphix/linux-kernel-azure that referenced this issue Oct 20, 2024
BugLink: https://bugs.launchpad.net/bugs/2036450

Zero-length arrays are deprecated[1] and we are moving towards
adopting C99 flexible-array members instead. So, replace zero-length
arrays in a couple of structures with flex-array members.

This helps with the ongoing efforts to tighten the FORTIFY_SOURCE
routines on memcpy() and help us make progress towards globally
enabling -fstrict-flex-arrays=3 [2].

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays [1]
Link: https://gcc.gnu.org/pipermail/gcc-patches/2022-October/602902.html [2]
Link: KSPP/linux#78
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Paulo Alcantara <pc@cjr.nz>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry picked from commit 4e551db)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
namjaejeon pushed a commit to cifsd-team/ksmbd that referenced this issue Oct 20, 2024
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 8 --sp-file script.cocci --include-headers --dir . > output.patch)

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

struct S {
  ...
  T1 member;
  T2 array[
- 0
  ];
};

UAPI and wireless changes were intentionally excluded from this patch
and will be sent out separately.

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Nov 10, 2024
Replace the deprecated zero-length array with a modern flexible array
member in the struct iscsi_bsg_host_vendor_reply.

Link: KSPP#78
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Nov 10, 2024
Replace the deprecated zero-length array with a modern flexible array
member in the struct iscsi_bsg_host_vendor_reply.

Link: KSPP#78
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Nov 21, 2024
Replace the deprecated zero-length array with a modern flexible array
member in the struct sctp_idatahdr.

Link: KSPP#78
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
staging-kernelci-org pushed a commit to kernelci/linux that referenced this issue Dec 5, 2024
Replace the deprecated zero-length array with a modern flexible array
member in the struct iscsi_bsg_host_vendor_reply.

Link: KSPP#78
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://lore.kernel.org/r/20241110223323.42772-2-thorsten.blum@linux.dev
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
guojinhui-liam pushed a commit to bytedance/kernel that referenced this issue Jan 6, 2025
commit 8fcf4c4 upstream

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

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://www.kernel.org/doc/html/v5.16/process/deprecated.html#zero-length-and-one-element-arrays

Link: KSPP/linux#78
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Fengnan Chang <changfengnan@bytedance.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Needs compiler support [Idiom] fake flexible array [Linux] v5.18 Released in Linux kernel v5.18 [PATCH] Exists A patch exists to address the issue
Projects
None yet
Development

No branches or pull requests

3 participants