[PATCH 1/2] wifi: mm81x: clamp command-response copy to the received skb length
From: guohongyu
Date: Mon Nov 16 2026 - 22:29:59 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")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: guohongyu <guohongyu@xxxxxxxxxxxxxxxxxxxx>
---
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