mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2026-11-19 18:21:41 +00:00
sbi_dbtr_read_trig() rejects ranges ending exactly at total_trigs because it treats trig_idx_base + trig_count == total_trigs as out of range. This breaks the corner case where supervisor software reads the last trigger by asking for base total_trigs - 1 and count 1. Validate the base first, then compare trig_count against total_trigs - trig_idx_base. This permits exact-end ranges and avoids relying on unsigned addition that could overflow for a bad count. On similar lines, the trig_count parameter of sbi_dbtr_install_trig() and sbi_dbtr_update_trig() can be equal to total_trigs. Fixes:a14e4d24a1("lib: sbi: dbtr: fix integer overflow in read_trig bounds check") Fixes:97f234f15c("lib: sbi: Introduce the SBI debug triggers extension support") Signed-off-by: Himanshu Chauhan <himanshu.chauhan@oss.qualcomm.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20261107060325.1117887-1-himanshu.chauhan@oss.qualcomm.com Signed-off-by: Anup Patel <anup@brainfault.org>