diff options
| author | Carlos López <carlos.lopezr4096@gmail.com> | 2024-08-01 14:58:52 +0200 |
|---|---|---|
| committer | Anup Patel <anup@brainfault.org> | 2024-08-02 08:53:22 +0530 |
| commit | 43cace6c3671e5172d0df0a8963e552bb04b7b20 (patch) | |
| tree | e46933243177fd4faa12546056627f25007cbfc3 | |
| parent | cb0f4757fc2904cbf579e34feba891a5878625c5 (diff) | |
| download | opensbi-release-1.5.x.zip opensbi-release-1.5.x.tar.gz opensbi-release-1.5.x.tar.bz2 | |
lib: sbi: check result of pmp_get() in is_pmp_entry_mapped()v1.5.1release-1.5.x
pmp_get() may return an error if the given entry, given by the caller
of is_pmp_entry_mapped(), is invalid. This results in the output
parameters for pmp_get() being uninitialized. To avoid using garbage
values, check the result and return early if necessary.
This issue is not being hit because at the moment
is_pmp_entry_mapped() is only being called from a single site with a
valid hardcoded value.
Signed-off-by: Carlos López <carlos.lopezr4096@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
| -rw-r--r-- | lib/sbi/riscv_asm.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/sbi/riscv_asm.c b/lib/sbi/riscv_asm.c index 05b8c7c..c7d75ac 100644 --- a/lib/sbi/riscv_asm.c +++ b/lib/sbi/riscv_asm.c @@ -291,7 +291,8 @@ int is_pmp_entry_mapped(unsigned long entry) unsigned long addr; unsigned long log2len; - pmp_get(entry, &prot, &addr, &log2len); + if (pmp_get(entry, &prot, &addr, &log2len) != 0) + return false; /* If address matching bits are non-zero, the entry is enable */ if (prot & PMP_A) |
