Skip to content

Commit 6a0a25a

Browse files
dramforeverV8 LUCI CQ
authored andcommitted
[riscv] Fix sp handling in MacroAssembler::LeaveFrame
Keep sp <= fp to ensure that data right above fp doesn't get clobbered by an inopportune signal and its handler. Such clobbering can happen in e.g. Node.js when JIT-compiled code is interrupted by a SIGCHLD handler. Bug: None Change-Id: Ief0836032ada7942e89f081f7605f61632c4d414 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7540554 Reviewed-by: Ji Qiu <qiuji@iscas.ac.cn> Commit-Queue: Yahan Lu (LuYahan) <yahan@iscas.ac.cn> Reviewed-by: Rezvan Mahdavi Hezaveh <rezvan@chromium.org> Cr-Commit-Position: refs/heads/main@{#105069}
1 parent 322f170 commit 6a0a25a

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎AUTHORS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ Vadim Gorbachev <bmsdave@gmail.com>
306306
Varun Varada <varuncvarada@gmail.com>
307307
Victor Costan <costan@gmail.com>
308308
Victor Polevoy <fx@thefx.co>
309+
Vivian Wang <wangruikang@iscas.ac.cn>
309310
Vlad Burlik <vladbph@gmail.com>
310311
Vladimir Kempik <vladimir.kempik@syntacore.com>
311312
Vladimir Krivosheev <develar@gmail.com>

‎src/codegen/riscv/macro-assembler-riscv.cc‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6782,9 +6782,10 @@ void MacroAssembler::EnterFrame(StackFrame::Type type, ShadowStackStatus ss) {
67826782

67836783
void MacroAssembler::LeaveFrame(StackFrame::Type type) {
67846784
ASM_CODE_COMMENT(this);
6785-
AddWord(sp, fp, 2 * kSystemPointerSize);
6785+
Move(sp, fp);
67866786
LoadWord(ra, MemOperand(fp, 1 * kSystemPointerSize));
67876787
LoadWord(fp, MemOperand(fp, 0 * kSystemPointerSize));
6788+
AddWord(sp, sp, 2 * kSystemPointerSize);
67886789
#ifdef V8_ENABLE_RISCV_SHADOW_STACK
67896790
sspopchk_ra();
67906791
#endif

0 commit comments

Comments
 (0)