From: root <karthiproffesional@gmail.com>
To: joel@jms.id.au, andrew@codeconstruct.com.au
Cc: jdelvare@suse.de, linux-aspeed@lists.ozlabs.org,
linux-kernel@vger.kernel.org,
Karthikeyan KS <karthiproffesional@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH] soc: aspeed: lpc-snoop: Fix usercopy overflow in snoop_file_read
Date: Thu, 23 Apr 2026 19:20:45 +0000 [thread overview]
Message-ID: <20260423192045.5729-1-root@LAPTOP-97G9G880.localdomain> (raw)
From: Karthikeyan KS <karthiproffesional@gmail.com>
snoop_file_read() passes the userspace count directly to
kfifo_to_user() without clamping. The kfifo backing buffer is
2048 bytes (SNOOP_FIFO_SIZE), allocated from kmalloc-2k slab.
A read larger than 2048 bytes triggers a BUG under
CONFIG_HARDENED_USERCOPY:
kernel BUG at mm/usercopy.c:99!
Reproducer:
hexdump /dev/aspeed-lpc-snoop0
Fix by clamping count to SNOOP_FIFO_SIZE before the copy.
Fixes: 3772e5da4454 ("drivers/misc: Aspeed LPC snoop output using misc chardev")
Cc: stable@vger.kernel.org
Signed-off-by: Karthikeyan KS <karthiproffesional@gmail.com>
---
drivers/soc/aspeed/aspeed-lpc-snoop.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/soc/aspeed/aspeed-lpc-snoop.c b/drivers/soc/aspeed/aspeed-lpc-snoop.c
index b03310c0830d..5b59e826cc68 100644
--- a/drivers/soc/aspeed/aspeed-lpc-snoop.c
+++ b/drivers/soc/aspeed/aspeed-lpc-snoop.c
@@ -125,6 +125,7 @@ static ssize_t snoop_file_read(struct file *file, char __user *buffer,
if (ret == -ERESTARTSYS)
return -EINTR;
}
+ count = min(count, (size_t)SNOOP_FIFO_SIZE);
ret = kfifo_to_user(&chan->fifo, buffer, count, &copied);
if (ret)
return ret;
--
2.34.1
next reply other threads:[~2026-04-23 19:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-23 19:20 root [this message]
[not found] <CAP_JKPter_ggMMvUY=pDZyZupSQb5KWGVPeig41Uw2wBDXepMg@mail.gmail.com>
2026-05-18 11:14 ` Andrew Jeffery
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=20260423192045.5729-1-root@LAPTOP-97G9G880.localdomain \
--to=karthiproffesional@gmail.com \
--cc=andrew@codeconstruct.com.au \
--cc=jdelvare@suse.de \
--cc=joel@jms.id.au \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.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®