AddressSanitizer: heap-use-after-free [@ mozilla::layers::CopyableCanvasRenderer::Initialize] with READ of size 8
Categories
(Core :: Graphics: CanvasWebGL, defect)
Tracking
()
People
(Reporter: decoder, Assigned: sotaro)
References
(Blocks 1 open bug)
Details
(5 keywords, Whiteboard: [adv-main66+][adv-esr60.6+])
Attachments
(6 files, 1 external file, 1 obsolete file)
|
19.95 KB,
text/plain
|
Details | |
|
355 bytes,
text/html
|
Details | |
|
143.85 KB,
application/octet-stream
|
Details | |
|
13.19 KB,
text/plain
|
Details | |
|
7.85 KB,
patch
|
RyanVM
:
approval-mozilla-esr60+
|
Details | Diff | Splinter Review |
|
7.80 KB,
patch
|
RyanVM
:
approval-mozilla-beta+
|
Details | Diff | Splinter Review |
| Reporter | ||
Comment 1•7 years ago
|
||
| Reporter | ||
Updated•7 years ago
|
| Reporter | ||
Comment 3•7 years ago
|
||
Updated•7 years ago
|
Comment 4•7 years ago
|
||
Comment 5•7 years ago
|
||
| Reporter | ||
Comment 6•7 years ago
|
||
Updated•7 years ago
|
Comment 8•7 years ago
|
||
| Reporter | ||
Comment 9•7 years ago
|
||
Updated•7 years ago
|
Comment 11•7 years ago
|
||
Comment 12•7 years ago
|
||
Comment 13•7 years ago
|
||
Updated•7 years ago
|
Comment 14•7 years ago
|
||
Comment 15•7 years ago
|
||
Comment 17•7 years ago
|
||
I tested the testcase.html againg on my Windows 10 PC and it still crashes the latest Firefox Nightly 66.0a1 (2019-01-07)(64-bit).
I also submitted the crash report:
https://crash-stats.mozilla.org/report/index/3de995cc-66f0-4778-86b4-a4d7d0190108
Is this bug not going to be fixed ?
Updated•7 years ago
|
Comment 19•7 years ago
|
||
This doesn't seem to crash without PageHeap enabled: I haven't installed it, and I can't repro with the attached testcase.
Comment 20•7 years ago
|
||
Ok, I bet I see it:
https://hg.mozilla.org/mozilla-central/annotate/aac6849c6ff0eb4981b569988a094f04e42f14dd/dom/canvas/WebGLContext.cpp#l1195
CanvasInitializeData data;
...
data.mGLContext = gl;
data.mSize = DrawingBufferSize(); // This can destroygl!
...
aRenderer->Initialize(data); // Tries to call data.mGLContext->AddRef(), UAF.
Comment 21•7 years ago
|
||
Comment 22•7 years ago
|
||
Comment on attachment 9035833 [details]
Bug 1506665 - CanvasInitializeData should use RefPtrs. -
[Security Approval Request]
How easily could an exploit be constructed based on the patch?: Relatively hard.
Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?: No
Which older supported branches are affected by this flaw?: 59+
If not all supported branches, which bug introduced the flaw?: None
Do you have backports for the affected branches?: No
If not, how different, hard to create, and risky will they be?: Very easy.
How likely is this patch to cause regressions; how much testing does it need?: Very unlikely to cause regressions.
Comment 23•7 years ago
|
||
Please test:
https://queue.taskcluster.net/v1/task/DFvTlUjLRiimXO0R5F5w8w/runs/0/artifacts/public/build/target.zip
Comment 24•7 years ago
|
||
I tested the testcase.html with the firefox version inside target.zip an it still crashes...
Updated•7 years ago
|
Comment 25•7 years ago
|
||
Well, setting pageheap on globally makes my machine fail to start.
| Reporter | ||
Comment 26•7 years ago
|
||
(In reply to Jeff Gilbert [:jgilbert] from comment #25)
Well, setting pageheap on globally makes my machine fail to start.
I am not sure what the need for pageheap here is, we do have ASan builds for Windows and Linux and they can both also be built on try or locally. If you need help doing so, please let me know :)
Comment 27•7 years ago
|
||
I never have had a smooth experience with getting asan builds running, and building takes a while, so trying to get pageheap running to trigger the failure (as reported) was worth trying.
However, I can't get that to work, so now I'll try with asan builds.
Comment 28•7 years ago
|
||
Comment on attachment 9035833 [details]
Bug 1506665 - CanvasInitializeData should use RefPtrs. -
Clearing sec-approval request until we know that the patch fixes the issue.
Comment 29•7 years ago
|
||
This isn't going to make Fx65 at this point with the RC coming next week :(
Comment 30•7 years ago
|
||
Any News about this bug ?
Firefox Nightly 67.0a1 (2019-01-31) (64-bit) still crashes.
Comment 31•7 years ago
|
||
(In reply to Aral Yaman from comment #24)
I tested the testcase.html with the firefox version inside target.zip an it still crashes...
Can you give me a crash report or at least a crash stack for where this crashes?
No one else can seem to reliably reproduce this.
Comment 32•7 years ago
|
||
I posted already a crash report:
https://crash-stats.mozilla.org/report/index/3de995cc-66f0-4778-86b4-a4d7d0190108
To reproduce the crash it is important that page heap is enabled.
Hope this helps otherwise let me know if I should provode more information
Comment 33•7 years ago
|
||
That's not the crash report with target.zip from the link I posted, is it?
I cannot enable page heap, so you need to do this test for me.
Comment 34•7 years ago
|
||
No it was a previous crash report.
Now I submitted a crash report from target.zip
See here: https://crash-stats.mozilla.org/report/index/a2f8a6d1-80f2-4b5f-9681-7f2500190201
Comment 35•7 years ago
|
||
Comment 36•7 years ago
|
||
The crash report looks not very useful so I tried to get some more information in WinDbg and attached the log file firefox-debug_3c78_2019-02-01_08-05-19-073.log
But I think I have a problem for getting sybol files.
Do you think this log can help you more or could you give me an instruction how I can get the symbol file information ?
I followed the instructions from here: https://developer.mozilla.org/en-US/docs/Mozilla/How_to_get_a_stacktrace_with_WinDbg
Updated•7 years ago
|
| Assignee | ||
Comment 37•7 years ago
|
||
I could reliably reproduce the crash like the following STR on my Win10 pc.
[1] Open attachment 9025361 [details]
[2] Reload the tab.
[3] Move to another tab.
[4] Move back to the tab of attachment 9025361 [details]
Repeat [2]-[4] if the crash did not happen.
| Assignee | ||
Comment 38•7 years ago
|
||
I could reproduce the crash with local build. I am going to look into it tomorrow.
| Assignee | ||
Comment 39•7 years ago
|
||
When the crash happened, WebGLContext::InitializeCanvasRenderer() destroyed GLContextEGL under WebGLContext::DrawingBufferSize(). The DrawingBufferSize() calls WebGLContext::EnsureDefaultFB(), but it failed to allocate backbuffer. Then GLContextEGL was destroyed.
Before calling the DrawingBufferSize(), CanvasInitializeData::mGLContext stored raw pointer. Then DrawingBufferSize() call destroyed the GLContextEGL, and mGLContext became stale pointer.
Updated•7 years ago
|
| Assignee | ||
Comment 40•7 years ago
•
|
||
When WebGLContext::SetDimensions() was called, if mRequestedSize was different from size of DefaultFB and GLContext already existed, the SetDimensions() just cleared mDefaultFB, the mDefaultFB was allocaed again when it became necessary next time. Then DrawingBufferSize() tried to allocate DefaultFB in WebGLContext::InitializeCanvasRenderer() as in Comment 39.
| Assignee | ||
Comment 41•7 years ago
|
||
| Assignee | ||
Comment 42•7 years ago
|
||
I confirmed that attachment 9043509 [details] addressed the problem of comment 0 and comment 1. Though there were still crash that were caused by oom. The oom crash is not related to this bug.
| Assignee | ||
Comment 43•7 years ago
•
|
||
Crash happened with attachment 9035833 [details].
Crash happened in ShareableCanvasRenderer::Initialize(). Null pointer access happened since gl::GLScreenBuffer* screen = mGLContext->Screen() was nullptr. mGLContext was destroyed because of EnsureDefaultFB() failure, it caused the nullptr.
Comment 44•7 years ago
|
||
Ok, cool!
Can you fix that too?
I would rather update our layers code to handle a destroyed GLContext, rather than patching just the issue in ShareableCanvasRenderer::Initialize().
| Assignee | ||
Comment 45•7 years ago
•
|
||
(In reply to Jeff Gilbert [:jgilbert] from comment #44)
I would rather update our layers code to handle a destroyed GLContext, rather than patching just the issue in ShareableCanvasRenderer::Initialize().
Yea, patching in ShareableCanvasRenderer::Initialize() is not good. I am going to update the patch, but it should not happen by change of WebGLContext::InitializeCanvasRenderer().
| Assignee | ||
Comment 48•7 years ago
|
||
I already updated the patch. Can you comment to the patch?
Updated•7 years ago
|
Updated•7 years ago
|
| Assignee | ||
Comment 49•7 years ago
|
||
attachment 9043509 [details] also addressed content process crash.
| Assignee | ||
Comment 50•7 years ago
•
|
||
Comment on attachment 9043509 [details]
Bug 1506665 - Add more GLContext failure handling
Security Approval Request
- How easily could an exploit be constructed based on the patch?: It seems not easy, but it might be possible to construct.
- Do comments in the patch, the check-in comment, or tests included in the patch paint a bulls-eye on the security problem?: No
- Which older supported branches are affected by this flaw?: Firefox 59
- If not all supported branches, which bug introduced the flaw?: Bug 1427668
- Do you have backports for the affected branches?: No
- If not, how different, hard to create, and risky will they be?: It is not difficult. Risk is same to the current path.
- How likely is this patch to cause regressions; how much testing does it need?: I locally tested with Bug 1506665 Comment 37. The patch addressed Tab crashes for me. There might still exist a route to cause nullptr GLContext access.
Testing with Bug 1506665 Comment 37 seems necessary.
Updated•7 years ago
|
Updated•7 years ago
|
| Assignee | ||
Comment 51•7 years ago
|
||
| Assignee | ||
Comment 52•7 years ago
|
||
| Assignee | ||
Updated•7 years ago
|
Updated•7 years ago
|
Comment 53•7 years ago
|
||
Comment on attachment 9043509 [details]
Bug 1506665 - Add more GLContext failure handling
sec-approval+ for trunk. We'll want this patched on all affected branches so we'll want Beta and ESR60 patches made and nominated.
| Assignee | ||
Comment 54•7 years ago
|
||
On beta, patch for m-c(attachment 9043509 [details]) could be applied. attachment 9046963 [details] [diff] [review] is for esr60.
| Assignee | ||
Comment 55•7 years ago
|
||
Comment on attachment 9043509 [details]
Bug 1506665 - Add more GLContext failure handling
Beta/Release Uplift Approval Request
- Feature/Bug causing the regression: Bug 1427668
- User impact if declined: Tab could crash in a STR like Bug 1506665 Comment 37.
- Is this code covered by automated tests?: Yes
- Has the fix been verified in Nightly?: No
- Needs manual test from QE?: Yes
- If yes, steps to reproduce: The step is in Bug 1506665 Comment 37.
- List of other uplifts needed: None
- Risk to taking this patch: Medium
- Why is the change risky/not risky? (and alternatives if risky): The patch fixes UAF bug. But there might still exist a route to cause nullptr GLContext access. Though I addressed some nullptr GLContext accesses.
I nominate the patch to Beta and ESR60 before landing to m-c because it was requested by Bug 1506665 Comment 53.
- String changes made/needed: None
ESR Uplift Approval Request
- If this is not a sec:{high,crit} bug, please state case for ESR consideration: Tab could crash in a STR like Bug 1506665 Comment 37.
- User impact if declined: Tab could crash in a STR like Bug 1506665 Comment 37.
- Fix Landed on Version: Not yet landed to m-c
- Risk to taking this patch: Medium
- Why is the change risky/not risky? (and alternatives if risky): The patch fixes UAF bug. But there might still exist a route to cause nullptr GLContext access. Though I addressed some nullptr GLContext accesses.
I nominate the patch to Beta and ESR60 before landing to m-c because it was requested by Bug 1506665 Comment 53.
- String or UUID changes made by this patch: None
Comment 56•7 years ago
|
||
Details: We're sorry, Autoland could not rebase your commits for you automatically. Please manually rebase your commits and try again. (255, 'applying /tmp/tmps6sb8i\npatching file gfx/layers/CanvasRenderer.h\nHunk #1 FAILED at 27\n1 out of 1 hunks FAILED -- saving rejects to file gfx/layers/CanvasRenderer.h.rej\nabort: patch failed to apply', '')
| Assignee | ||
Comment 57•7 years ago
|
||
It was caused by Bug 1530471. I am going to update the patch.
Updated•7 years ago
|
| Assignee | ||
Comment 58•7 years ago
|
||
Comment 60•7 years ago
|
||
Comment 61•7 years ago
|
||
Updated•7 years ago
|
Updated•7 years ago
|
Comment 62•7 years ago
|
||
Issue was reproduced with Nightly 67.0a1 (2019-01-31)(64-bit) on Windows 10 Pro x64.
Verified as fixed with Nightly 67.oa1 (2019-03-03).
Updated•7 years ago
|
Comment 63•7 years ago
|
||
Awarding a bug bounty for this report.
Aral: can you confirm that this fixes the problem for you? This patch should be in ASAN nightlies now.
Comment 64•7 years ago
|
||
I tested with the latest Nightly 67.0a1 (2019-03-04) and can confirm that it does not crash anymore!
Comment 65•7 years ago
|
||
Comment on attachment 9043509 [details]
Bug 1506665 - Add more GLContext failure handling
Fixes a WebGL sec issue. Verified by QA and the reporter. Approved for 66.0b14 and 60.6esr.
Updated•7 years ago
|
Updated•7 years ago
|
Comment 66•7 years ago
|
||
| uplift | ||
Comment 67•7 years ago
|
||
Verified the issue as fixed with 66.0b14 on Windows 10x64.
Updated•7 years ago
|
Updated•7 years ago
|
Comment 68•7 years ago
|
||
The issue is verified as fixed with 60.6esr on Windows 10x64.
Updated•7 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Updated•2 years ago
|
Description
•