linux-stable/fs/pstore
Sergey Shtylyov a34946ec3d pstore: ram_core: fix possible overflow in persistent_ram_init_ecc()
[ Upstream commit 86222a8fc1 ]

In persistent_ram_init_ecc(), on 64-bit arches DIV_ROUND_UP() will return
64-bit value since persistent_ram_zone::buffer_size has type size_t which
is derived from the 64-bit *unsigned long*, while the ecc_blocks variable
this value gets assigned to has (always 32-bit) *int* type.  Even if that
value fits into *int* type, an overflow is still possible when calculating
the size_t typed ecc_total variable further below since there's no cast to
any 64-bit type before multiplication.  Declaring the ecc_blocks variable
as *size_t* should fix this mess...

Found by Linux Verification Center (linuxtesting.org) with the SVACE static
analysis tool.

Fixes: 9cc05ad97c ("staging: android: persistent_ram: refactor ecc support")
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Link: https://lore.kernel.org/r/20231105202936.25694-1-s.shtylyov@omp.ru
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 15:35:17 -08:00
..
blk.c init: improve the name_to_dev_t interface 2023-06-05 10:56:46 -06:00
ftrace.c pstore/ftrace: Allow immediate recording 2021-11-18 10:29:52 -08:00
inode.c pstore updates for v6.6-rc1 2023-08-28 12:36:04 -07:00
internal.h pstore: Move kmsg_bytes default into Kconfig 2020-12-01 12:09:17 -08:00
Kconfig pstore: Replace crypto API compression with zlib_deflate library calls 2023-07-17 16:08:58 -07:00
Makefile pstore/blk: Introduce backend for block devices 2020-05-30 10:34:03 -07:00
platform.c pstore/platform: Add check for kstrdup 2023-11-20 11:58:53 +01:00
pmsg.c pstore update for v6.4-rc1 2023-04-27 17:03:40 -07:00
ram.c pstore: Support record sizes larger than kmalloc() limit 2023-08-17 15:18:24 -07:00
ram_core.c pstore: ram_core: fix possible overflow in persistent_ram_init_ecc() 2024-01-25 15:35:17 -08:00
ram_internal.h pstore/ram: Set freed addresses to NULL 2022-10-19 09:25:39 -07:00
zone.c pstore/zone: Use GFP_ATOMIC to allocate zone buffer 2022-10-17 13:14:10 -07:00