Windows: Validate any user handle permissions for syscall callbacks

In the terminate case, if we don't return early then we will delete the
FEX thread object but the actual terminate call that follows will
fail, leaving the thread in a bad state.
This commit is contained in:
Billy Laws committed 2025-08-12 00:51:00 +01:00
1 parent 6f5d4fbf30
commit b2b5ccf69c
4 files changed
+31 -1

No files matched your search

+5
View File
@@ -39,6 +39,7 @@ $end_info$
#include "Common/Module.h"
#include "Common/CRT/CRT.h"
#include "Common/PortabilityInfo.h"
#include "Common/Handle.h"
#include "DummyHandlers.h"
#include "BTInterface.h"
#include "Windows/Common/SHMStats.h"
@@ -959,6 +960,10 @@ NTSTATUS ThreadInit() {
}
NTSTATUS ThreadTerm(HANDLE Thread, LONG ExitCode) {
if (!FEX::Windows::ValidateHandleAccess(Thread, THREAD_TERMINATE)) {
return STATUS_ACCESS_DENIED;
}
THREAD_BASIC_INFORMATION Info;
if (auto Err = NtQueryInformationThread(Thread, ThreadBasicInformation, &Info, sizeof(Info), nullptr); Err) {
return Err;