[PATCH v2 1/2] wifi: mm81x: clamp command-response copy to the received skb length
From: guohongyu
Date: Fri Nov 20 2026 - 01:56:31 EST
mm81x_cmd_resp_process() copies a synchronous command response from
the received skb into the caller-provided buffer:
length = min_t(int, length,
le16_to_cpu(src_resp->hdr.len) +
sizeof(struct host_cmd_header));
memcpy(dest_resp, src_resp, length);
src_resp->hdr.len is the inner host_cmd_header length of the firmware
response. The skb, however, was sized by the *outer* mm81x_skb_hdr.len
(mm81x_yaps_read_pkt(), yaps.c:186-199: skb_len = sizeof(*hdr) +
hdr->offset + le16_to_cpu(hdr->len); skb_trim(skb, skb_len)), and
nothing ties the inner header length to the outer one. A buggy or
malicious firmware can therefore declare an inner hdr.len far larger
than the payload actually present, and the memcpy reads past the end of
the skb's data into adjacent heap memory, leaking it into the command
response buffer.
Clamp the copy to skb->len so we never read past the data actually
received.
Fixes: b1906cea00b0 ("wifi: mm81x: add mm81x Wi-Fi HaLow driver")
Signed-off-by: guohongyu <guohongyu@xxxxxxxxxxxxxxxxxxxx>
---
Hi Lachlan,
You are right, it is not. Both fixes only clamp lengths declared by
the firmware, so they are hardening within the firmware trust
boundary rather than fixes with real user impact, and the driver
first landed in v7.3, so the only backport target would be 7.3.x
itself. I have dropped the tag from both patches. No code changes
otherwise.
Changes in v2:
- Drop the Cc: stable tag. No code change.
drivers/net/wireless/morsemicro/mm81x/command.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/wireless/morsemicro/mm81x/command.c b/drivers/net/wireless/morsemicro/mm81x/command.c
index afb7ee9bb236..591e5ba10753 100644
--- a/drivers/net/wireless/morsemicro/mm81x/command.c
+++ b/drivers/net/wireless/morsemicro/mm81x/command.c
@@ -209,6 +209,7 @@ int mm81x_cmd_resp_process(struct mm81x *mors, struct sk_buff *skb)
length = min_t(int, length,
le16_to_cpu(src_resp->hdr.len) +
sizeof(struct host_cmd_header));
+ length = min_t(int, length, skb->len);
memcpy(dest_resp, src_resp, length);
} else {
ret = le32_to_cpu(src_resp->status);
--
2.43.0