From: Muhammad Bilal <meatuni001@gmail.com>
To: lachlan.hodges@morsemicro.com
Cc: dan.callaghan@morsemicro.com, arien.judge@morsemicro.com,
johannes@sipsolutions.net, ayman.grais@morsemicro.com,
andrew.pope@morsemicro.com, linux-wireless@vger.kernel.org,
linux-kernel@vger.kernel.org,
Muhammad Bilal <meatuni001@gmail.com>
Subject: [PATCH] wifi: mm81x: check bytes_remaining before reading delimiter
Date: Sun, 20 Sep 2026 00:22:31 +0500 [thread overview]
Message-ID: <20260919192231.272078-1-meatuni001@gmail.com> (raw)
mm81x_yaps_hw_read_pkts() reads a full 4-byte delimiter and then
subtracts sizeof(delim) from bytes_remaining on every loop iteration,
guarded only by "bytes_remaining > 0". If 1-3 bytes are left in the
window, this reads past the end of the valid data and then subtracts
4 from a value smaller than 4, driving bytes_remaining negative.
A negative bytes_remaining then reaches the total_len > bytes_remaining
branch, where "bytes_remaining" is passed to memcpy() as the copy
length. Implicitly converted to size_t, a negative int becomes a
huge value, turning that memcpy() into a massive out-of-bounds copy.
Bail out of the split loop once fewer than sizeof(delim) bytes remain,
the same way the existing "end of stream" check bails on a zero
delimiter.
Fixes: b1906cea00b0 ("wifi: mm81x: add mm81x Wi-Fi HaLow driver")
Signed-off-by: Muhammad Bilal <meatuni001@gmail.com>
---
drivers/net/wireless/morsemicro/mm81x/yaps_hw.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/wireless/morsemicro/mm81x/yaps_hw.c b/drivers/net/wireless/morsemicro/mm81x/yaps_hw.c
index 3d641d23c35b..e1102b8fb802 100644
--- a/drivers/net/wireless/morsemicro/mm81x/yaps_hw.c
+++ b/drivers/net/wireless/morsemicro/mm81x/yaps_hw.c
@@ -486,6 +486,9 @@ static int mm81x_yaps_hw_read_pkts(struct mm81x_yaps *yaps,
int total_len;
int pkt_size;
+ if (bytes_remaining < (int)sizeof(delim))
+ break;
+
delim = le32_to_cpu(*((__le32 *)read_ptr));
read_ptr += sizeof(delim);
bytes_remaining -= sizeof(delim);
--
2.55.0
reply other threads:[~2026-09-19 19:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260919192231.272078-1-meatuni001@gmail.com \
--to=meatuni001@gmail.com \
--cc=andrew.pope@morsemicro.com \
--cc=arien.judge@morsemicro.com \
--cc=ayman.grais@morsemicro.com \
--cc=dan.callaghan@morsemicro.com \
--cc=johannes@sipsolutions.net \
--cc=lachlan.hodges@morsemicro.com \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®