]> www.infradead.org Git - users/jedix/linux-maple.git/commit
riscv: kvm: Fix out-of-bounds array access
authorBjörn Töpel <bjorn@rivosinc.com>
Mon, 4 Nov 2024 19:15:01 +0000 (20:15 +0100)
committerAnup Patel <anup@brainfault.org>
Tue, 5 Nov 2024 07:57:32 +0000 (13:27 +0530)
commit332fa4a802b16ccb727199da685294f85f9880cb
tree8e0fe1c41d7ccd7b8c9e010c44f9016ab7101b9b
parent60821fb4dd7345e5662094accf0a52845306de8c
riscv: kvm: Fix out-of-bounds array access

In kvm_riscv_vcpu_sbi_init() the entry->ext_idx can contain an
out-of-bound index. This is used as a special marker for the base
extensions, that cannot be disabled. However, when traversing the
extensions, that special marker is not checked prior indexing the
array.

Add an out-of-bounds check to the function.

Fixes: 56d8a385b605 ("RISC-V: KVM: Allow some SBI extensions to be disabled by default")
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20241104191503.74725-1-bjorn@kernel.org
Signed-off-by: Anup Patel <anup@brainfault.org>
arch/riscv/kvm/vcpu_sbi.c