linux/drivers/soc/aspeed
Karthikeyan KS 1acef6d85b soc: aspeed: lpc-snoop: Fix usercopy overflow in snoop_file_read
put_fifo_with_discard() acts as both producer and consumer on the kfifo:
it calls kfifo_skip() (advances out) and kfifo_put() (advances in) from
the IRQ handler without synchronizing with snoop_file_read(), which also
consumes via kfifo_to_user(). On SMP systems this concurrent access can
leave (in - out) larger than the ring buffer, so __kfifo_to_user()'s clamp
to (in - out) is ineffective and kfifo_copy_to_user() can attempt a
copy_to_user() past the kmalloc-2k backing store:

  usercopy: Kernel memory exposure attempt detected from SLUB object
  'kmalloc-2k' (offset 0, size 2049)!
  kernel BUG at mm/usercopy.c!
  Call trace:
   usercopy_abort
   __check_heap_object
   __check_object_size
   kfifo_copy_to_user
   __kfifo_to_user
   snoop_file_read
   vfs_read

Serialize kfifo access with a per-channel spinlock shared between the
IRQ handler (producer) and the file reader (consumer).  Annotate @fifo
with __guarded_by(&lock) and opt the driver into context analysis so the
compiler enforces that all fifo access holds the lock.

Fixes: 3772e5da44 ("drivers/misc: Aspeed LPC snoop output using misc chardev")
Signed-off-by: Karthikeyan KS <karthiproffesional@gmail.com>
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
History 2026-07-22 22:10:54 +09:30
..
aspeed-lpc-ctrl.c soc: aspeed: Move MODULE_DEVICE_TABLE next to the table itself 2026-05-18 16:10:17 +09:30
aspeed-lpc-snoop.c soc: aspeed: lpc-snoop: Fix usercopy overflow in snoop_file_read 2026-07-22 22:10:54 +09:30
aspeed-p2a-ctrl.c soc: aspeed: Move MODULE_DEVICE_TABLE next to the table itself 2026-05-18 16:10:17 +09:30
aspeed-socinfo.c soc: aspeed: socinfo: Mask table entries for accurate SoC ID matching 2026-02-23 09:43:21 +10:30
aspeed-uart-routing.c soc: Switch back to struct platform_driver::remove() 2024-11-01 17:08:57 +01:00
Kconfig soc: aspeed: cleanup dead default for ASPEED_SOCINFO 2026-06-03 10:47:55 +09:30
Makefile soc: aspeed: lpc-snoop: Fix usercopy overflow in snoop_file_read 2026-07-22 22:10:54 +09:30