Closed Bug 826980 Opened 12 years ago Closed 11 years ago

Crash with large canvas, stroke

Categories

(Core :: Graphics: Canvas2D, defect)

x86_64
macOS
defect
Not set
critical

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: jruderman, Assigned: u480271)

References

Details

(Keywords: crash, sec-high, testcase)

Crash Data

Attachments

(5 files, 3 obsolete files)

In a debug build: * Under mozilla::dom::CanvasRenderingContext2D::Stroke: * mozilla::gfx::DrawTargetCG::Init encounters OOM, but does not crash * CGBlt_copyBytes (in CoreGraphics) crashes accessing a bogus address In a nightly build: * Might hang.
Attached file stacks (gdb)
Tested on Mac OS X 10.7.5.
If we're really carrying on and then using something we failed to allocate that would be sec-critical bad, but can't tell if that's really the case.
Assignee: nobody → milan
The code is certainly suspect; on the Mac, for instance, we follow the failed "surface size check" with unsigned int width = static_cast<unsigned int>(-1); and on the windows it may assume you have a 1 pixel image running top down. So, I'm probably not reading the code correctly, as it surely can't be this bad.
I don't see mCG initialized to nullptr anywhere in the constructor and it looks like there might be paths where it ends up being used uninitialized. There are asserts that mCG isn't null at a couple of places, but that seems to assume mCG starts out as null (in a couple of places it's checking null as an error return value, but not always).
Keywords: sec-high
Assignee: milan → bgirard
I can still reproduce this bug, so no.
But only on Mac OS X 10.7, not 10.8?
BenWa, have you had a chance to look at this? We're trying to sort critical and high within six weeks of being identified as gfx, and that's tomorrow :-)
Flags: needinfo?(bgirard)
Attached patch patch (obsolete) — Splinter Review
Attachment #715572 - Flags: review?(jmuizelaar)
Flags: needinfo?(bgirard)
Comment on attachment 715572 [details] [diff] [review] patch Review of attachment 715572 [details] [diff] [review]: ----------------------------------------------------------------- ::: gfx/2d/DrawTargetCG.cpp @@ +912,5 @@ > if (aData == nullptr && aType != BACKEND_COREGRAPHICS_ACCELERATED) { > // XXX: Currently, Init implicitly clears, that can often be a waste of time > mData = calloc(aSize.height * aStride, 1); > + if (!mData) { > + mColorSpace = nullptr; This leaks mColorSpace @@ +936,5 @@ > // and we will fallback to software below > mData = nullptr; > } > > if (!mCg || aType == BACKEND_COREGRAPHICS) { The control flow here has become pretty confusing. Please fix it up.
Attachment #715572 - Flags: review?(jmuizelaar) → review-
Did the patch review cycle break down here or something else?
Opps. I'll finish this up!
Attached patch patch (obsolete) — Splinter Review
better control flow.
Attachment #715572 - Attachment is obsolete: true
Attachment #740397 - Flags: review?(jmuizelaar)
Comment on attachment 740397 [details] [diff] [review] patch Review of attachment 740397 [details] [diff] [review]: ----------------------------------------------------------------- ::: gfx/2d/DrawTargetCG.cpp @@ -898,1 @@ > mColorSpace = nullptr; It would be better to split out Init into different functions for the Backend types instead of trying to munge both of them together. Unfortunately we'll need to duplicate the size check. However, I think that's ok. @@ +921,5 @@ > + mColorSpace = nullptr; > + mCg = nullptr; > + mData = nullptr; > + return false; > + } This should move up close to the return at the top of the function.
Attachment #740397 - Flags: review?(jmuizelaar) → review-
Attached patch patch v2 (obsolete) — Splinter Review
Attachment #740397 - Attachment is obsolete: true
Attachment #741885 - Flags: review?(jmuizelaar)
Comment on attachment 741885 [details] [diff] [review] patch v2 Review of attachment 741885 [details] [diff] [review]: ----------------------------------------------------------------- ::: gfx/2d/DrawTargetCG.cpp @@ +189,1 @@ > } You could drop the return nullptr to the bottom of the function avoiding the need to duplicate it.
Attachment #741885 - Flags: review?(jmuizelaar) → review+
Attachment #741885 - Attachment is obsolete: true
Attachment #743195 - Flags: review+
That try job failed. BenWa, are you going to try again?
Flags: needinfo?(bjacob)
Did you mean to CC the other Benoit ? ;-)
Flags: needinfo?(bjacob) → needinfo?(bgirard)
One cannot have too many Benoits but yes.
Benoit *bump* - ready for another try run?
Hey, can we get another try run and maybe get this old sec-high security issue fixed?
Flags: needinfo?(milan)
Is this still a problem? That code has changed since then, and I can't reproduce the crash or the hang.
Flags: needinfo?(milan)
Flags: needinfo?(bgirard)
Jesse, can you still reproduce this?
Flags: needinfo?(jruderman)
Attached file 10.9 stack (lldb)
Yes, the testcase still crashes debug builds for me.
Flags: needinfo?(jruderman)
(In reply to Jesse Ruderman from comment #28) > Created attachment 8338716 [details] > 10.9 stack (lldb) > > Yes, the testcase still crashes debug builds for me. Milan, Jesse, please report to the octagon.
I can still reproduce now that I'm on Mac OS X 10.9, fwiw.
Benoit, are you going to be able to finish this soon, or should we find somebody else? The bug is over a year old.
Flags: needinfo?(bgirard)
This bug is important but I haven't found the time to deal with it. We're pushing an important feature on b2g and I can't find time to look at this. If we can reassign that would be great.
Flags: needinfo?(bgirard)
Is there somebody else who could work on this, Milan? Thanks.
Flags: needinfo?(milan)
Dan, can you reproduce this? I instead just get: Surface size too large (allocation size would overflow int32_t)! message and nothing bad happens. Clean profile?
Assignee: bgirard → dglastonbury
Flags: needinfo?(milan)
I'll take a look at trying to repro.
Tested nightly on OSX 10.6.8 & 10.9.2 as well as a debug build. All builds were fine. Does this bug need to be marked WFM?
Flags: needinfo?(milan)
Can you reproduce still, Jesse?
Flags: needinfo?(jruderman)
Still WFM, but I will try asan build, see what happens.
Flags: needinfo?(milan)
Group: gfx-core-security
I can't reproduce this any more. (Still on 10.9.)
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: needinfo?(jruderman)
Resolution: --- → WORKSFORME
Group: gfx-core-security
Group: core-security → core-security-release
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: