diff options
| author | Bin Meng <[email protected]> | 2022-12-11 14:54:21 +0800 |
|---|---|---|
| committer | Anup Patel <[email protected]> | 2022-12-17 09:00:29 +0530 |
| commit | 8509e46ca63a4ed7dff2244cd7f288bf5591ab61 (patch) | |
| tree | 17f2815b39328279f9459d09e106c8a31660442a /include | |
| parent | 34da6638ad7b3d8c1834dffe5cd2629aa748efaf (diff) | |
lib: utils/irqchip: plic: Ensure no out-of-bound access in priority save/restore helpers
Currently the priority 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 <[email protected]>
Reviewed-by: Anup Patel <[email protected]>
Diffstat (limited to 'include')
| -rw-r--r-- | include/sbi_utils/irqchip/fdt_irqchip_plic.h | 14 | ||||
| -rw-r--r-- | include/sbi_utils/irqchip/plic.h | 5 |
2 files changed, 15 insertions, 4 deletions
diff --git a/include/sbi_utils/irqchip/fdt_irqchip_plic.h b/include/sbi_utils/irqchip/fdt_irqchip_plic.h index 98d4de57..d5b1c60e 100644 --- a/include/sbi_utils/irqchip/fdt_irqchip_plic.h +++ b/include/sbi_utils/irqchip/fdt_irqchip_plic.h @@ -9,9 +9,19 @@ #include <sbi/sbi_types.h> -void fdt_plic_priority_save(u8 *priority); +/** + * Save the PLIC priority state + * @param priority pointer to the memory region for the saved priority + * @param num size of the memory region including interrupt source 0 + */ +void fdt_plic_priority_save(u8 *priority, u32 num); -void fdt_plic_priority_restore(const u8 *priority); +/** + * Restore the PLIC priority state + * @param priority pointer to the memory region for the saved priority + * @param num size of the memory region including interrupt source 0 + */ +void fdt_plic_priority_restore(const u8 *priority, u32 num); void fdt_plic_context_save(bool smode, u32 *enable, u32 *threshold); diff --git a/include/sbi_utils/irqchip/plic.h b/include/sbi_utils/irqchip/plic.h index 48c24f0b..38704a10 100644 --- a/include/sbi_utils/irqchip/plic.h +++ b/include/sbi_utils/irqchip/plic.h @@ -18,9 +18,10 @@ struct plic_data { }; /* So far, priorities on all consumers of these functions fit in 8 bits. */ -void plic_priority_save(const struct plic_data *plic, u8 *priority); +void plic_priority_save(const struct plic_data *plic, u8 *priority, u32 num); -void plic_priority_restore(const struct plic_data *plic, const u8 *priority); +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); |
