Skip to content

Commit 5c1bb07

Browse files
Radim Krčmářavpatel
authored andcommitted
RISC-V: KVM: fix off-by-one array access in SBI PMU
The indexed array only has RISCV_KVM_MAX_COUNTERS elements. The out-of-bound access could have been performed by a guest, but it could only access another guest accessible data. Fixes: 8f0153e ("RISC-V: KVM: Add skeleton support for perf") Signed-off-by: Radim Krčmář <radim.krcmar@oss.qualcomm.com> Reviewed-by: Anup Patel <anup@brainfault.org> Link: https://lore.kernel.org/r/20260227134617.23378-1-radim.krcmar@oss.qualcomm.com Signed-off-by: Anup Patel <anup@brainfault.org>
1 parent c28eb18 commit 5c1bb07

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/riscv/kvm/vcpu_pmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ int kvm_riscv_vcpu_pmu_ctr_info(struct kvm_vcpu *vcpu, unsigned long cidx,
520520
{
521521
struct kvm_pmu *kvpmu = vcpu_to_pmu(vcpu);
522522

523-
if (cidx > RISCV_KVM_MAX_COUNTERS || cidx == 1) {
523+
if (cidx >= RISCV_KVM_MAX_COUNTERS || cidx == 1) {
524524
retdata->err_val = SBI_ERR_INVALID_PARAM;
525525
return 0;
526526
}

0 commit comments

Comments
 (0)