Closed
Bug 1438917
Opened 8 years ago
Closed 8 years ago
Possible integer overflow in GrResourceCache::changeUniqueKey
Categories
(Core :: Graphics, defect, P3)
Tracking
()
RESOLVED
FIXED
mozilla61
People
(Reporter: mccr8, Assigned: lsalzman)
Details
(Keywords: crash, csectype-intoverflow, sec-audit, Whiteboard: [gfx-noted][adv-main60-][post-critsmash-triage])
Crash Data
Attachments
(1 file)
|
1.59 KB,
patch
|
jrmuizel
:
review+
RyanVM
:
approval-mozilla-beta+
|
Details | Diff | Splinter Review |
This bug was filed from the Socorro interface and is
report bp-cde464fd-6aea-4a3d-8341-4fff90180215.
=============================================================
Top 10 frames of crashing thread:
0 libmozglue.dylib mozalloc_abort memory/mozalloc/mozalloc_abort.cpp:33
1 libmozglue.dylib mozalloc_handle_oom memory/mozalloc/mozalloc_oom.cpp:54
2 libmozglue.dylib moz_xcalloc memory/mozalloc/mozalloc.cpp:84
3 XUL GrResourceCache::changeUniqueKey gfx/skia/skia/src/core/SkTDynamicHash.h:256
4 XUL GrClipStackClip::createSoftwareClipMask const gfx/skia/skia/src/gpu/GrClipStackClip.cpp:485
5 XUL GrClipStackClip::apply const gfx/skia/skia/src/gpu/GrClipStackClip.cpp:319
6 XUL GrRenderTargetContext::addLegacyMeshDrawOp gfx/skia/skia/src/gpu/GrRenderTargetContext.cpp:1630
7 XUL GrSmallPathRenderer::onDrawPath gfx/skia/skia/src/gpu/ops/GrSmallPathRenderer.cpp:769
8 XUL GrRenderTargetContext::internalDrawPath gfx/skia/skia/src/gpu/GrPathRenderer.h:174
9 XUL GrRenderTargetContext::drawPath gfx/skia/skia/src/gpu/GrRenderTargetContext.cpp:1385
=============================================================
I came across this crash on Nightly, on this line:
fArray = (T**)sk_calloc_throw(sizeof(T*) * fCapacity);
This is an OOM crash, and the allocation size is 18,446,744,056,529,682,432 bytes, which leads me to think that there's an integer overflow here.
I also see another one like this, on 59:
bp-6d60fdbe-a90f-430e-bfbd-d9f920180215
Maybe somebody was just running a test case from a Skia security bug or something, though I don't see any other bugs with changeUniqueKey in the summary.
In the middle of updating Skia, it'd be interesting to see if this is around after that gets updated.
Whiteboard: [gfx-noted]
Comment 2•8 years ago
|
||
Note: that value is 0xFFFFFFFC00000000
Updated•8 years ago
|
Priority: -- → P3
| Assignee | ||
Comment 3•8 years ago
|
||
fCapacity here can overflow to become negative, which then can cause a crash downwind in sk_calloc_throw. fCapacity can only be a power of two, so the overflow value will be exactly 2^31, which is INT_MIN.
In practice, this negative value will be cast to an unsigned size_t value, then multiplied by sizeof(T*) which is either 4 or 8. On 64 bit systems this will simply cause sk_calloc_throw to trigger an exception, which is not exploitable.
On 32 bit systems, size_t(INT_MIN) * sizeof(T*) will become 0. However, due to the fact that fCapacity is thusly set to negative, and find/add/remove routines are guarded by index < fCapacity checks, this should not be practically exploitable there either beyond just triggering debug asserts and/or a release crash.
So this is mostly a correctness fix that ensures we assert up front rather than just crashing in various ways downwind.
Updated•8 years ago
|
Attachment #8958155 -
Flags: review?(jmuizelaar) → review+
| Assignee | ||
Comment 4•8 years ago
|
||
Comment on attachment 8958155 [details] [diff] [review]
limit allocations in SkTDynamicHash
[Security approval request comment]
> How easily could an exploit be constructed based on the patch?
No known exploit yet besides above crash.
> Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?
Nothing specific.
> Which older supported branches are affected by this flaw?
All.
> Do you have backports for the affected branches? If not, how different, hard to create, and risky will they be?
Depends on machinery from Skia m66 update in bug 1444506.
> How likely is this patch to cause regressions; how much testing does it need?
Unlikely, just trades overflow for an assert.
Attachment #8958155 -
Flags: sec-approval?
Comment 5•8 years ago
|
||
As a sec-audit, this doesn't need sec-approval to go in.
Updated•8 years ago
|
Attachment #8958155 -
Flags: sec-approval?
Comment 6•8 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/49bbe768f2389958b159bad3db913d1d0a893323
https://hg.mozilla.org/mozilla-central/rev/49bbe768f238
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-firefox61:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → Future
Comment 7•8 years ago
|
||
Please nominate this for Beta approval when you're comfortable doing so.
status-firefox59:
--- → wontfix
status-firefox60:
--- → affected
status-firefox-esr52:
--- → wontfix
Flags: needinfo?(lsalzman)
Target Milestone: Future → mozilla61
| Assignee | ||
Comment 8•8 years ago
|
||
Comment on attachment 8958155 [details] [diff] [review]
limit allocations in SkTDynamicHash
Approval Request Comment
[Feature/Bug causing the regression]: Pre-existing.
[User impact if declined]: Possible overflows, undefined behavior, and crashes.
[Is this code covered by automated tests?]: Yes
[Has the fix been verified in Nightly?]: Yes
[Needs manual test from QE? If yes, steps to reproduce]: No
[List of other uplifts needed for the feature/fix]:
[Is the change risky?]: No
[Why is the change risky/not risky?]: Just guards a potential security exploit with an assert.
[String changes made/needed]: None
Flags: needinfo?(lsalzman)
Attachment #8958155 -
Flags: approval-mozilla-beta?
Comment 9•8 years ago
|
||
Comment on attachment 8958155 [details] [diff] [review]
limit allocations in SkTDynamicHash
Approved for 60.0b6
Attachment #8958155 -
Flags: approval-mozilla-beta? → approval-mozilla-beta+
Comment 10•8 years ago
|
||
| uplift | ||
Updated•8 years ago
|
Group: gfx-core-security → core-security-release
Updated•8 years ago
|
Whiteboard: [gfx-noted] → [gfx-noted][adv-main60-]
Updated•8 years ago
|
Flags: qe-verify-
Whiteboard: [gfx-noted][adv-main60-] → [gfx-noted][adv-main60-][post-critsmash-triage]
Updated•7 years ago
|
Group: core-security-release
You need to log in
before you can comment on or make changes to this bug.
Description
•