mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 20:51:44 +00:00
963b54df82
When allocating the 2D array for handling IRQ type registers in
regmap_add_irq_chip_fwnode(), the intent is to allocate a matrix
with num_config_bases rows and num_config_regs columns.
This is currently handled by allocating a buffer to hold a pointer for
each row (i.e. num_config_bases). After that, the logic attempts to
allocate the memory required to hold the register configuration for
each row. However, instead of doing this allocation for each row
(i.e. num_config_bases allocations), the logic erroneously does this
allocation num_config_regs number of times.
This scenario can lead to out-of-bounds accesses when num_config_regs
is greater than num_config_bases. Fix this by updating the terminating
condition of the loop that allocates the memory for holding the register
configuration to allocate memory only for each row in the matrix.
Amit Pundir reported a crash that was occurring on his db845c device
due to memory corruption (see "Closes" tag for Amit's report). The KASAN
report below helped narrow it down to this issue:
[ 14.033877][ T1] ==================================================================
[ 14.042507][ T1] BUG: KASAN: invalid-access in regmap_add_irq_chip_fwnode+0x594/0x1364
[ 14.050796][ T1] Write of size 8 at addr 06ffff8081021850 by task init/1
[ 14.242004][ T1] The buggy address belongs to the object at ffffff8081021850
[ 14.242004][ T1] which belongs to the cache kmalloc-8 of size 8
[ 14.255669][ T1] The buggy address is located 0 bytes inside of
[ 14.255669][ T1] 8-byte region [ffffff8081021850, ffffff8081021858)
Fixes:
|
||
---|---|---|
.. | ||
firmware_loader | ||
power | ||
regmap | ||
test | ||
arch_numa.c | ||
arch_topology.c | ||
attribute_container.c | ||
auxiliary.c | ||
base.h | ||
bus.c | ||
cacheinfo.c | ||
class.c | ||
component.c | ||
container.c | ||
core.c | ||
cpu.c | ||
dd.c | ||
devcoredump.c | ||
devres.c | ||
devtmpfs.c | ||
driver.c | ||
firmware.c | ||
hypervisor.c | ||
init.c | ||
isa.c | ||
Kconfig | ||
Makefile | ||
map.c | ||
memory.c | ||
module.c | ||
node.c | ||
physical_location.c | ||
physical_location.h | ||
pinctrl.c | ||
platform-msi.c | ||
platform.c | ||
property.c | ||
soc.c | ||
swnode.c | ||
syscore.c | ||
topology.c | ||
trace.c | ||
trace.h | ||
transport_class.c |