Mishandling return status in ReadbackResultWriterD3D11::Run might cause memory-safety bug
- Fixed in 18 days
- Paid in 19 days
- Disclosed after 18 days
ReadbackResultWriterD3D11::Run (gfx\layers\d3d11\ReadbackManagerD3D11.cpp) mishandles failure status from ID3D10Texture2D::Map. This might cause it to use a pointer and other data from uninitialized memory to create a surface, which is then used to read (and possibly write?) data from/to memory:
41: NS_IMETHODIMP Run()
42: {
43: D3D10_TEXTURE2D_DESC desc;
44: mTask->mReadbackTexture->GetDesc(&desc);
45:
46: D3D10_MAPPED_TEXTURE2D mappedTex;
47: // We know this map will immediately succeed, as we've already mapped this
48: // copied data on our task thread.
49: HRESULT hr = mTask->mReadbackTexture->Map(0, D3D10_MAP_READ, 0, &mappedTex);
50:
51: if (FAILED(hr)) {
52: mTask->mSink->ProcessReadback(nullptr);
53: }
54:
55: {
56: RefPtr<DataSourceSurface> surf =
57: Factory::CreateWrappingDataSourceSurface((uint8_t*)mappedTex.pData, mappedTex.RowPitch,
58: IntSize(desc.Width, desc.Height),
59: SurfaceFormat::B8G8R8X8);
60:
61: mTask->mSink->ProcessReadback(surf);
62:
63: MOZ_ASSERT(surf->hasOneRef());
64: }
65:
66: mTask->mReadbackTexture->Unmap(0);
67:
68: return NS_OK;
69: }
First lines 47-8 assert that Map cannot fail, but then lines 51-3 attempt to handle failure. However, they do so imcompletely (should there be a "return <some status>;" following line 52? Or has an "else" accidentally been elided from line 54?) leaving lines 57-9 using the uninitialized struct mappedTex. Despite the comments on line 47-8, probably OOM, device failure, and possibly other conditions can cause Map to fail even under the conditions under which Run runs.
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 memory corruption bug in Graphics. Mozilla made it public on 23 August 2015 as CVE-2015-7180.
About Memory corruption
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.