From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CC1A41F7C3; Tue, 21 Jul 2026 22:23:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784672602; cv=none; b=j9DcrLmAz6QRtm5y/4ZkIQg4DTclv8rAEXyBqzTECFUOCTX6rvDtPafQ1uRa1SUTLiUv0YRDZn+Ydb0lZ5UR1GB9HdaS3Zd3xXIbJHi64o5XA+YT5dH+yJysL6Iyf5t08Vijrm+ky2lpPgopB4Y70SEFPCqjkdLn4Hm9zCD0HS8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784672602; c=relaxed/simple; bh=s4UFgHtQDMy67vU0rmvroGopO89PwKJt3OO016hZBRI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JXrRDRPKMAP4If5BNV+TT8HR6tArU1jR6ewV0//vUwRJ343Q4KlVMSIkinTZVznsnEBUZ8MNIAE35My9qB0i2l3Zc/r0OvGL/cx8djdPpFPEIT8eQv9KnQ+rfOqx1y62wUa9Of8EV0Adjc0HziAoAg/tih/sgk8jo27zJun+GPY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TuEgrRGO; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="TuEgrRGO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B267F1F000E9; Tue, 21 Jul 2026 22:23:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784672600; bh=zOAL2ooqX6j/mr1/yC+v68AnJtH8Aoz4aKa13uIyYI8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TuEgrRGOGGgsFJtvE5ol97dY0r4RAzapltkkXR2U5YRxu8jYCYMJowTYl+Fg1vxyj c/Dpn8hQyvEwo2Fm7g2Ye7japKWY+Rx7D058+H3RmPkGIgRqOTjW5WFG4cIKO1mKuJ 3oEsptrApsouWa9FKPVV5mSE0kf4UxuhK97XUUSE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Shitalkumar Gandhi , Simon Horman , Stefan Schmidt Subject: [PATCH 5.15 687/843] ieee802154: ca8210: fix pointer truncation in kfifo on 64-bit Date: Tue, 21 Jul 2026 17:25:22 +0200 Message-ID: <20260721152421.509838409@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152405.946368001@linuxfoundation.org> References: <20260721152405.946368001@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shitalkumar Gandhi commit 6d7f7bcf225b2d566176bf6229dbd1252940cb3c upstream. 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 Reviewed-by: Simon Horman Link: https://lore.kernel.org/20260520105750.30144-1-shitalkumar.gandhi@cambiumnetworks.com Signed-off-by: Stefan Schmidt Signed-off-by: Greg Kroah-Hartman --- drivers/net/ieee802154/ca8210.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/net/ieee802154/ca8210.c +++ b/drivers/net/ieee802154/ca8210.c @@ -639,7 +639,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; @@ -2571,6 +2571,7 @@ static ssize_t ca8210_test_int_user_read struct ca8210_priv *priv = filp->private_data; unsigned char *fifo_buffer; unsigned long bytes_not_copied; + unsigned int copied; if (filp->f_flags & O_NONBLOCK) { /* Non-blocking mode */ @@ -2584,7 +2585,8 @@ static ssize_t ca8210_test_int_user_read ); } - 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"