Memory-safety bug in InitTextures
- Fixed in 19 days
- Paid in 26 days
- Disclosed after 19 days
InitTextures (gfx\layers\IMFYCbCrImage.cpp) can cause its callers to use a wild pointer to read and/or write data to memory. This is because it calls IDirect3DSurface9::LockRect without checking the return code. Instead, it checks whether the resulting aLockedRect.pBits member == nullptr. It then returns aLockedRect to its callers, which use its members to read and/or write data into memory that (on success) would be mapped to a GPU buffer.
The problem is that InitTextures receives aLockedRect from its caller, and does not itself initialize it. As it happens, its only known caller (UploadData) passes a reference to an uninitialized automatic D3DLOCKED_RECT to InitTextures. D3DLOCKED_RECT also lacks a constructor, so it does not initialize itself.
The upshot is that if LockRect fails (as under OOM conditions), UploadData will overwrite (probably a considerable amount of) memory at some arbitrary place in Firefox's address space.
116: static bool UploadData(IDirect3DDevice9* aDevice,
117: RefPtr<IDirect3DTexture9>& aTexture,
118: HANDLE& aHandle,
119: uint8_t* aSrc,
120: const gfx::IntSize& aSrcSize,
121: int32_t aSrcStride)
122: {
123: RefPtr<IDirect3DSurface9> surf;
124: D3DLOCKED_RECT rect;
125: aTexture = InitTextures(aDevice, aSrcSize, D3DFMT_A8, surf, aHandle, rect);
126: if (!aTexture) {
127: return false;
128: }
...
59: static TemporaryRef<IDirect3DTexture9>
60: InitTextures(IDirect3DDevice9* aDevice,
61: const IntSize &aSize,
62: _D3DFORMAT aFormat,
63: RefPtr<IDirect3DSurface9>& aSurface,
64: HANDLE& aHandle,
65: D3DLOCKED_RECT& aLockedRect)
66: {
...
92: aSurface->LockRect(&aLockedRect, nullptr, 0);
93: if (!aLockedRect.pBits) {
94: NS_WARNING("Could not lock surface");
95: return nullptr;
96: }
97:
98: return result;
99: }
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 medium-severity security bug in Graphics: Layers. Mozilla made it public on 10 August 2015 as CVE-2015-7177.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.