Skip to content
Commit 879fabc5 authored by Jisheng Zhang's avatar Jisheng Zhang Committed by Greg Kroah-Hartman
Browse files

riscv: fix race when vmap stack overflow

[ Upstream commit 7e186433 ]

Currently, when detecting vmap stack overflow, riscv firstly switches
to the so called shadow stack, then use this shadow stack to call the
get_overflow_stack() to get the overflow stack. However, there's
a race here if two or more harts use the same shadow stack at the same
time.

To solve this race, we introduce spin_shadow_stack atomic var, which
will be swap between its own address and 0 in atomic way, when the
var is set, it means the shadow_stack is being used; when the var
is cleared, it means the shadow_stack isn't being used.

Fixes: 31da94c2

 ("riscv: add VMAP_STACK overflow detection")
Signed-off-by: default avatarJisheng Zhang <jszhang@kernel.org>
Suggested-by: default avatarGuo Ren <guoren@kernel.org>
Reviewed-by: default avatarGuo Ren <guoren@kernel.org>
Link: https://lore.kernel.org/r/20221030124517.2370-1-jszhang@kernel.org


[Palmer: Add AQ to the swap, and also some comments.]
Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 96f47938
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment