linux/fs/pstore
Sergey Shtylyov 86222a8fc1 pstore: ram_core: fix possible overflow in persistent_ram_init_ecc()
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>
2023-12-08 14:15:00 -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: convert to new timestamp accessors 2023-10-18 14:08:26 +02: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
platform.c pstore/platform: Add check for kstrdup 2023-10-12 09:47:01 -07:00
pmsg.c pstore update for v6.4-rc1 2023-04-27 17:03:40 -07:00
ram_core.c pstore: ram_core: fix possible overflow in persistent_ram_init_ecc() 2023-12-08 14:15:00 -08:00
ram_internal.h pstore/ram: Set freed addresses to NULL 2022-10-19 09:25:39 -07:00
ram.c pstore/ram: Fix crash when setting number of cpus to an odd number 2023-12-08 14:15:00 -08:00
zone.c pstore/zone: Use GFP_ATOMIC to allocate zone buffer 2022-10-17 13:14:10 -07:00