* [PATCH wpan v2] ieee802154: ca8210: fix pointer truncation in kfifo on 64-bit
@ 2026-05-20 5:07 Shitalkumar Gandhi
2026-05-20 8:11 ` Miquel Raynal
0 siblings, 1 reply; 2+ messages in thread
From: Shitalkumar Gandhi @ 2026-05-20 5:07 UTC (permalink / raw)
To: Miquel Raynal, Alexander Aring, Stefan Schmidt
Cc: Simon Horman, Andrew Lunn, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, linux-wpan, netdev, linux-kernel,
stable, Shitalkumar Gandhi
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 2588 bytes --]
ca8210_test_int_driver_write() and ca8210_test_int_user_read() exchange
a kmalloc'd buffer pointer through a struct kfifo, but pass a literal
'4' as the byte count to kfifo_in()/kfifo_out().
This is correct on 32-bit (pointer = 4 bytes), but on 64-bit only the
low 4 bytes of the 8-byte pointer are written into the FIFO. The reader
then reads back 4 bytes into an 8-byte local pointer variable, leaving
the upper 4 bytes uninitialized stack data. The first dereference of
the reconstructed pointer (fifo_buffer[1]) accesses an arbitrary kernel
address and generally results in an oops.
Use sizeof(fifo_buffer) so the byte count matches pointer width on every
architecture.
The driver has no architecture restriction in Kconfig, so any 64-bit
build with CONFIG_IEEE802154_CA8210_DEBUGFS=y is exposed. Issue has
been latent since the driver was added in 2017 because it is most
commonly deployed on 32-bit MCUs.
Found via a custom Coccinelle semantic patch hunting for short-byte
kfifo I/O on byte-mode kfifos used to shuttle pointers.
Fixes: ded845a781a5 ("ieee802154: Add CA8210 IEEE 802.15.4 device driver")
Cc: stable@vger.kernel.org
Signed-off-by: Shitalkumar Gandhi <shitalkumar.gandhi@cambiumnetworks.com>
Reviewed-by: Simon Horman <horms@kernel.org>
---
Changes in v2:
- Use intermediate variable for kfifo_out() return value (Miquèl)
- Add Cc: stable@vger.kernel.org (Miquèl)
- Add Reviewed-by from Simon Horman (v1)
Link to v1: https://lore.kernel.org/linux-wpan/20260513153412.1284549-1-shitalkumar.gandhi@cambiumnetworks.com/
drivers/net/ieee802154/ca8210.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
index 753215ebc67c..828cee8a6101 100644
--- a/drivers/net/ieee802154/ca8210.c
+++ b/drivers/net/ieee802154/ca8210.c
@@ -597,7 +597,7 @@ static int ca8210_test_int_driver_write(
fifo_buffer = kmemdup(buf, len, GFP_KERNEL);
if (!fifo_buffer)
return -ENOMEM;
- kfifo_in(&test->up_fifo, &fifo_buffer, 4);
+ kfifo_in(&test->up_fifo, &fifo_buffer, sizeof(fifo_buffer));
wake_up_interruptible(&priv->test.readq);
return 0;
@@ -2540,8 +2540,10 @@ static ssize_t ca8210_test_int_user_read(
!kfifo_is_empty(&priv->test.up_fifo)
);
}
+ unsigned int copied;
- if (kfifo_out(&priv->test.up_fifo, &fifo_buffer, 4) != 4) {
+ copied = kfifo_out(&priv->test.up_fifo, &fifo_buffer, sizeof(fifo_buffer));
+ if (copied != sizeof(fifo_buffer)) {
dev_err(
&priv->spi->dev,
"test_interface: Wrong number of elements popped from upstream fifo\n"
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH wpan v2] ieee802154: ca8210: fix pointer truncation in kfifo on 64-bit
2026-05-20 5:07 [PATCH wpan v2] ieee802154: ca8210: fix pointer truncation in kfifo on 64-bit Shitalkumar Gandhi
@ 2026-05-20 8:11 ` Miquel Raynal
0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2026-05-20 8:11 UTC (permalink / raw)
To: Shitalkumar Gandhi
Cc: Alexander Aring, Stefan Schmidt, Simon Horman, Andrew Lunn,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
linux-wpan, netdev, linux-kernel, stable, Shitalkumar Gandhi
Hi,
> @@ -2540,8 +2540,10 @@ static ssize_t ca8210_test_int_user_read(
> !kfifo_is_empty(&priv->test.up_fifo)
> );
> }
> + unsigned int copied;
Why is this declaration in the middle of the code? It should be at the
top,no?
Thanks,
Miquèl
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-20 8:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-20 5:07 [PATCH wpan v2] ieee802154: ca8210: fix pointer truncation in kfifo on 64-bit Shitalkumar Gandhi
2026-05-20 8:11 ` Miquel Raynal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox