diff options
author | Bin Meng <bmeng@tinylab.org> | 2022-12-11 09:54:24 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2022-12-17 06:33:30 +0300 |
commit | 9a2eeb4aaeac9102a7db3676035d83394784c88b (patch) | |
tree | a1969ea5d42c251b3d17890e9e74fb537b7da09d /include | |
parent | fabbc006687a0fddeabb7a3effabb3a8e1c81c48 (diff) | |
download | opensbi-9a2eeb4aaeac9102a7db3676035d83394784c88b.tar.xz |
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>
Diffstat (limited to 'include')
-rw-r--r-- | include/sbi_utils/irqchip/fdt_irqchip_plic.h | 5 | ||||
-rw-r--r-- | include/sbi_utils/irqchip/plic.h | 4 |
2 files changed, 5 insertions, 4 deletions
diff --git a/include/sbi_utils/irqchip/fdt_irqchip_plic.h b/include/sbi_utils/irqchip/fdt_irqchip_plic.h index d5b1c60..df645dd 100644 --- a/include/sbi_utils/irqchip/fdt_irqchip_plic.h +++ b/include/sbi_utils/irqchip/fdt_irqchip_plic.h @@ -23,9 +23,10 @@ void fdt_plic_priority_save(u8 *priority, u32 num); */ void fdt_plic_priority_restore(const u8 *priority, u32 num); -void fdt_plic_context_save(bool smode, u32 *enable, u32 *threshold); +void fdt_plic_context_save(bool smode, u32 *enable, u32 *threshold, u32 num); -void fdt_plic_context_restore(bool smode, const u32 *enable, u32 threshold); +void fdt_plic_context_restore(bool smode, const u32 *enable, u32 threshold, + u32 num); void thead_plic_restore(void); diff --git a/include/sbi_utils/irqchip/plic.h b/include/sbi_utils/irqchip/plic.h index 38704a1..112a714 100644 --- a/include/sbi_utils/irqchip/plic.h +++ b/include/sbi_utils/irqchip/plic.h @@ -24,10 +24,10 @@ void plic_priority_restore(const struct plic_data *plic, const u8 *priority, u32 num); void plic_context_save(const struct plic_data *plic, int context_id, - u32 *enable, u32 *threshold); + u32 *enable, u32 *threshold, u32 num); void plic_context_restore(const struct plic_data *plic, int context_id, - const u32 *enable, u32 threshold); + const u32 *enable, u32 threshold, u32 num); int plic_context_init(const struct plic_data *plic, int context_id, bool enable, u32 threshold); |