[PATCH net v2 4/4] ieee802154: mcr20a: fix 1-byte out-of-bounds read in mcr20a_handle_tx()
From: Hui Peng
Date: Mon Sep 21 2026 - 03:51:04 EST
In mcr20a_handle_tx(), the 1-byte psduLength prefix (lp->tx_len[0]) is
already sent in a separate SPI transfer (lp->tx_xfer_len), while
lp->tx_xfer_buf transfers the payload from lp->tx_skb->data. Setting
lp->tx_xfer_buf.len = lp->tx_skb->len + 1 causes the SPI transfer to read
1 byte past the end of lp->tx_skb->data:
BUG: KASAN: slab-out-of-bounds in mcr20a_handle_tx+0xf5/0x150
Read of size 17 at addr ffff8880057f7500 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+0x23/0x60
mcr20a_handle_tx+0xf5/0x150
...
The buggy address belongs to the object at ffff8880057f7500
which belongs to the cache kmalloc-16 of size 16
The buggy address is located 0 bytes inside of
allocated 16-byte region [ffff8880057f7500, ffff8880057f7510)
Set lp->tx_xfer_buf.len to lp->tx_skb->len.
Tested in QEMU with KASAN enabled by transferring a 16-byte tx_skb->data
buffer in mcr20a_handle_tx().
Fixes: 8c6ad9cc5157 ("ieee802154: Add NXP MCR20A IEEE 802.15.4 transceiver driver")
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@xxxxxxxxx>
---
Changes in v2:
- Split out as patch 4/4 covering only the mcr20a TX SPI transfer length
fix as requested by Miquel Raynal.
drivers/net/ieee802154/mcr20a.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c
index d01b277d33d2..d7e076397550 100644
--- a/drivers/net/ieee802154/mcr20a.c
+++ b/drivers/net/ieee802154/mcr20a.c
@@ -867,8 +867,7 @@ mcr20a_handle_tx(struct mcr20a_local *lp)
/* add 2 bytes of FCS */
lp->tx_len[0] = lp->tx_skb->len + 2;
lp->tx_xfer_buf.tx_buf = lp->tx_skb->data;
- /* add 1 byte psduLength */
- lp->tx_xfer_buf.len = lp->tx_skb->len + 1;
+ lp->tx_xfer_buf.len = lp->tx_skb->len;
ret = spi_async(lp->spi, &lp->tx_buf_msg);
if (ret) {
--
2.47.3