Linux wireless drivers development
 help / color / mirror / Atom feed
From: jeff.chen_1@oss.nxp.com
To: linux-wireless@vger.kernel.org
Cc: briannorris@chromium.org, johannes@sipsolutions.net,
	francesco@dolcini.it, Jeff Chen <jeff.chen_1@nxp.com>
Subject: [PATCH wireless-next v2 2/2] wifi: mwifiex: validate GET_HW_SPEC TLV lengths before parsing
Date: Mon, 12 Oct 2026 20:36:24 +0800	[thread overview]
Message-ID: <20261012123624.3147417-3-jeff.chen_1@oss.nxp.com> (raw)
In-Reply-To: <20261012123624.3147417-1-jeff.chen_1@oss.nxp.com>

From: Jeff Chen <jeff.chen_1@nxp.com>

Validate TLV lengths before accessing TLV payloads in
mwifiex_ret_get_hw_spec().

Signed-off-by: Jeff Chen <jeff.chen_1@nxp.com>
---
 drivers/net/wireless/marvell/mwifiex/cmdevt.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/cmdevt.c b/drivers/net/wireless/marvell/mwifiex/cmdevt.c
index 268a795db486..6e04d7da6217 100644
--- a/drivers/net/wireless/marvell/mwifiex/cmdevt.c
+++ b/drivers/net/wireless/marvell/mwifiex/cmdevt.c
@@ -1494,6 +1494,7 @@ int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
 	struct hw_spec_max_conn *max_conn;
 	u16 resp_size, api_id;
 	int i, left_len, parsed_len = 0;
+	int tlv_len;
 
 	adapter->fw_cap_info = le32_to_cpu(hw_spec->fw_cap_info);
 
@@ -1559,8 +1560,16 @@ int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
 		left_len = resp_size - sizeof(struct host_cmd_ds_get_hw_spec);
 		while (left_len > sizeof(struct mwifiex_ie_types_header)) {
 			tlv = (void *)&hw_spec->tlvs + parsed_len;
+			tlv_len = sizeof(*tlv) + le16_to_cpu(tlv->len);
+
+			if (tlv_len > left_len)
+				break;
+
 			switch (le16_to_cpu(tlv->type)) {
 			case TLV_TYPE_API_REV:
+				if (tlv_len < sizeof(struct hw_spec_api_rev))
+					break;
+
 				api_rev = (struct hw_spec_api_rev *)tlv;
 				api_id = le16_to_cpu(api_rev->api_id);
 				switch (api_id) {
@@ -1613,6 +1622,9 @@ int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
 				}
 				break;
 			case TLV_TYPE_MAX_CONN:
+				if (tlv_len < sizeof(struct hw_spec_max_conn))
+					break;
+
 				max_conn = (struct hw_spec_max_conn *)tlv;
 				adapter->max_p2p_conn = max_conn->max_p2p_conn;
 				adapter->max_sta_conn = max_conn->max_sta_conn;
-- 
2.34.1


      parent reply	other threads:[~2026-10-12 12:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12 12:36 [PATCH wireless-next v2 0/2] wifi: mwifiex: append hotfix number to firmware version string jeff.chen_1
2026-10-12 12:36 ` [PATCH wireless-next v2 1/2] " jeff.chen_1
2026-10-19 14:13   ` Francesco Dolcini
2026-10-19 14:16     ` Johannes Berg
2026-10-19 14:28       ` Francesco Dolcini
2026-10-19 14:49         ` Johannes Berg
2026-10-19 15:11           ` Francesco Dolcini
2026-10-12 12:36 ` jeff.chen_1 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261012123624.3147417-3-jeff.chen_1@oss.nxp.com \
    --to=jeff.chen_1@oss.nxp.com \
    --cc=briannorris@chromium.org \
    --cc=francesco@dolcini.it \
    --cc=jeff.chen_1@nxp.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox