Unify StubLinker stub memory management with JIT code allocator - #1
anurag6569201 wants to merge 1 commit into
Conversation
Source PR: dotnet#131903 Source head: bb70c03
⛔ Shipwright · BlockedRecommendation: do not merge PR #1 · Tier
Findings (11)
Fireworks usage: 59,680 input · 1,408 output · 61,088 total tokens · $0.0141 · 23s · 0 fix iteration(s) Open the Shipwright check for full evidence and the audit bundle. Use |
| } | ||
|
|
||
| typedef DPTR(PTR_MethodDesc) PTR_PTR_MethodDesc; | ||
|
|
There was a problem hiding this comment.
Shipwright · CRITICAL
GetStubTargetMethod reads a PTR_MethodDesc from immediately before the stub start address (pStubData - sizeof(PTR_MethodDesc)) without any validation that the memory layout actuall
Impact: GetStubTargetMethod reads a PTR_MethodDesc from immediately before the stub start address (pStubData - sizeof(PTR_MethodDesc)) without any validation that the memory layout actually contains a MethodDesc pointer. If the stub kind is not WRAPPER_STUB or the allocation layout differs, this dereferences arbitrary memory and can crash or corrupt state.
Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
| } | ||
|
|
||
| typedef DPTR(PTR_MethodDesc) PTR_PTR_MethodDesc; | ||
|
|
There was a problem hiding this comment.
Shipwright · CRITICAL
The change from Stub::RecoverStub to GetStubTargetMethod removes the debug-only signature validation (kUsedStub) and the assertion that the entry point matches the stub.
Impact: The change from Stub::RecoverStub to GetStubTargetMethod removes the debug-only signature validation (kUsedStub) and the assertion that the entry point matches the stub. In DAC builds, the old code explicitly checked m_signature and GetEntryPoint before dereferencing. The new code blindly reads a pointer before the stub address, creating a memory-safety vulnerability where a crafted or corrupted dump can cause arbit…
Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
|
|
||
| extern "C" void STDCALL JIT_PatchedCodeStart(); | ||
| extern "C" void STDCALL JIT_PatchedCodeLast(); | ||
| #ifndef TARGET_X86 |
There was a problem hiding this comment.
Shipwright · HIGH
The new GetCodeSize helper uses a ptrdiff_t subtraction and asserts codeSize > 0, but the callers pass symbol addresses that may not be ordered correctly on all platforms or build
Impact: The new GetCodeSize helper uses a ptrdiff_t subtraction and asserts codeSize > 0, but the callers pass symbol addresses that may not be ordered correctly on all platforms or build configurations. If the linker places JIT_WriteBarrier_End before JIT_WriteBarrier, the assert fires in release builds or the size is silently wrong.
Suggested fix: Review the cited evidence, fix the risk if confirmed, and rerun Shipwright.
StubLinker-generated stubs used a dedicated
LoaderAllocator::m_pStubHeap, separate from the executable memory infrastructure shared by JITed code and other stub kinds. This PR unifies the two paths.LoaderAllocator: removedm_pStubHeapand its init/terminate/DAC/size-reporting plumbing.StubLinker/Stub:StubLinker::LinkandStub::NewStubnow take aLoaderAllocator*instead of aLoaderHeap*, allocating stub memory throughExecutionManager::GetEEJitManager()->AllocCodeFragmentBlock.StubCodeBlockKind: addedSTUB_CODE_BLOCK_STUBLINKandSTUB_CODE_BLOCK_SHUFFLE_THUNKto distinguish these stubs in the code-fragment allocator.StubLinkStubManager: removed its own range list;RangeSectionStubManagernow recognizes the new stub kinds and forwards stub identification/tracing toStubLinkStubManager(mirroring the existing pattern for jump stubs and call-counting stubs).datadescriptor.incanddebug/daccess/request.cppto drop the removed stub heap field.stubcache.cpp,comdelegate.cpp,prestub.cpp,assembly.cpp,appdomain.hpp/.inl, andclass.hto passLoaderAllocator*instead of a stubLoaderHeap*.Source merge-base:
c36f112e7ad108b8f52e5d7028d2ecc09a4015f2Source head:
bb70c03b305a8f424e9924bb2defc66bcd7424b1