* [PATCH net v2 1/4] ieee802154: cc2520: ensure tailroom before skb_put() in promiscuous TX
[not found] <20260919213639.3316625-1-benquike@gmail.com>
@ 2026-09-21 7:42 ` Hui Peng
2026-09-21 7:42 ` [PATCH net v2 2/4] ieee802154: cc2520: flush fifop_irqwork before destroying buffer_mutex in probe Hui Peng
` (2 subsequent siblings)
3 siblings, 0 replies; 4+ messages in thread
From: Hui Peng @ 2026-09-21 7:42 UTC (permalink / raw)
To: Alexander Aring, Miquel Raynal, Stefan Schmidt
Cc: linux-wpan, netdev, linux-kernel, Hui Peng, stable
In cc2520_tx(), when priv->promiscuous is enabled, skb_put(skb, 2) is
called unconditionally to append the 2-byte software CRC without checking
whether the skb has at least 2 bytes of tailroom, triggering
skb_over_panic when skb_tailroom(skb) < 2:
skbuff: skb_over_panic: text:ffffffffc080071a len:386 put:2
kernel BUG at net/core/skbuff.c:214!
Oops: invalid opcode: 0000 [#1] SMP KASAN PTI
RIP: 0010:skb_panic+0x170/0x172
Call Trace:
<TASK>
skb_put.cold+0x23/0x23
cc2520_tx.constprop.0.isra.0+0x8a/0x1d0
Ensure at least 2 bytes of tailroom via pskb_expand_head() before calling
skb_put(skb, 2).
Tested in QEMU with KASAN enabled by passing a zero-tailroom skb to
cc2520_tx() with promiscuous mode enabled.
Fixes: 59869ebfe7a7 ("ieee802154: cc2520: Check CRC & add promiscuous")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
Changes in v2:
- Split the cc2520 and mcr20a fixes into four single-issue patches
(1/4..4/4) and documented each change in its own commit message as
requested by Miquel Raynal.
drivers/net/ieee802154/cc2520.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ieee802154/cc2520.c b/drivers/net/ieee802154/cc2520.c
index abfcfe0..5454872 100644
--- a/drivers/net/ieee802154/cc2520.c
+++ b/drivers/net/ieee802154/cc2520.c
@@ -482,8 +482,14 @@ cc2520_tx(struct ieee802154_hw *hw, struct sk_buff *skb)
* values on RX. This means we need to manually add the CRC on TX.
*/
if (priv->promiscuous) {
- u16 crc = crc_ccitt(0, skb->data, skb->len);
+ u16 crc;
+ if (skb_tailroom(skb) < 2 &&
+ pskb_expand_head(skb, 0, 2, GFP_KERNEL)) {
+ rc = -ENOMEM;
+ goto err_tx;
+ }
+ crc = crc_ccitt(0, skb->data, skb->len);
put_unaligned_le16(crc, skb_put(skb, 2));
pkt_len = skb->len;
} else {
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net v2 2/4] ieee802154: cc2520: flush fifop_irqwork before destroying buffer_mutex in probe
[not found] <20260919213639.3316625-1-benquike@gmail.com>
2026-09-21 7:42 ` [PATCH net v2 1/4] ieee802154: cc2520: ensure tailroom before skb_put() in promiscuous TX Hui Peng
@ 2026-09-21 7:42 ` Hui Peng
2026-09-21 7:42 ` [PATCH net v2 3/4] ieee802154: mcr20a: drop corrupted RX frames instead of reading 125 stale bytes Hui Peng
2026-09-21 7:42 ` [PATCH net v2 4/4] ieee802154: mcr20a: fix 1-byte out-of-bounds read in mcr20a_handle_tx() Hui Peng
3 siblings, 0 replies; 4+ messages in thread
From: Hui Peng @ 2026-09-21 7:42 UTC (permalink / raw)
To: Alexander Aring, Miquel Raynal, Stefan Schmidt
Cc: linux-wpan, netdev, linux-kernel, Hui Peng, stable
In cc2520_probe()'s err_hw_init path, mutex_destroy(&priv->buffer_mutex)
is called before flush_work(&priv->fifop_irqwork). If fifop_irq fires
after devm_request_irq() and schedules priv->fifop_irqwork before probe
fails, cc2520_fifop_irqwork() can lock priv->buffer_mutex after it has
already been destroyed:
BUG: KASAN: slab-use-after-free in assign_work+0x2f1/0x340
Read of size 8 at addr ffff88800246b0b0 by task kworker/1:1/43
Workqueue: 0x0 (events)
Call Trace:
<TASK>
dump_stack_lvl+0x70/0xa0
print_report+0x153/0x4c6
kasan_report+0xf1/0x120
assign_work+0x2f1/0x340
worker_thread+0x2b8/0xb70
Flush priv->fifop_irqwork before mutex_destroy(&priv->buffer_mutex),
matching the teardown order in cc2520_remove().
Tested in QEMU with KASAN enabled by scheduling fifop_irqwork on the
cc2520_probe() error path.
Fixes: ff5891b266a7 ("ieee802154: cc2520: fix FIFOP work use-after-free")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
Changes in v2:
- Split out as patch 2/4 and documented the probe cleanup ordering fix and
Fixes: tag as requested by Miquel Raynal.
drivers/net/ieee802154/cc2520.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ieee802154/cc2520.c b/drivers/net/ieee802154/cc2520.c
index 5454872..d2c8484 100644
--- a/drivers/net/ieee802154/cc2520.c
+++ b/drivers/net/ieee802154/cc2520.c
@@ -1153,8 +1153,8 @@ static int cc2520_probe(struct spi_device *spi)
return 0;
err_hw_init:
- mutex_destroy(&priv->buffer_mutex);
flush_work(&priv->fifop_irqwork);
+ mutex_destroy(&priv->buffer_mutex);
return ret;
}
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net v2 3/4] ieee802154: mcr20a: drop corrupted RX frames instead of reading 125 stale bytes
[not found] <20260919213639.3316625-1-benquike@gmail.com>
2026-09-21 7:42 ` [PATCH net v2 1/4] ieee802154: cc2520: ensure tailroom before skb_put() in promiscuous TX Hui Peng
2026-09-21 7:42 ` [PATCH net v2 2/4] ieee802154: cc2520: flush fifop_irqwork before destroying buffer_mutex in probe Hui Peng
@ 2026-09-21 7:42 ` Hui Peng
2026-09-21 7:42 ` [PATCH net v2 4/4] ieee802154: mcr20a: fix 1-byte out-of-bounds read in mcr20a_handle_tx() Hui Peng
3 siblings, 0 replies; 4+ messages in thread
From: Hui Peng @ 2026-09-21 7:42 UTC (permalink / raw)
To: Alexander Aring, Miquel Raynal, Stefan Schmidt
Cc: linux-wpan, netdev, linux-kernel, Hui Peng, stable
In mcr20a_handle_rx_read_buf_complete(), when
!ieee802154_is_valid_psdu_len(len) is true, the driver overwrites len
with IEEE802154_MTU (127) and copies 125 bytes from lp->rx_buf into a new
skb even though only the original len bytes were transferred over SPI,
reading past the valid RX data and leaking up to 125 bytes of stale heap
memory to the network stack:
BUG: KASAN: slab-out-of-bounds in mcr20a_handle_rx_read_buf_complete.constprop.0+0x91/0xc0
Read of size 125 at addr ffff888002853f40 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_rx_read_buf_complete.constprop.0+0x91/0xc0
...
The buggy address belongs to the object at ffff888002853f40
which belongs to the cache kmalloc-8 of size 8
The buggy address is located 0 bytes inside of
allocated 4-byte region [ffff888002853f40, ffff888002853f44)
Drop the corrupted frame, re-arm reception via mcr20a_request_rx(lp), and
return early.
Tested in QEMU with KASAN enabled by passing a corrupted 4-byte RX frame
length to mcr20a_handle_rx_read_buf_complete().
Fixes: 8c6ad9cc5157 ("ieee802154: Add NXP MCR20A IEEE 802.15.4 transceiver driver")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
Changes in v2:
- Split out as patch 3/4 covering only the mcr20a RX corrupted frame
handling as requested by Miquel Raynal.
drivers/net/ieee802154/mcr20a.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c
index 020d392a98b6..d01b277d33d2 100644
--- a/drivers/net/ieee802154/mcr20a.c
+++ b/drivers/net/ieee802154/mcr20a.c
@@ -790,7 +790,8 @@ mcr20a_handle_rx_read_buf_complete(void *context)
if (!ieee802154_is_valid_psdu_len(len)) {
dev_vdbg(&lp->spi->dev, "corrupted frame received\n");
- len = IEEE802154_MTU;
+ mcr20a_request_rx(lp);
+ return;
}
len = len - 2; /* get rid of frame check field */
--
2.47.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH net v2 4/4] ieee802154: mcr20a: fix 1-byte out-of-bounds read in mcr20a_handle_tx()
[not found] <20260919213639.3316625-1-benquike@gmail.com>
` (2 preceding siblings ...)
2026-09-21 7:42 ` [PATCH net v2 3/4] ieee802154: mcr20a: drop corrupted RX frames instead of reading 125 stale bytes Hui Peng
@ 2026-09-21 7:42 ` Hui Peng
3 siblings, 0 replies; 4+ messages in thread
From: Hui Peng @ 2026-09-21 7:42 UTC (permalink / raw)
To: Alexander Aring, Miquel Raynal, Stefan Schmidt
Cc: linux-wpan, netdev, linux-kernel, Hui Peng, stable
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@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-21 7:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20260919213639.3316625-1-benquike@gmail.com>
2026-09-21 7:42 ` [PATCH net v2 1/4] ieee802154: cc2520: ensure tailroom before skb_put() in promiscuous TX Hui Peng
2026-09-21 7:42 ` [PATCH net v2 2/4] ieee802154: cc2520: flush fifop_irqwork before destroying buffer_mutex in probe Hui Peng
2026-09-21 7:42 ` [PATCH net v2 3/4] ieee802154: mcr20a: drop corrupted RX frames instead of reading 125 stale bytes Hui Peng
2026-09-21 7:42 ` [PATCH net v2 4/4] ieee802154: mcr20a: fix 1-byte out-of-bounds read in mcr20a_handle_tx() Hui Peng
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®