Wasm: stop R2R stack walk at reverse-pinvoke frames - #131668
Conversation
Fixes a failure seen in dotnet#131493 (enable SPC R2R). We were walking off the end of the managed part of the shadow stack at a reverse pinvoke boundary. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 89caa9c8-5b0f-4fcc-a8c4-726ac8535110
|
@dotnet/wasm-contrib PTAL Not sure who best to tag as a reviewer given that David is away for a few days. @janvorli ? |
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Updates the WASM RtlVirtualUnwind implementation to stop R2R shadow-stack-based unwinding when the current frame is a reverse-P/Invoke boundary (i.e., the managed frame’s caller is native), preventing the unwind from treating a native caller SP as a managed shadow frame.
Changes:
- Extends
WasmUnwindStackFrameCoreto optionally leave the caller IP unset when the caller is native. - Detects reverse-P/Invoke frames via GC info (
DECODE_REVERSE_PINVOKE_VAR) and uses that to terminate the R2R walk at the native boundary.
| EECodeInfo codeInfo; | ||
| codeInfo.Init((PCODE)ControlPc); | ||
| if (codeInfo.IsValid()) |
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
Holistic ReviewMotivation: Real and well-founded. Approach: Directionally right and consistent with the existing precedent in Summary: Detailed Findings
|
Fixes a failure seen in #131493 (enable SPC R2R). We were walking off the end of the managed part of the shadow stack at a reverse pinvoke boundary.