[PATCH 0/1] MR881: kernelbase: Fix reading stale information from IOSB.
Ensure IOSB Information (InternalHigh) is loaded after Status (Internal) to avoid reading stale value from the Information (InternalHigh) field. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/881
From: Jinoh Kang <jinoh.kang.kr(a)gmail.com> Ensure IOSB Information (InternalHigh) is loaded after Status (Internal) to avoid reading stale value from the Information (InternalHigh) field. --- dlls/kernelbase/file.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c index 5ba7e0be419..62f65a1c068 100644 --- a/dlls/kernelbase/file.c +++ b/dlls/kernelbase/file.c @@ -3133,7 +3133,7 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetOverlappedResultEx( HANDLE file, OVERLAPPED *ov TRACE( "(%p %p %p %lu %d)\n", file, overlapped, result, timeout, alertable ); - status = overlapped->Internal; + status = ReadAcquire((volatile LONG *)&overlapped->Internal); if (status == STATUS_PENDING) { if (!timeout) @@ -3150,7 +3150,13 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetOverlappedResultEx( HANDLE file, OVERLAPPED *ov return FALSE; } - status = overlapped->Internal; + /* Normally this does not require an atomic load, since the wait above + * acts as a barrier as long as the caller supplied the correct handle + * and nothing else interfered with signalling of I/O completion. + * However, we do it anyway for consistency and extra safety in case + * Windows takes the same precaution for misbehaving applications. + */ + status = ReadAcquire((volatile LONG *)&overlapped->Internal); if (status == STATUS_PENDING) status = STATUS_SUCCESS; } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/881
participants (2)
-
Jinoh Kang -
Jinoh Kang (@iamahuman)