aboutsummaryrefslogtreecommitdiff
path: root/arch/riscv/kvm/vcpu_vector.c
diff options
context:
space:
mode:
authorGreentime Hu <[email protected]>2023-06-05 11:07:14 +0000
committerPalmer Dabbelt <[email protected]>2023-06-08 07:16:49 -0700
commitc7cdd96eca2810f5b69c37eb439ec63d59fa1b83 (patch)
treef2a8e3558e3a32fedd2ebe2cd5962a6e8b3449a3 /arch/riscv/kvm/vcpu_vector.c
parent76e22fdc2c2658ab595cdda7368d43d2dc16f3f4 (diff)
riscv: prevent stack corruption by reserving task_pt_regs(p) early
Early function calls, such as setup_vm(), relocate_enable_mmu(), soc_early_init() etc, are free to operate on stack. However, PT_SIZE_ON_STACK bytes at the head of the kernel stack are purposedly reserved for the placement of per-task register context pointed by task_pt_regs(p). Those functions may corrupt task_pt_regs if we overlap the $sp with it. In fact, we had accidentally corrupted sstatus.VS in some tests, treating the kernel to save V context before V was actually allocated, resulting in a kernel panic. Thus, we should skip PT_SIZE_ON_STACK for $sp before making C function calls from the top-level assembly. Co-developed-by: ShihPo Hung <[email protected]> Signed-off-by: ShihPo Hung <[email protected]> Co-developed-by: Vincent Chen <[email protected]> Signed-off-by: Vincent Chen <[email protected]> Signed-off-by: Greentime Hu <[email protected]> Signed-off-by: Andy Chiu <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Reviewed-by: Heiko Stuebner <[email protected]> Tested-by: Heiko Stuebner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
Diffstat (limited to 'arch/riscv/kvm/vcpu_vector.c')
0 files changed, 0 insertions, 0 deletions