lib: utils/irqchip: plic: Ensure no out-of-bound access in context save/restore helpers
authorBin Meng <bmeng@tinylab.org>
Sun, 11 Dec 2022 06:54:24 +0000 (14:54 +0800)
committerAnup Patel <anup@brainfault.org>
Sat, 17 Dec 2022 03:33:30 +0000 (09:03 +0530)
commit9a2eeb4aaeac9102a7db3676035d83394784c88b
treea1969ea5d42c251b3d17890e9e74fb537b7da09d
parentfabbc006687a0fddeabb7a3effabb3a8e1c81c48
lib: utils/irqchip: plic: Ensure no out-of-bound access in context save/restore helpers

Currently the context save/restore helpers writes/reads the provided
array using an index whose maximum value is determined by PLIC, which
potentially may disagree with the caller to these helpers.

Add a parameter to ask the caller to provide the size limit of the
array to ensure no out-of-bound access happens.

Signed-off-by: Bin Meng <bmeng@tinylab.org>
Reviewed-by: Anup Patel <anup@brainfault.org>
include/sbi_utils/irqchip/fdt_irqchip_plic.h
include/sbi_utils/irqchip/plic.h
lib/utils/irqchip/fdt_irqchip_plic.c
lib/utils/irqchip/plic.c
platform/generic/allwinner/sun20i-d1.c