From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FF82541449; Thu, 17 Sep 2026 17:08:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789664928; cv=none; b=jDIJl1UUDj2HtYzQ1CxeG67dl9UtARqc3unRNBkM2Vx/DN/9Qy1h75PRyioWnXWwF+3VQS1OaHbImXYMQWK+AvWelbaDILqh5Yxg1Mty63c/JaBpRuOdwXe2BDFm2/chcyvVWH5hKcvF360EH8LXCLnalvuQvXcxgu+g0v+3l9U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789664928; c=relaxed/simple; bh=BsgU8n2DAlZ/ra4K4HX6sWIb202qGtWYm7eadKWGnro=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l6V2CpWW8+IrZ/UasTxgeUSBJceZ0Vcd5h4VxQWTa+0iE18vk7IcKST5uHxc9ysO/M7xtYc7emmskH1RcFX/RBgmxF3hRogjvgqBwwRSNEsPYFwc/rdG20g/+sSRUI1pLFSnpHrNLuYlaY4sxxnF0TREymK5byVCMjNZxjgsYp4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=jOahVTjN; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="jOahVTjN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC9541F000FF; Thu, 17 Sep 2026 17:08:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789664927; bh=5kgQAoFnVZPMMdSfzgvF5Gr3aZLRUGtl65Y5b8mMtW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jOahVTjNdJDTG9XzojcW7gLphDiWSxV3Rko3a8/I5UlIXfsi4jikLjcGWvScmk834 /EGeNu89Aq+cXrUSJZWhnA50h1bXEXOJvoXzajZmc7sL2Gb9an4BdAY1/AkYBmQENt tmCCUhZq5WDtSYDmJoWd9H2lGjUA2aW2IA7rgTwQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Emmanuel Grumbach , Miri Korenblit , Sasha Levin Subject: [PATCH 6.18 0535/1250] wifi: iwlwifi: bound aligned TLV advance in FW parser Date: Thu, 17 Sep 2026 16:05:30 +0100 Message-ID: <20260917151606.438300264@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151551.901433442@linuxfoundation.org> References: <20260917151551.901433442@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Emmanuel Grumbach [ Upstream commit acad742714bdc70e7fd7f234323807c596828213 ] Validate ALIGN(tlv_len, 4) against remaining parser length before consuming bytes from the firmware image. This avoids length underflow on malformed TLVs. Assisted-by: GitHubCopilot:GPT-5.3-Codex Signed-off-by: Emmanuel Grumbach Link: https://patch.msgid.link/20260717173215.393c286488f9.Ia39144dc3ca334325ee4eacb7420901e2446fc23@changeid Signed-off-by: Miri Korenblit Signed-off-by: Sasha Levin --- drivers/net/wireless/intel/iwlwifi/iwl-drv.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c index 0f002ef261fcc..3a4bcfd60905c 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c @@ -803,6 +803,7 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv, u32 build, paging_mem_size; int num_of_cpus; bool usniffer_req = false; + size_t aligned_tlv_len; if (len < sizeof(*ucode)) { IWL_ERR(drv, "uCode has invalid length: %zd\n", len); @@ -851,8 +852,16 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv, len, tlv_len); return -EINVAL; } - len -= ALIGN(tlv_len, 4); - data += sizeof(*tlv) + ALIGN(tlv_len, 4); + + aligned_tlv_len = ALIGN(tlv_len, 4); + if (len < aligned_tlv_len) { + IWL_ERR(drv, "invalid aligned TLV len: %zd/%zu\n", + len, aligned_tlv_len); + return -EINVAL; + } + + len -= aligned_tlv_len; + data += sizeof(*tlv) + aligned_tlv_len; switch (tlv_type) { case IWL_UCODE_TLV_INST: -- 2.53.0