diff mbox series

[next] iwlwifi: fw: Replace zero-length arrays with flexible-array members

Message ID 20220216195015.GA904148@embeddedor (mailing list archive)
State Mainlined
Commit 34e63cd5ba29fb832f3fe31e37cea28027979c1d
Delegated to: Gustavo A. R. Silva
Headers show
Series [next] iwlwifi: fw: Replace zero-length arrays with flexible-array members | expand

Commit Message

Gustavo A. R. Silva Feb. 16, 2022, 7:50 p.m. UTC
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>
---
 drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h |  4 ++--
 drivers/net/wireless/intel/iwlwifi/fw/api/debug.h   |  4 ++--
 drivers/net/wireless/intel/iwlwifi/fw/api/filter.h  |  2 +-
 drivers/net/wireless/intel/iwlwifi/fw/api/scan.h    |  4 ++--
 drivers/net/wireless/intel/iwlwifi/fw/api/sta.h     |  2 +-
 drivers/net/wireless/intel/iwlwifi/fw/api/tdls.h    |  2 +-
 drivers/net/wireless/intel/iwlwifi/fw/error-dump.h  |  2 +-
 drivers/net/wireless/intel/iwlwifi/fw/file.h        | 12 ++++++------
 8 files changed, 16 insertions(+), 16 deletions(-)

Comments

Kees Cook Feb. 16, 2022, 8:35 p.m. UTC | #1
On Wed, Feb 16, 2022 at 01:50:15PM -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>

Reviewed-by: Kees Cook <keescook@chromium.org>
Gustavo A. R. Silva March 26, 2022, 12:38 a.m. UTC | #2
On Wed, Feb 16, 2022 at 12:35:14PM -0800, Kees Cook wrote:
> On Wed, Feb 16, 2022 at 01:50:15PM -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>
> 
> 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
Kalle Valo March 28, 2022, 5:47 a.m. UTC | #3
"Gustavo A. R. Silva" <gustavoars@kernel.org> writes:

> On Wed, Feb 16, 2022 at 12:35:14PM -0800, Kees Cook wrote:
>> On Wed, Feb 16, 2022 at 01:50:15PM -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>
>> 
>> 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.

Like we have discussed before, please don't take any wireless patches to
your tree. The conflicts just cause more work of us.

I assigned this patch to me on patchwork and I'm planning to take it to
wireless-next once it opens. Luca, ack?
Gustavo A. R. Silva March 28, 2022, 6:23 a.m. UTC | #4
On 3/28/22 00:47, Kalle Valo wrote:
> "Gustavo A. R. Silva" <gustavoars@kernel.org> writes:
> 
>> On Wed, Feb 16, 2022 at 12:35:14PM -0800, Kees Cook wrote:
>>> On Wed, Feb 16, 2022 at 01:50:15PM -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>
>>>
>>> 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.
> 
> Like we have discussed before, please don't take any wireless patches to
> your tree. The conflicts just cause more work of us.

Sure thing. I just removed it from my tree.

I didn't get any reply from wireless people in more than a month, and
that's why I temporarily took it in my tree so it doesn't get lost. :)

> I assigned this patch to me on patchwork and I'm planning to take it to
> wireless-next once it opens. Luca, ack?

Awesome.

Thanks
--
Gustavo
Luca Coelho April 1, 2022, 8:10 a.m. UTC | #5
On Mon, 2022-03-28 at 01:23 -0500, Gustavo A. R. Silva wrote:
> 
> On 3/28/22 00:47, Kalle Valo wrote:
> > "Gustavo A. R. Silva" <gustavoars@kernel.org> writes:
> > 
> > > On Wed, Feb 16, 2022 at 12:35:14PM -0800, Kees Cook wrote:
> > > > On Wed, Feb 16, 2022 at 01:50:15PM -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>
> > > > 
> > > > 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.
> > 
> > Like we have discussed before, please don't take any wireless patches to
> > your tree. The conflicts just cause more work of us.
> 
> Sure thing. I just removed it from my tree.
> 
> I didn't get any reply from wireless people in more than a month, and
> that's why I temporarily took it in my tree so it doesn't get lost. :)
> 
> > I assigned this patch to me on patchwork and I'm planning to take it to
> > wireless-next once it opens. Luca, ack?

Sorry for the delay, I was on vacation.

