]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: iwlwifi: validate payload length in iwl_pnvm_complete_fn
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Wed, 15 Jul 2026 18:57:07 +0000 (21:57 +0300)
committerMiri Korenblit <miriam.rachel.korenblit@intel.com>
Thu, 16 Jul 2026 18:12:18 +0000 (21:12 +0300)
iwl_pnvm_complete_fn() casts pkt->data directly to
struct iwl_pnvm_init_complete_ntfy and reads the status field
without first verifying that the firmware notification payload
is large enough to contain that structure.

Add a WARN_ON_ONCE check against sizeof(*pnvm_ntf) and return
early without reading uninitialised memory if the payload is too
short.

Fixes: b3e4c0f34c17 ("iwlwifi: move PNVM implementation to common code")
Assisted-by: GitHubCopilot:gpt-5.3-codex
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20260715215523.7f2a669e5c75.I00465dcfcbccb250ae9af2d9bb305e24de1ba394@changeid
drivers/net/wireless/intel/iwlwifi/fw/pnvm.c

index afff8d51ca950c4d05627afb05aab0d61853b865..ec0ff58ab312d5ac53066efc01078603fd0573b1 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright(c) 2020-2025 Intel Corporation
+ * Copyright(c) 2020-2026 Intel Corporation
  */
 
 #include "iwl-drv.h"
@@ -12,6 +12,7 @@
 #include "fw/api/alive.h"
 #include "fw/uefi.h"
 #include "fw/img.h"
+#include "fw/dbg.h"
 
 #define IWL_PNVM_REDUCED_CAP_BIT BIT(25)
 
@@ -26,6 +27,12 @@ static bool iwl_pnvm_complete_fn(struct iwl_notif_wait_data *notif_wait,
        struct iwl_trans *trans = (struct iwl_trans *)data;
        struct iwl_pnvm_init_complete_ntfy *pnvm_ntf = (void *)pkt->data;
 
+       if (IWL_FW_CHECK(trans,
+                        iwl_rx_packet_payload_len(pkt) < sizeof(*pnvm_ntf),
+                        "Bad notif len: %d\n",
+                        iwl_rx_packet_payload_len(pkt)))
+               return true;
+
        IWL_DEBUG_FW(trans,
                     "PNVM complete notification received with status 0x%0x\n",
                     le32_to_cpu(pnvm_ntf->status));