* [PATCH wireless] wifi: mm81x: validate YAPS receive framing
@ 2026-09-10 20:10 Felix Hoffmann
2026-10-07 3:15 ` Lachlan Hodges
0 siblings, 1 reply; 3+ messages in thread
From: Felix Hoffmann @ 2026-09-10 20:10 UTC (permalink / raw)
To: linux-wireless
Cc: Lachlan Hodges, Dan Callaghan, Arien Judge, Johannes Berg, linux-kernel
The receive byte count comes from device-controlled status registers, but
the packet splitter unconditionally consumes a four-byte delimiter. A count
of one to three bytes therefore makes bytes_remaining negative. If the
reused receive buffer contains a valid delimiter, the negative value is
passed to memcpy() and converted to a near-SIZE_MAX length, corrupting
kernel memory.
YAPS streams are word aligned, so reject byte counts that cannot contain
complete delimiters. Also reject delimiter sizes which do not leave any
packet data after removing the reserved metadata page.
Fixes: b1906cea00b0 ("wifi: mm81x: add mm81x Wi-Fi HaLow driver")
Assisted-by: Codex:gpt-5
Signed-off-by: Felix Hoffmann <f3lix.dev@gmx.de>
---
drivers/net/wireless/morsemicro/mm81x/yaps_hw.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/morsemicro/mm81x/yaps_hw.c b/drivers/net/wireless/morsemicro/mm81x/yaps_hw.c
index 3d641d23c35b..97b2ff93c69f 100644
--- a/drivers/net/wireless/morsemicro/mm81x/yaps_hw.c
+++ b/drivers/net/wireless/morsemicro/mm81x/yaps_hw.c
@@ -407,7 +407,7 @@ static bool mm81x_read_pkts_h_is_valid_delim(u32 delim)
if (calc_crc != YAPS_DELIM_GET_CRC(delim))
return false;
- if (pkt_size == 0)
+ if (pkt_size <= YAPS_RESERVED_PAGE_SIZE)
return false;
if ((pkt_size + padding) > YAPS_MAX_PKT_SIZE_BYTES)
@@ -455,6 +455,10 @@ static int mm81x_yaps_hw_read_pkts(struct mm81x_yaps *yaps,
return 0;
if (bytes_remaining < 0)
return bytes_remaining;
+ if (!IS_ALIGNED(bytes_remaining, sizeof(u32))) {
+ dev_warn(yaps->mors->dev, "yaps truncated delimiter");
+ return -EIO;
+ }
if (bytes_remaining > YAPS_HW_WINDOW_SIZE_BYTES) {
bytes_remaining = YAPS_HW_WINDOW_SIZE_BYTES;
--
2.43.0
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH wireless] wifi: mm81x: validate YAPS receive framing
2026-09-10 20:10 [PATCH wireless] wifi: mm81x: validate YAPS receive framing Felix Hoffmann
@ 2026-10-07 3:15 ` Lachlan Hodges
2026-10-07 9:30 ` Felix Hoffmann
0 siblings, 1 reply; 3+ messages in thread
From: Lachlan Hodges @ 2026-10-07 3:15 UTC (permalink / raw)
To: Felix Hoffmann
Cc: linux-wireless, Dan Callaghan, Arien Judge, Johannes Berg, linux-kernel
> - if (pkt_size == 0)
> + if (pkt_size <= YAPS_RESERVED_PAGE_SIZE)
> return false;
Can we not use YAPS_DELIM_GET_PKT_SIZE instead which already accounts
for delimiter length so it's a bit easier to read?
lachlan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH wireless] wifi: mm81x: validate YAPS receive framing
2026-10-07 3:15 ` Lachlan Hodges
@ 2026-10-07 9:30 ` Felix Hoffmann
0 siblings, 0 replies; 3+ messages in thread
From: Felix Hoffmann @ 2026-10-07 9:30 UTC (permalink / raw)
To: Lachlan Hodges
Cc: linux-wireless, Dan Callaghan, Arien Judge, Johannes Berg, linux-kernel
Hi Lachlan,
Thank you for the review.
Yes, YAPS_DELIM_GET_PKT_SIZE() makes the intent clearer. I have changed v2
to use it through the signed pkt_size local, so encoded sizes below the
reserved page remain negative and are rejected. The upper-bound check adds
YAPS_RESERVED_PAGE_SIZE back to preserve its existing encoded-size semantics.
I will send v2 as a separate thread.
Thanks,
Felix
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-07 9:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-10 20:10 [PATCH wireless] wifi: mm81x: validate YAPS receive framing Felix Hoffmann
2026-10-07 3:15 ` Lachlan Hodges
2026-10-07 9:30 ` Felix Hoffmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®