Memory-safety bug in Buffer11::NativeBuffer11::map
- Fixed in 3 months
- Paid in 3 months
- Disclosed after 3 months
Buffer11::NativeBuffer11::map (gfx\angle\src\libGLESv2\renderer\d3d\d3d11\Buffer11.cpp) can cause its callers to use a wild pointer to read and/or write data to memory. This is because it calls ID3D11DeviceContext::Map without checking the return code (in release builds). It then returns the resulting mappedResource.pData to its callers, which use it to read and/or write data into memory that (on success) would be mapped to a GPU buffer. But mappedResource is an automatic variable with no explicit initialization, and it isa D3D11_MAPPED_SUBRESOURCE, which lacks a constructor and so does not initialize itself. Thus, on failure (which is possible: see https://msdn.microsoft.com/en-us/library/windows/desktop/ff476457%28v=vs.85%29.aspx ) callers use a wild pointer to read and/or write data to memory.
788: void *Buffer11::NativeBuffer11::map(size_t offset, size_t length, GLbitfield access) 789: { 790: ASSERT(mUsage == BUFFER_USAGE_STAGING); 791: 792: D3D11_MAPPED_SUBRESOURCE mappedResource; 793: ID3D11DeviceContext context = mRenderer->getDeviceContext(); 794: D3D11_MAP d3dMapType = gl_d3d11::GetD3DMapTypeFromBits(access); 795: UINT d3dMapFlag = ((access & GL_MAP_UNSYNCHRONIZED_BIT) != 0 ? D3D11_MAP_FLAG_DO_NOT_WAIT : 0); 796: 797: HRESULT result = context->Map(mNativeBuffer, 0, d3dMapType, d3dMapFlag, &mappedResource); 798: UNUSED_ASSERTION_VARIABLE(result); 799: ASSERT(SUCCEEDED(result)); 800: 801: return static_cast<GLubyte>(mappedResource.pData) + offset; 802: }
There are reports of ID3D11DeviceContext::Map returning error in other applications in OOM situations (e.g, https://community.amd.com/thread/128535 ) , and when there are underlying graphics driver bugs (e.g., http://answers.flyppdevportal.com/categories/metro/gameswithdirectx.aspx?ID=7ff91f34-f8e0-4197-a5d7-991e136ae939 ).
*** There is also a similar bug in Buffer11::NativeBuffer11::copyFromStorage in the same module, but other code in the same module, e.g., Buffer11::getData, handles this issue correctly. ***
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A high-severity security bug in Graphics. Mozilla made it public on 27 October 2015 as CVE-2016-1944.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.