Closed
Bug 1182908
Opened 11 years ago
Closed 5 years ago
InsertD3D11FormatInfo can read beyond end of swizzleMap
Categories
(Core :: Graphics, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: q1, Unassigned)
References
Details
(Keywords: reporter-external, sec-moderate)
Attachments
(1 file)
|
1.64 KB,
patch
|
jrmuizel
:
review+
ritu
:
approval-mozilla-release-
|
Details | Diff | Splinter Review |
InsertD3D11FormatInfo (gfx\angle\src\libGLESv2\renderer\d3d\d3d11\formatutils11.cpp) does not, in the release version, check whether its swizzleIter != swizzleMap () end before dereferencing it:
687: static const SwizzleInfoMap swizzleMap = BuildSwizzleInfoMap();
688: SwizzleInfoMap::const_iterator swizzleIter = swizzleMap.find(SwizzleSizeType(maxBits, formatInfo.componentType));
689: ASSERT(swizzleIter != swizzleMap.end());
690:
691: const SwizzleFormatInfo &swizzleInfo = swizzleIter->second;
692: info.swizzleTexFormat = swizzleInfo.mTexFormat;
693: info.swizzleSRVFormat = swizzleInfo.mSRVFormat;
694: info.swizzleRTVFormat = swizzleInfo.mRTVFormat;
This can cause the function to read an element beyond the map's end, with unknown consequences.
I found this bug when the assert fired under 36.0.1 debug when testing WebGL with a new video card (NVIDIA GeForce GT 610 GPU, NVIDIA drivers 353.06, Win7 SP1 x64). I was visiting https://developer.cdn.mozilla.net/media/uploads/demos/j/c/jcarpenter/5ba2bcfa7e453d50149ba76819a02ec2/the-polar-sea_1415735678_demo_package/index.html , and got the following stack trace:
> msvcr120.dll!675f7cbd() Unknown [this is _wassert]
[Frames below may be incorrect and/or missing, no symbols loaded for msvcr120.dll]
libGLESv2.dll!rx::d3d11::InsertD3D11FormatInfo(std::map<unsigned int,rx::d3d11::TextureFormat,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,rx::d3d11::TextureFormat> > > * map, unsigned int internalFormat, DXGI_FORMAT texFormat, DXGI_FORMAT srvFormat, DXGI_FORMAT rtvFormat, DXGI_FORMAT dsvFormat) Line 687 C++
libGLESv2.dll!rx::d3d11::BuildD3D11FormatMap() Line 817 C++
libGLESv2.dll!rx::d3d11::GetTextureFormatInfo(unsigned int internalFormat) Line 851 C++
libGLESv2.dll!rx::d3d11_gl::GenerateTextureFormatCaps(unsigned int internalFormat, ID3D11Device * device) Line 233 C++
libGLESv2.dll!rx::d3d11_gl::GenerateCaps(ID3D11Device * device, gl::Caps * caps, gl::TextureCapsMap * textureCapsMap, gl::Extensions * extensions) Line 864 C++
libGLESv2.dll!rx::Renderer11::generateCaps(gl::Caps * outCaps, gl::TextureCapsMap * outTextureCaps, gl::Extensions * outExtensions) Line 3130 C++
libGLESv2.dll!rx::Renderer::getRendererCaps() Line 55 C++
libGLESv2.dll!rx::Blit11::Blit11(rx::Renderer11 * renderer) Line 188 C++
libGLESv2.dll!rx::Renderer11::initializeDevice() Line 312 C++
libGLESv2.dll!rx::Renderer11::initialize() Line 296 C++
libGLESv2.dll!glCreateRenderer(egl::Display * display, HDC__ * nativeDisplay, int requestedDisplayType) Line 155 C++
libEGL.dll!egl::Display::initialize() Line 81 C++
libEGL.dll!eglInitialize(void * dpy, int * major, int * minor) Line 187 C++
xul.dll!mozilla::gl::GLLibraryEGL::fInitialize(void * dpy, int * major, int * minor) Line 248 C++
xul.dll!mozilla::gl::GetAndInitDisplay(mozilla::gl::GLLibraryEGL & egl, void * displayType) Line 109 C++
xul.dll!mozilla::gl::GLLibraryEGL::EnsureInitialized() Line 274 C++
xul.dll!mozilla::gl::GLContextProviderEGL::CreateHeadless() Line 883 C++
xul.dll!CreateHeadlessANGLE(bool forceEnabled, const nsCOMPtr<nsIGfxInfo> & gfxInfo, mozilla::WebGLContext * webgl) Line 525 C++
xul.dll!CreateHeadlessGL(bool forceEnabled, const nsCOMPtr<nsIGfxInfo> & gfxInfo, mozilla::WebGLContext * webgl) Line 571 C++
xul.dll!mozilla::WebGLContext::CreateOffscreenGL(bool forceEnabled) Line 698 C++
xul.dll!mozilla::WebGLContext::SetDimensions(int signedWidth, int signedHeight) Line 851 C++
xul.dll!mozilla::dom::HTMLCanvasElement::UpdateContext(JSContext * aCx, JS::Handle<JS::Value> aNewContextOptions) Line 839 C++
xul.dll!mozilla::dom::HTMLCanvasElement::GetContext(JSContext * aCx, const nsAString_internal & aContextId, JS::Handle<JS::Value> aContextOptions, mozilla::ErrorResult & rv) Line 763 C++
xul.dll!mozilla::dom::HTMLCanvasElementBinding::getContext(JSContext * cx, JS::Handle<JSObject *> obj, mozilla::dom::HTMLCanvasElement * self, const JSJitMethodCallArgs & args) Line 215 C++
xul.dll!mozilla::dom::GenericBindingMethod(JSContext * cx, unsigned int argc, JS::Value * vp) Line 2434 C++
xul.dll!js::CallJSNative(JSContext * cx, bool (JSContext *, unsigned int, JS::Value *) * native, const JS::CallArgs & args) Line 231 C++
xul.dll!js::Invoke(JSContext * cx, JS::CallArgs args, js::MaybeConstruct construct) Line 484 C++
xul.dll!Interpret(JSContext * cx, js::RunState & state) Line 2541 C++
xul.dll!js::RunScript(JSContext * cx, js::RunState & state) Line 434 C++
xul.dll!js::ExecuteKernel(JSContext * cx, JS::Handle<JSScript *> script, JSObject & scopeChainArg, const JS::Value & thisv, js::ExecuteType type, js::AbstractFramePtr evalInFrame, JS::Value * result) Line 643 C++
xul.dll!js::Execute(JSContext * cx, JS::Handle<JSScript *> script, JSObject & scopeChainArg, JS::Value * rval) Line 680 C++
xul.dll!Evaluate(JSContext * cx, JS::Handle<JSObject *> obj, const JS::ReadOnlyCompileOptions & optionsArg, JS::SourceBufferHolder & srcBuf, JS::MutableHandle<JS::Value> rval) Line 4791 C++
xul.dll!Evaluate(JSContext * cx, JS::AutoObjectVector & scopeChain, const JS::ReadOnlyCompileOptions & optionsArg, JS::SourceBufferHolder & srcBuf, JS::MutableHandle<JS::Value> rval) Line 4817 C++
xul.dll!JS::Evaluate(JSContext * cx, JS::AutoObjectVector & scopeChain, const JS::ReadOnlyCompileOptions & optionsArg, JS::SourceBufferHolder & srcBuf, JS::MutableHandle<JS::Value> rval) Line 4872 C++
xul.dll!nsJSUtils::EvaluateString(JSContext * aCx, JS::SourceBufferHolder & aSrcBuf, JS::Handle<JSObject *> aEvaluationGlobal, JS::CompileOptions & aCompileOptions, const nsJSUtils::EvaluateOptions & aEvaluateOptions, JS::MutableHandle<JS::Value> aRetValue, void * * aOffThreadToken) Line 256 C++
xul.dll!nsJSUtils::EvaluateString(JSContext * aCx, JS::SourceBufferHolder & aSrcBuf, JS::Handle<JSObject *> aEvaluationGlobal, JS::CompileOptions & aCompileOptions, void * * aOffThreadToken) Line 329 C++
xul.dll!nsScriptLoader::EvaluateScript(nsScriptLoadRequest * aRequest, JS::SourceBufferHolder & aSrcBuf, void * * aOffThreadToken) Line 1144 C++
xul.dll!nsScriptLoader::ProcessRequest(nsScriptLoadRequest * aRequest, void * * aOffThreadToken) Line 973 C++
xul.dll!nsScriptLoader::ProcessScriptElement(nsIScriptElement * aElement) Line 781 C++
xul.dll!nsScriptElement::MaybeProcessScript() Line 140 C++
xul.dll!nsIScriptElement::AttemptToExecute() Line 220 C++
xul.dll!nsHtml5TreeOpExecutor::RunScript(nsIContent * aScriptElement) Line 663 C++
xul.dll!nsHtml5TreeOpExecutor::RunFlushLoop() Line 491 C++
xul.dll!nsHtml5ExecutorReflusher::Run() Line 56 C++
xul.dll!nsThread::ProcessNextEvent(bool aMayWait, bool * aResult) Line 830 C++
xul.dll!NS_ProcessNextEvent(nsIThread * aThread, bool aMayWait) Line 265 C++
xul.dll!mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate * aDelegate) Line 99 C++
xul.dll!MessageLoop::RunInternal() Line 234 C++
xul.dll!MessageLoop::RunHandler() Line 227 C++
xul.dll!MessageLoop::Run() Line 201 C++
xul.dll!nsBaseAppShell::Run() Line 166 C++
xul.dll!nsAppShell::Run() Line 178 C++
xul.dll!nsAppStartup::Run() Line 281 C++
xul.dll!XREMain::XRE_mainRun() Line 4220 C++
xul.dll!XREMain::XRE_main(int argc, char * * argv, const nsXREAppData * aAppData) Line 4296 C++
xul.dll!XRE_main(int argc, char * * argv, const nsXREAppData * aAppData, unsigned int aFlags) Line 4516 C++
firefox.exe!do_main(int argc, char * * argv, nsIFile * xreDirectory) Line 292 C++
firefox.exe!NS_internal_main(int argc, char * * argv) Line 661 C++
firefox.exe!wmain(int argc, wchar_t * * argv) Line 117 C++
[External Code]
Tracing this code under 39.0 release (on the same system) shows that swizzleIter never == swizzleMap.end(), presumably due to some other change.
The lack of a release-version failout is a bug unless it's now impossible for external code (e.g., a video driver) to cause InsertD3D11FormatInfo to go off the map's end.
Updated•11 years ago
|
Flags: sec-bounty?
Comment 2•11 years ago
|
||
Does this actually affect Firefox?
(In reply to Al Billings [:abillings] from comment #2)
> Does this actually affect Firefox?
I found this bug when the relevant assert fired in a debug build of 36.0.1. I haven't seen it since, but I haven't tested for it either. The bug is still present in the 40.0 sources. I guess that changes to/bugs in a video driver can cause this bug to manifest.
I don't know what are the consequences of reading beyond the end of swizzleMap are. It can at least crash Firefox, and possibly cause some other malfunction and/or leak data from one context into another.
Comment 5•11 years ago
|
||
Has it been filed upstream with ANGLE?
(In reply to Milan Sreckovic [:milan] from comment #5)
> Has it been filed upstream with ANGLE?
I haven't done this, but will do so -- and post the bug link here -- later today. The bug is still present in the tip-of-tree Angle: https://github.com/google/angle/blob/master/src/libANGLE/renderer/d3d/d3d11/formatutils11.cpp .
Updated•11 years ago
|
Group: core-security → gfx-core-security
Updated•11 years ago
|
Updated•11 years ago
|
Flags: needinfo?(jmuizelaar)
Comment 8•11 years ago
|
||
does iter==end mean the map is empty? is there some other way to get that condition? guessing sec-moderate because this looks like a minor out of bounds read of integer values, not pointers or anything that would be easy to interpret back out of displayed value. But if this leads to more reading or especially writing out of bounds it could be a higher rating.
Keywords: sec-moderate
(In reply to Daniel Veditz [:dveditz] from comment #8)
> does iter==end mean the map is empty? is there some other way to get that
> condition?
Line 688 attempts to find a given entry in swizzleMap, which the assert on line 689 indicates should always be there. But if it isn't, as when the assert tripped for me, it could -- but doesn't necessarily mean -- that the map is entirely empty. I seem to recall that it was not empty, and it really can't be empty unless FF is OOM, because BuildSwizzleInfoMap called on line 687 is a simple series of map.insert calls.
> guessing sec-moderate because this looks like a minor out of
> bounds read of integer values, not pointers or anything that would be easy
> to interpret back out of displayed value.
Yes, the values read are DXGI_FORMAT enums.
> But if this leads to more reading or especially writing out of bounds it could be a higher rating.
There might be some other code that does that, but I don't know of any right now.
Updated•11 years ago
|
Flags: sec-bounty? → sec-bounty+
Updated•10 years ago
|
Assignee: nobody → dvander
It looks like this has been long-since fixed in upstream angle, which is also the angle we use in Firefox 44+. So this only affects the release channel right now.
Given that this is unlikely to be very serious, and we're just 19 days from another release, it might not be worth pursuing. But just in case here's the patch.
Attachment #8705033 -
Flags: review?(jmuizelaar)
Updated•10 years ago
|
Status: NEW → ASSIGNED
Comment 11•10 years ago
|
||
Comment on attachment 8705033 [details] [diff] [review]
fix
Review of attachment 8705033 [details] [diff] [review]:
-----------------------------------------------------------------
Is this same fix as in upstream ANGLE?
(In reply to Jeff Muizelaar [:jrmuizel] from comment #11)
> Comment on attachment 8705033 [details] [diff] [review]
> fix
>
> Review of attachment 8705033 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> Is this same fix as in upstream ANGLE?
Yes.
Comment 13•10 years ago
|
||
Comment on attachment 8705033 [details] [diff] [review]
fix
Review of attachment 8705033 [details] [diff] [review]:
-----------------------------------------------------------------
Is this same fix as in upstream ANGLE?
Attachment #8705033 -
Flags: review?(jmuizelaar) → review+
Updated•10 years ago
|
Attachment #8705033 -
Flags: approval-mozilla-release?
Comment 14•10 years ago
|
||
Comment on attachment 8705033 [details] [diff] [review]
fix
Could you please fill out the uplift request template? This will help me understand how easily exploitable is this issue and what kind of test coverage was done on the patch as well as the risks associated.
As such, given that we are in RC week for Fx44, I do not think sec-moderates meet the bar.
Attachment #8705033 -
Flags: approval-mozilla-release? → approval-mozilla-release-
Sounds like this is WONTFIX then.
Updated•5 years ago
|
Assignee: dvander → nobody
Status: ASSIGNED → NEW
Comment 16•5 years ago
|
||
Fixed by angle updates.
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Updated•5 years ago
|
Group: gfx-core-security → core-security-release
Updated•5 years ago
|
Group: core-security-release
Updated•2 years ago
|
Keywords: reporter-external
You need to log in
before you can comment on or make changes to this bug.
Description
•