[PATCH] lib: sbi_dbtr: use range check for shared memory domain validation
liutong <[email protected]> Mon, 6 Jul 2026 14:53:03 +0800
| Newsgroups | org.infradead.lists.opensbi |
|---|---|
| Message-ID | <[email protected]> |
sbi_dbtr_setup_shmem() validates the shared memory address using sbi_domain_check_addr(), which only checks a single address. However, subsequent DBTR operations (install, read, update) access up to total_trigs * sizeof(sbi_dbtr_shmem_entry) bytes starting from that address. If the shared memory region spans a domain boundary, accesses beyond the first byte could violate domain isolation. Replace the single-address check with sbi_domain_check_addr_range() to validate the entire shared memory region that DBTR operations will use. Signed-off-by: liutong <[email protected]> --- lib/sbi/sbi_dbtr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/sbi/sbi_dbtr.c b/lib/sbi/sbi_dbtr.c index 01047969..983f0f6a 100644 --- a/lib/sbi/sbi_dbtr.c +++ b/lib/sbi/sbi_dbtr.c @@ -304,9 +304,10 @@ int sbi_dbtr_setup_shmem(const struct sbi_domain *dom, unsigned long smode, if (shmem_phys_hi) return SBI_EINVALID_ADDR; - if (dom && !sbi_domain_check_addr(dom, - DBTR_SHMEM_MAKE_PHYS(shmem_phys_hi, shmem_phys_lo), smode, - SBI_DOMAIN_READ | SBI_DOMAIN_WRITE)) + if (dom && !sbi_domain_check_addr_range(dom, + DBTR_SHMEM_MAKE_PHYS(shmem_phys_hi, shmem_phys_lo), + hart_state->total_trigs * sizeof(union sbi_dbtr_shmem_entry), + smode, SBI_DOMAIN_READ | SBI_DOMAIN_WRITE)) return SBI_ERR_INVALID_ADDRESS; hart_state->shmem.phys_lo = shmem_phys_lo; -- 2.34.1 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi