From: Hui Peng <benquike@gmail.com>
To: alex.aring@gmail.com, stefan@datenfreihafen.org,
miquel.raynal@bootlin.com, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com
Cc: linux-wpan@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] ieee802154: ca8210: fix SPI RX length validation and FIFO out-of-bounds read
Date: Sat, 19 Sep 2026 22:34:35 +0000 [thread overview]
Message-ID: <20260919223435.3883048-1-benquike@gmail.com> (raw)
In drivers/net/ieee802154/ca8210.c, validate MAC command/data frame
lengths received over SPI before copying payload bytes or indexing MAC
header fields.
Fixes: ded845a781a5 ("ieee802154: Add CA8210 IEEE 802.15.4 device driver")
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
index 01af4f9cf7f2..d3205275741a 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)
@@ -1677,6 +1678,9 @@ static u8 hwme_get_request_sync(
return IEEE802154_SYSTEM_ERROR;
if (response.pdata.hwme_get_cnf.status == IEEE802154_SUCCESS) {
+ if (response.pdata.hwme_get_cnf.hw_attribute_length >
+ sizeof(response.pdata.hwme_get_cnf.hw_attribute_value))
+ return IEEE802154_SYSTEM_ERROR;
*hw_attribute_length =
response.pdata.hwme_get_cnf.hw_attribute_length;
memcpy(
@@ -1755,13 +1759,17 @@ static int ca8210_skb_rx(
u8 *data_ind
)
{
- struct ieee802154_hdr hdr;
+ struct ieee802154_hdr hdr = { };
int msdulen;
int hlen;
- u8 mpdulinkquality = data_ind[23];
+ u8 mpdulinkquality;
struct sk_buff *skb;
struct ca8210_priv *priv = hw->priv;
+ if (len < 30)
+ return -EINVAL;
+ mpdulinkquality = data_ind[23];
+
/* Allocate mtu size buffer for every rx packet */
skb = dev_alloc_skb(IEEE802154_MTU + sizeof(hdr));
if (!skb)
@@ -1770,7 +1778,7 @@ static int ca8210_skb_rx(
skb_reserve(skb, sizeof(hdr));
msdulen = data_ind[22]; /* msdu_length */
- if (msdulen > IEEE802154_MTU) {
+ if (msdulen > IEEE802154_MTU || len < 30 + msdulen) {
dev_err(
&priv->spi->dev,
"received erroneously large msdu length!\n"
@@ -1787,6 +1795,10 @@ static int ca8210_skb_rx(
hdr.sec.level = data_ind[29 + msdulen];
dev_dbg(&priv->spi->dev, "security level: %#03x\n", hdr.sec.level);
if (hdr.sec.level > 0) {
+ if (len < 40 + msdulen) {
+ kfree_skb(skb);
+ return -EINVAL;
+ }
hdr.sec.key_id_mode = data_ind[30 + msdulen];
memcpy(&hdr.sec.extended_src, &data_ind[31 + msdulen], 8);
hdr.sec.key_id = data_ind[39 + msdulen];
@@ -1801,6 +1813,7 @@ static int ca8210_skb_rx(
hdr.dest.pan_id = cpu_to_le16(get_unaligned_le16(&data_ind[12]));
dev_dbg(&priv->spi->dev, "dstPanId: %#06x\n", hdr.dest.pan_id);
memcpy(&hdr.dest.extended_addr, &data_ind[14], 8);
+ hdr.seq = data_ind[24];
/* Fill in FC implicitly */
hdr.fc.type = 1; /* Data frame */
@@ -2028,11 +2041,14 @@ static int ca8210_xmit_async(struct ieee802154_hw *hw, struct sk_buff *skb)
static int ca8210_get_ed(struct ieee802154_hw *hw, u8 *level)
{
u8 lenvar;
+ u8 buf[sizeof(((struct hwme_get_confirm_pset *)0)->hw_attribute_value)] = { 0 };
+ u8 status;
struct ca8210_priv *priv = hw->priv;
- return link_to_linux_err(
- hwme_get_request_sync(HWME_EDVALUE, &lenvar, level, priv->spi)
- );
+ status = hwme_get_request_sync(HWME_EDVALUE, &lenvar, buf, priv->spi);
+ if (status == IEEE802154_SUCCESS)
+ *level = buf[0];
+ return link_to_linux_err(status);
}
/**
next reply other threads:[~2026-09-19 22:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 22:34 Hui Peng [this message]
2026-09-20 13:00 ` Miquel Raynal
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=20260919223435.3883048-1-benquike@gmail.com \
--to=benquike@gmail.com \
--cc=alex.aring@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--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®