From: David Laight <david.laight.linux@gmail.com>
To: Hui Peng <benquike@gmail.com>
Cc: Harry Morris <h.morris@cascoda.com>,
Alexander Aring <alex.aring@gmail.com>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Stefan Schmidt <stefan@datenfreihafen.org>,
linux-wpan@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH net v2 1/3] ieee802154: ca8210: prevent stack buffer overflow in ca8210_rx_done()
Date: Mon, 21 Sep 2026 10:08:59 +0100 [thread overview]
Message-ID: <20260921100859.3869db3d@pumpkin> (raw)
In-Reply-To: <20260921074205.2289211-1-benquike@gmail.com>
On Mon, 21 Sep 2026 07:42:03 +0000
Hui Peng <benquike@gmail.com> wrote:
> In ca8210_rx_done(), the packet length len = buf[1] + 2 is only checked
> against CA8210_SPI_BUF_SIZE (256). When buf[0] & SPI_SYN is set and
> priv->sync_command_response is non-NULL, memcpy() copies up to 256 bytes
> into priv->sync_command_response, which points to a struct mac_message
> object (sizeof(struct mac_message) = 250 bytes) on the synchronous
> caller's stack, overflowing the stack buffer by up to 6 bytes:
>
> BUG: KASAN: stack-out-of-bounds in ca8210_rx_done+0xc4/0xe0
> Write of size 256 at addr ffff888001907660 by task init/1
> Call Trace:
> <TASK>
> dump_stack_lvl+0x70/0xa0
> print_report+0x153/0x4c6
> kasan_report+0xf1/0x120
> kasan_check_range+0x125/0x200
> __asan_memcpy+0x3c/0x60
> ca8210_rx_done+0xc4/0xe0
> ca8210_spi_exchange+0x12e/0x190
> ...
> The buggy address belongs to stack of task init/1
> and is located at offset 32 in frame:
> ca8210_spi_exchange+0x0/0x190
> This frame has 1 object:
> [32, 282) 'response'
>
> Bound the synchronous response memcpy() length to
> min_t(size_t, len, sizeof(struct mac_message)).
Why min_t() ?
len is unsigned so min() is fine.
Shouldn't there also be some kind of indication the data was truncated?
David
>
> Tested in QEMU with KASAN enabled by passing a 256-byte SPI_SYN response
> into ca8210_rx_done().
>
> Fixes: ded845a781a5 ("ieee802154: Add CA8210 IEEE 802.15.4 device driver")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Hui Peng <benquike@gmail.com>
> ---
> Changes in v2:
> - Split the ca8210 fixes into three single-issue patches (1/3..3/3).
>
> drivers/net/ieee802154/ca8210.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
> index 01af4f9..c009930 100644
> --- a/drivers/net/ieee802154/ca8210.c
> +++ b/drivers/net/ieee802154/ca8210.c
> @@ -697,7 +697,8 @@ static void ca8210_rx_done(struct cas_control *cas_ctl)
>
> if (buf[0] & SPI_SYN) {
> if (priv->sync_command_response) {
> - memcpy(priv->sync_command_response, buf, len);
> + memcpy(priv->sync_command_response, buf,
> + min_t(size_t, len, sizeof(struct mac_message)));
> complete(&priv->sync_exchange_complete);
> } else {
> if (cascoda_api_upstream)
next prev parent reply other threads:[~2026-09-21 9:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260919213637.3316595-1-benquike@gmail.com>
2026-09-21 7:42 ` Hui Peng
2026-09-21 9:08 ` David Laight [this message]
2026-09-22 8:32 ` netdev-bot+sashiko
2026-09-21 7:42 ` [PATCH net v2 2/3] ieee802154: ca8210: prevent stack buffer overflow in hwme_get_request_sync() Hui Peng
2026-09-22 8:32 ` netdev-bot+sashiko
2026-09-21 7:42 ` [PATCH net v2 3/3] ieee802154: ca8210: validate data_ind length upfront in ca8210_skb_rx() Hui Peng
2026-09-22 8:32 ` netdev-bot+sashiko
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=20260921100859.3869db3d@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=alex.aring@gmail.com \
--cc=benquike@gmail.com \
--cc=h.morris@cascoda.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=stefan@datenfreihafen.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®