Skip to content

Commit

Permalink
iwlwifi: dbg_ini: Split memcpy() to avoid multi-field write
Browse files Browse the repository at this point in the history
To avoid a run-time false positive in the stricter FORTIFY_SOURCE
memcpy() checks, split the memcpy() into the struct and the data.
Additionally switch the data member to a flexible array to follow
modern language conventions.

Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20210727205855.411487-64-keescook@chromium.org
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
  • Loading branch information
Kees Cook authored and Luca Coelho committed Feb 18, 2022
1 parent 583d183 commit cb0a1fb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/net/wireless/intel/iwlwifi/fw/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ static int iwl_dbg_tlv_add(const struct iwl_ucode_tlv *tlv,
if (!node)
return -ENOMEM;

memcpy(&node->tlv, tlv, sizeof(node->tlv) + len);
memcpy(&node->tlv, tlv, sizeof(node->tlv));
memcpy(node->tlv.data, tlv->data, len);
list_add_tail(&node->list, list);

return 0;
Expand Down

0 comments on commit cb0a1fb

Please sign in to comment.