RISC-V: KVM: fix stack overrun when loading vlenb
authorRadim Krčmář <rkrcmar@ventanamicro.com>
Tue, 5 Aug 2025 10:44:21 +0000 (12:44 +0200)
committerAnup Patel <anup@brainfault.org>
Mon, 25 Aug 2025 04:56:20 +0000 (10:26 +0530)
commit799766208f09f95677a9ab111b93872d414fbad7
tree8e90fcf0e0d6686d6a5507a865cfcef8178e93c1
parente61a12a4baf06a4c71e15f522bb5c4345c2ba198
RISC-V: KVM: fix stack overrun when loading vlenb

The userspace load can put up to 2048 bits into an xlen bit stack
buffer.  We want only xlen bits, so check the size beforehand.

Fixes: 2fa290372dfe ("RISC-V: KVM: add 'vlenb' Vector CSR")
Cc: stable@vger.kernel.org
Signed-off-by: Radim Krčmář <rkrcmar@ventanamicro.com>
Reviewed-by: Nutty Liu <liujingqi@lanxincomputing.com>
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Link: https://lore.kernel.org/r/20250805104418.196023-4-rkrcmar@ventanamicro.com
Signed-off-by: Anup Patel <anup@brainfault.org>
arch/riscv/kvm/vcpu_vector.c