Message ID | 20220216195306.GA904220@embeddedor (mailing list archive) |
---|---|
State | New, archived |
Commit | b8efcb1f55c5a6ac03a102daafb66da898613dcf |
Delegated to: | Gustavo A. R. Silva |
Headers | show |
Series | uapi: wireless: Replace zero-length array with flexible-array member | expand |
On Wed, Feb 16, 2022 at 01:53:06PM -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]. > > [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: https://github.com/KSPP/linux/issues/78 > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> This UAPI change should be fine for any compiler that understood the older "[0]" syntax. Reviewed-by: Kees Cook <keescook@chromium.org>
On Wed, Feb 16, 2022 at 12:36:27PM -0800, Kees Cook wrote: > On Wed, Feb 16, 2022 at 01:53:06PM -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]. > > > > [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: https://github.com/KSPP/linux/issues/78 > > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> > > This UAPI change should be fine for any compiler that understood the > older "[0]" syntax. > > Reviewed-by: Kees Cook <keescook@chromium.org> Hi all, Friendly ping: can someone take this, please? ...I can take this in my -next tree in the meantime. Thanks -- Gustavo
diff --git a/include/uapi/linux/wireless.h b/include/uapi/linux/wireless.h index 08967b3f19c8..3c2ad5fae17f 100644 --- a/include/uapi/linux/wireless.h +++ b/include/uapi/linux/wireless.h @@ -835,7 +835,7 @@ struct iw_encode_ext { * individual keys */ __u16 alg; /* IW_ENCODE_ALG_* */ __u16 key_len; - __u8 key[0]; + __u8 key[]; }; /* SIOCSIWMLME data */
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: https://github.com/KSPP/linux/issues/78 Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> --- include/uapi/linux/wireless.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)