Skip to content

Commit cdfae41

Browse files
[NativeAOT] Adjust SSP to match RSP of the throw site (#119194)
This fixes unbounded shadow stack growth that leads to stack overflow exception when exceptions are thrown and caught in a loop. Fixes #118913 Fixes #107418 Co-authored-by: Jan Kotas <[email protected]>
1 parent 1dc2902 commit cdfae41

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/coreclr/nativeaot/Runtime/amd64/ExceptionHandling.asm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ NESTED_ENTRY RhpThrowEx, _TEXT
130130

131131
alloc_stack SIZEOF_XmmSaves + 8h ;; reserve stack for the xmm saves (+8h to realign stack)
132132
rdsspq r8 ;; nop if SSP is not implemented, 0 if not enabled
133+
test r8, r8
134+
je @f
135+
add r8, 8 ;; Move SSP to match RSP of the throw site
136+
@@:
133137
push_vol_reg r8 ;; SSP
134138
xor r8, r8
135139
push_nonvol_reg r15
@@ -226,6 +230,10 @@ NESTED_ENTRY RhpRethrow, _TEXT
226230

227231
alloc_stack SIZEOF_XmmSaves + 8h ;; reserve stack for the xmm saves (+8h to realign stack)
228232
rdsspq r8 ;; nop if SSP is not implemented, 0 if not enabled
233+
test r8, r8
234+
je @f
235+
add r8, 8 ;; Move SSP to match RSP of the throw site
236+
@@:
229237
push_vol_reg r8 ;; SSP
230238
xor r8, r8
231239
push_nonvol_reg r15

src/tests/issues.targets

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,13 +1024,6 @@
10241024
</ExcludeList>
10251025
</ItemGroup>
10261026

1027-
<!-- NativeAOT ControlFlowGuard specific -->
1028-
<ItemGroup Condition="'$(XunitTestBinBase)' != '' and '$(TestBuildMode)' == 'nativeaot' and '$(RuntimeFlavor)' == 'coreclr' and '$(ControlFlowGuard)' == 'Guard'">
1029-
<ExcludeList Include = "$(XunitTestBinBase)/JIT/Regression/CLR-x86-JIT/V2.0-Beta2/b425314/b425314/**">
1030-
<Issue>https://github.com/dotnet/runtime/issues/107418</Issue>
1031-
</ExcludeList>
1032-
</ItemGroup>
1033-
10341027
<!-- run.proj finds all the *.cmd/*.sh scripts in a test folder and creates corresponding test methods.
10351028
Exclude these scripts to avoid creating such methods for the superpmicollect dependent test projects
10361029
and running them separately from superpmicollect test. These should be excluded regardless of RuntimeFlavor/os/arch-->

0 commit comments

Comments
 (0)