As you some of you already know, I'm stepping aside from my role as
iwlwifi maintainer (FWIW I'm moving to Intel Graphics).  I can still
ack this change, but we'll soon send an update to MAINTAINERS to
reflect the change.

Acked-by: Luca Coelho <luciano.coelho@intel.com>

--
Cheers,
Luca.
Kalle Valo April 1, 2022, 11:43 a.m. UTC | #6
"Gustavo A. R. Silva" <gustavo@embeddedor.com> writes:

> On 3/28/22 00:47, Kalle Valo wrote:
>> "Gustavo A. R. Silva" <gustavoars@kernel.org> writes:
>>
>>> On Wed, Feb 16, 2022 at 12:35:14PM -0800, Kees Cook wrote:
>>>> On Wed, Feb 16, 2022 at 01:50:15PM -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>
>>>>
>>>> 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.
>>
>> Like we have discussed before, please don't take any wireless patches to
>> your tree. The conflicts just cause more work of us.
>
> Sure thing. I just removed it from my tree.
>
> I didn't get any reply from wireless people in more than a month, and
> that's why I temporarily took it in my tree so it doesn't get lost. :)

That increases the risk of conflicts and, because of multiple trees we
have, the conflicts cause more work for us. Please don't take ANY
wireless patches to your tree (or any other tree for that matter) unless
Johannes or me has acked them.

If you don't get reply to your patch for few weeks (and the merge window
is not open), you can ping in the list or contact me.
Kalle Valo April 6, 2022, 7:18 a.m. UTC | #7
"Gustavo A. R. Silva" <gustavoars@kernel.org> 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>
> Reviewed-by: Kees Cook <keescook@chromium.org>
> Acked-by: Luca Coelho <luciano.coelho@intel.com>

Patch applied to wireless-next.git, thanks.

34e63cd5ba29 iwlwifi: fw: Replace zero-length arrays with flexible-array members
diff mbox series

