Skip to content

Commit

Permalink
Fix fail-fast due to unlocked FreeProcessData call (#12599)
Browse files Browse the repository at this point in the history
2b202ce introduced a bug, where FreeProcessData was called without the console
lock being held. The previous code can be found in 40e3dea, on line 441-454.

## PR Checklist
* [x] Closes MSFT:21372705
* [x] I work here
* [x] Tests added/passed

## Validation Steps Performed
None, as this fix is purely theoretic, but it matches the stack trace
and 40e3dea clearly wasn't correctly ported to strict C++ either.

(cherry picked from commit 79a08ec)
  • Loading branch information
lhecker authored and DHowett committed Mar 10, 2022
1 parent 3914779 commit 9e960ce
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/server/IoDispatchers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,6 @@ PCONSOLE_API_MSG IoDispatchers::ConsoleHandleConnectionRequest(_In_ PCONSOLE_API
LockConsole();

const auto cleanup = wil::scope_exit([&]() noexcept {
UnlockConsole();

if (!NT_SUCCESS(Status))
{
pReceiveMsg->SetReplyStatus(Status);
Expand All @@ -299,6 +297,9 @@ PCONSOLE_API_MSG IoDispatchers::ConsoleHandleConnectionRequest(_In_ PCONSOLE_API
gci.ProcessHandleList.FreeProcessData(ProcessData);
}
}

// FreeProcessData() above requires the console to be locked.
UnlockConsole();
});

DWORD const dwProcessId = (DWORD)pReceiveMsg->Descriptor.Process;
Expand Down

0 comments on commit 9e960ce

Please sign in to comment.