diff options
author | Clément Léger <cleger@rivosinc.com> | 2024-04-09 12:02:08 +0200 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2024-05-07 17:31:08 +0530 |
commit | 033104da08baf52c8b65b56a03363ea238c9ca31 (patch) | |
tree | 13dc194005a8ef600db7ebae28fb93f45e391e8f | |
parent | bd007658f8f36e2846ea3f420afe2d0891bd1110 (diff) | |
download | opensbi-033104da08baf52c8b65b56a03363ea238c9ca31.zip opensbi-033104da08baf52c8b65b56a03363ea238c9ca31.tar.gz opensbi-033104da08baf52c8b65b56a03363ea238c9ca31.tar.bz2 |
lib: sbi: sse: check handler entry to belong to supervisor mode
When registering an SSE event, check for the handler_entry_pc to belong
to supervisor mode domain using sbi_domain_check_addr_range().
Signed-off-by: Clément Léger <cleger@rivosinc.com>
Reported-by: Samuel Holland <samuel.holland@sifive.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
-rw-r--r-- | lib/sbi/sbi_sse.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/sbi/sbi_sse.c b/lib/sbi/sbi_sse.c index 76fbee4..18dfdb6 100644 --- a/lib/sbi/sbi_sse.c +++ b/lib/sbi/sbi_sse.c @@ -959,6 +959,12 @@ int sbi_sse_register(uint32_t event_id, unsigned long handler_entry_pc, if (handler_entry_pc & 0x1) return SBI_EINVAL; + if (!sbi_domain_check_addr_range(sbi_domain_thishart_ptr(), + handler_entry_pc, + sizeof(unsigned long), PRV_S, + SBI_DOMAIN_EXECUTE)) + return SBI_EINVALID_ADDR; + e = sse_event_get(event_id); if (!e) return SBI_EINVAL; |