Patch

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h b/drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h
index 456b7eaac570..9df7eda3b3e7 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/dbg-tlv.h
@@ -25,7 +25,7 @@  struct iwl_fw_ini_hcmd {
 	u8 id;
 	u8 group;
 	__le16 reserved;
-	u8 data[0];
+	u8 data[];
 } __packed; /* FW_DEBUG_TLV_HCMD_DATA_API_S_VER_1 */
 
 /**
@@ -275,7 +275,7 @@  struct iwl_fw_ini_conf_set_tlv {
 	__le32 time_point;
 	__le32 set_type;
 	__le32 addr_offset;
-	struct iwl_fw_ini_addr_val addr_val[0];
+	struct iwl_fw_ini_addr_val addr_val[];
 } __packed; /* FW_TLV_DEBUG_CONFIG_SET_API_S_VER_1 */
 
 /**
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/debug.h b/drivers/net/wireless/intel/iwlwifi/fw/api/debug.h
index 029ae64bf2b2..e732afc7204d 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/debug.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/debug.h
@@ -234,7 +234,7 @@  struct iwl_mfu_assert_dump_notif {
 	__le16   index_num;
 	__le16   parts_num;
 	__le32   data_size;
-	__le32   data[0];
+	__le32   data[];
 } __packed; /* MFU_DUMP_ASSERT_API_S_VER_1 */
 
 /**
@@ -270,7 +270,7 @@  struct iwl_mvm_marker {
 	u8 marker_id;
 	__le16 reserved;
 	__le64 timestamp;
-	__le32 metadata[0];
+	__le32 metadata[];
 } __packed; /* MARKER_API_S_VER_1 */
 
 /**
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/filter.h b/drivers/net/wireless/intel/iwlwifi/fw/api/filter.h
index dd62a63956b3..0783b531f616 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/filter.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/filter.h
@@ -33,7 +33,7 @@  struct iwl_mcast_filter_cmd {
 	u8 pass_all;
 	u8 bssid[6];
 	u8 reserved[2];
-	u8 addr_list[0];
+	u8 addr_list[];
 } __packed; /* MCAST_FILTERING_CMD_API_S_VER_1 */
 
 #define MAX_BCAST_FILTERS 8
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/scan.h b/drivers/net/wireless/intel/iwlwifi/fw/api/scan.h
index 5413087ae909..5543d9cb74c8 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/scan.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/scan.h
@@ -1165,7 +1165,7 @@  struct iwl_scan_offload_profiles_query_v1 {
 	u8 resume_while_scanning;
 	u8 self_recovery;
 	__le16 reserved;
-	struct iwl_scan_offload_profile_match_v1 matches[0];
+	struct iwl_scan_offload_profile_match_v1 matches[];
 } __packed; /* SCAN_OFFLOAD_PROFILES_QUERY_RSP_S_VER_2 */
 
 /**
@@ -1209,7 +1209,7 @@  struct iwl_scan_offload_profiles_query {
 	u8 resume_while_scanning;
 	u8 self_recovery;
 	__le16 reserved;
-	struct iwl_scan_offload_profile_match matches[0];
+	struct iwl_scan_offload_profile_match matches[];
 } __packed; /* SCAN_OFFLOAD_PROFILES_QUERY_RSP_S_VER_3 */
 
 /**
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/sta.h b/drivers/net/wireless/intel/iwlwifi/fw/api/sta.h
index 5edbe27c0922..d62fed543276 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/sta.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/sta.h
@@ -477,7 +477,7 @@  struct iwl_mvm_wep_key_cmd {
 	u8 decryption_type;
 	u8 flags;
 	u8 reserved;
-	struct iwl_mvm_wep_key wep_key[0];
+	struct iwl_mvm_wep_key wep_key[];
 } __packed; /* SEC_CURR_WEP_KEY_CMD_API_S_VER_2 */
 
 /**
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/tdls.h b/drivers/net/wireless/intel/iwlwifi/fw/api/tdls.h
index 14d35000abed..893438aadab0 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/api/tdls.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/api/tdls.h
@@ -132,7 +132,7 @@  struct iwl_tdls_config_cmd {
 
 	__le32 pti_req_data_offset;
 	struct iwl_tx_cmd pti_req_tx_cmd;
-	u8 pti_req_template[0];
+	u8 pti_req_template[];
 } __packed; /* TDLS_CONFIG_CMD_API_S_VER_1 */
 
 /**
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/error-dump.h b/drivers/net/wireless/intel/iwlwifi/fw/error-dump.h
index 079fa0023bd8..c62576e442bd 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/error-dump.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/error-dump.h
@@ -84,7 +84,7 @@  struct iwl_fw_error_dump_data {
 struct iwl_fw_error_dump_file {
 	__le32 barker;
 	__le32 file_len;
-	u8 data[0];
+	u8 data[];
 } __packed;
 
 /**
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/file.h b/drivers/net/wireless/intel/iwlwifi/fw/file.h
index e4ebda64cd52..e336c254a2ee 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/file.h
+++ b/drivers/net/wireless/intel/iwlwifi/fw/file.h
@@ -119,7 +119,7 @@  enum iwl_ucode_tlv_type {
 struct iwl_ucode_tlv {
 	__le32 type;		/* see above */
 	__le32 length;		/* not including type/length fields */
-	u8 data[0];
+	u8 data[];
 };
 
 #define IWL_TLV_UCODE_MAGIC		0x0a4c5749
@@ -145,7 +145,7 @@  struct iwl_tlv_ucode_header {
 	 * Note that each TLV is padded to a length
 	 * that is a multiple of 4 for alignment.
 	 */
-	u8 data[0];
+	u8 data[];
 };
 
 /*
@@ -631,7 +631,7 @@  struct iwl_fw_dbg_dest_tlv_v1 {
 	__le32 wrap_count;
 	u8 base_shift;
 	u8 end_shift;
-	struct iwl_fw_dbg_reg_op reg_ops[0];
+	struct iwl_fw_dbg_reg_op reg_ops[];
 } __packed;
 
 /* Mask of the register for defining the LDBG MAC2SMEM buffer SMEM size */
@@ -651,14 +651,14 @@  struct iwl_fw_dbg_dest_tlv {
 	__le32 wrap_count;
 	u8 base_shift;
 	u8 size_shift;
-	struct iwl_fw_dbg_reg_op reg_ops[0];
+	struct iwl_fw_dbg_reg_op reg_ops[];
 } __packed;
 
 struct iwl_fw_dbg_conf_hcmd {
 	u8 id;
 	u8 reserved;
 	__le16 len;
-	u8 data[0];
+	u8 data[];
 } __packed;
 
 /**
@@ -733,7 +733,7 @@  struct iwl_fw_dbg_trigger_tlv {
 	u8 flags;
 	u8 reserved[5];
 
-	u8 data[0];
+	u8 data[];
 } __packed;
 
 #define FW_DBG_START_FROM_ALIVE	0