From: Andrew Jeffery <andrew@codeconstruct.com.au>
To: karthikeyan K S <karthiproffesional@gmail.com>, joel@jms.id.au
Cc: jdelvare@suse.de, linux-aspeed@lists.ozlabs.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] soc: aspeed: lpc-snoop: Fix usercopy overflow in snoop_file_read
Date: Mon, 18 May 2026 20:44:43 +0930 [thread overview]
Message-ID: <c3d474a1ec807e686c0b7ac70cc75f86898aee99.camel@codeconstruct.com.au> (raw)
In-Reply-To: <CAP_JKPter_ggMMvUY=pDZyZupSQb5KWGVPeig41Uw2wBDXepMg@mail.gmail.com>
On Fri, 2026-04-24 at 00:30 +0530, karthikeyan K S wrote:
> From c50ff07baf2032ca12133775c61c50a38e8a2029 Mon Sep 17 00:00:00 2001
> From: Karthikeyan KS <karthiproffesional@gmail.com>
> Date: Thu, 23 Apr 2026 21:26:08 +0300
> Subject: [PATCH] soc: aspeed: lpc-snoop: Fix usercopy overflow in
> snoop_file_read
>
> 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
Can you provide more details on how you achieved this result?
__kfifo_to_user() clamps the provided value to the content of the fifo
and has done in its current form since 2e956fb32056 ("kfifo: replace
the old non generic API").
>
> 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;
next prev parent reply other threads:[~2026-05-18 11:14 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-23 19:00 [PATCH] soc: aspeed: lpc-snoop: Fix usercopy overflow in snoop_file_read karthikeyan K S
2026-05-18 11:14 ` Andrew Jeffery [this message]
2026-05-23 17:35 ` [PATCH v2] " Karthikeyan KS
2026-05-27 3:53 ` Andrew Jeffery
2026-05-27 17:59 ` [PATCH v3] " Karthikeyan KS
2026-05-28 2:39 ` Andrew Jeffery
2026-06-01 12:52 ` [PATCH v4] " Karthikeyan KS
2026-06-10 2:26 ` Andrew Jeffery
2026-06-10 17:23 ` [PATCH v5] " Karthikeyan KS
2026-06-11 2:50 ` Andrew Jeffery
2026-06-11 17:31 ` karthikeyan K S
2026-06-12 0:39 ` Andrew Jeffery
2026-06-11 18:08 ` Karthikeyan KS
2026-06-12 19:07 ` [PATCH v6] " Karthikeyan KS
2026-06-16 0:20 ` Andrew Jeffery
2026-06-16 7:30 ` Karthikeyan KS
2026-06-17 0:44 ` Andrew Jeffery
2026-06-17 13:10 ` Karthikeyan KS
2026-06-18 0:44 ` Andrew Jeffery
-- strict thread matches above, loose matches on Subject: below --
2026-04-23 19:20 [PATCH] " root
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=c3d474a1ec807e686c0b7ac70cc75f86898aee99.camel@codeconstruct.com.au \
--to=andrew@codeconstruct.com.au \
--cc=jdelvare@suse.de \
--cc=joel@jms.id.au \
--cc=karthiproffesional@gmail.com \
--cc=linux-aspeed@lists.ozlabs.org \
--cc=linux-kernel@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