]> git.ipfire.org Git - people/ms/linux.git/commitdiff
iwlwifi: dbg_ini: Split memcpy() to avoid multi-field write
authorKees Cook <keescook@chromium.org>
Tue, 27 Jul 2021 20:58:54 +0000 (13:58 -0700)
committerLuca Coelho <luciano.coelho@intel.com>
Fri, 18 Feb 2022 08:40:56 +0000 (10:40 +0200)
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>
drivers/net/wireless/intel/iwlwifi/fw/file.h
drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c

index f44aedb3f04904d4abe354484846544b98f66107..fa2a73ae418320fb96fc471225a31cae240a3e54 100644 (file)
@@ -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
index bf167bdd02cd60e3165bf3484251bdccc5e58f0d..866a33f49915f16b7a4f32187ba654e03b33fb26 100644 (file)
@@ -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;