wifi: iwlwifi: mei: check SAP message length before reading it

Verify the SAP message size is not larger than the local buffer before
reading the message to avoid buffer overflow.

Fixes: bcd68b3dbe ("wifi: iwlwifi: mei: fix tx DHCP packet for devices with new Tx API")
Signed-off-by: Avraham Stern <avraham.stern@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20260715220243.f0026ce26218.I00a856d3aacae1caac605c708f7362689b734234@changeid
This commit is contained in:
Avraham Stern 2026-07-15 22:04:27 +03:00 committed by Miri Korenblit
parent c5aeb11489
commit 7d8cc301bc

View File

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2021-2024 Intel Corporation
* Copyright (C) 2026 Intel Corporation
*/
#include <linux/etherdevice.h>
@ -1147,6 +1148,11 @@ static void iwl_mei_handle_sap_rx_cmd(struct mei_cl_device *cldev,
iwl_mei_read_from_q(q_head, q_sz, &rd, wr, hdr, sizeof(*hdr));
valid_rx_sz -= sizeof(*hdr);
len = le16_to_cpu(hdr->len);
if (len + sizeof(*hdr) > PAGE_SIZE) {
dev_err(&cldev->dev,
"SAP message is too big: %u\n", len);
break;
}
if (valid_rx_sz < len)
break;