Closed Bug 1744460 Opened 3 years ago Closed 3 years ago

Windows 32-bit build Crash in [@ w2c_memset]

Categories

(Core :: Security: RLBox, defect)

x86
Windows
defect

Tracking

()

VERIFIED FIXED
97 Branch
Tracking Status
firefox-esr91 --- unaffected
firefox94 --- unaffected
firefox95 --- unaffected
firefox96 + verified
firefox97 --- verified

People

(Reporter: aryx, Assigned: shravanrn)

References

(Regression)

Details

(Keywords: crash, regression)

Crash Data

Attachments

(2 files)

Firefox Nightly 96.0a1 20211204215420, 32-bit version

https://council.gwangju.go.kr/index.do crashes trying to load a web font. Deian, could you take a look?

Crash report: https://crash-stats.mozilla.org/report/index/ce9bd866-e349-4b3c-a7d6-320730211205

Reason: EXCEPTION_ACCESS_VIOLATION_WRITE

Top 10 frames of crashing thread:

0 xul.dll w2c_memset security/rlbox/rlbox.wasm.c:661399
1 xul.dll w2c_RLBoxConvertWOFF2ToTTF security/rlbox/rlbox.wasm.c:229877
2 xul.dll rlbox::rlbox_sandbox<rlbox::rlbox_wasm2c_sandbox>::INTERNAL_invoke_with_func_ptr<bool  third_party/rlbox/include/rlbox_sandbox.hpp:790
3 xul.dll RLBoxProcessWOFF2 gfx/ots/RLBoxWOFF2Host.cpp:168
4 xul.dll ots::OTSContext::Process gfx/ots/src/ots.cc:1084
5 xul.dll gfxOTSMessageContext::Process gfx/thebes/gfxUserFontSet.cpp:168
6 xul.dll gfxUserFontEntry::SanitizeOpenTypeData gfx/thebes/gfxUserFontSet.cpp:199
7 xul.dll gfxUserFontEntry::StartPlatformFontLoadOnBackgroundThread gfx/thebes/gfxUserFontSet.cpp:637
8 xul.dll static mozilla::detail::RunnableMethodArguments<unsigned int, const unsigned char*, unsigned int, nsMainThreadPtrHandle<nsIFontLoadCompleteCallback> >::applyImpl<gfxUserFontEntry, void  xpcom/threads/nsThreadUtils.h:1147
9 xul.dll mozilla::detail::RunnableMethodImpl<gfxUserFontEntry*, void  xpcom/threads/nsThreadUtils.h:1200
Flags: needinfo?(deian)

Upon investigation, it looks like this is an oom ... this happened when decompressing a font whose decompressed size is 17mb (which OOMs the 16MB sandbox default on 32-bit platforms)

  1. this call here https://searchfox.org/mozilla-central/source/gfx/ots/RLBoxWOFF2Host.cpp#170 passes in a decompressed size of 17mb
  2. this causes this malloc in the sandbox to fail https://searchfox.org/mozilla-central/source/modules/woff2/RLBoxWOFF2Sandbox.cpp#15

We should try to estimate the size of the sandbox needed and create a sandbox of that size. The way to estimate the decompressed size (which is actually done in the same file https://searchfox.org/mozilla-central/source/gfx/ots/RLBoxWOFF2Host.cpp#152) is shown by another woff2 function. We need to do this estimation outside the sandbox and compute the estimate before sandbox creation

Working on a fix

Assignee: nobody → shravanrn
Flags: needinfo?(deian)

Going to do this in parts

Part 1 - Move the mem estimation code outside the sandbox

  • From here modules/woff2/src/woff2_dec.cc:1300

Part 2 - Augment the RLBoxSandboxPool

  • RLBoxSandboxPool::CreateSandboxData function accept params that it can pass to the RLBoxWoff2SandboxPool::CreateSandboxData
  • RLBoxSandboxPool::PopOrCreate needs to accept a function pointer that accepts a "sandbox filter" that would apply a filter condition (Filter's type would be bool (*)(RLBoxSandboxPoolData&))

Part 3 - Write an algorithm to estimate size of sandbox based on size of decompressed font. Need to do some testing to figure out what this estimate should be. But maybe something like at 50% more that the expected decompress size to account for input size and misc allocs

  • I need to add a small feature to RLBox to expose the maximum memory of a sandbox (it has only the "current memory" right now)

Simplifying this, we can combine parts 2 and 3 above and skip the rlbox update

Crash Signature: [@ w2c_memset] → [@ nsExpatDriver::ConsumeToken] [@ nsExpatDriver::WillBuildModel] [@ w2c_memset]
Crash Signature: [@ nsExpatDriver::ConsumeToken] [@ nsExpatDriver::WillBuildModel] [@ w2c_memset] → [@ nsExpatDriver::ConsumeToken] [@ nsExpatDriver::WillBuildModel] [@ OOM | large | NS_ABORT_OOM | nsParser::Parse] [@ w2c_memset]

Set release status flags based on info from the regressing bug 1743324

Pushed by bholley@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/dba7b7c19b2f part 1 - Move woff2 memory estimation code outside rlbox sandbox r=bholley https://hg.mozilla.org/integration/autoland/rev/582101d582a0 part 2 - Update woff2 RLBoxSandboxPool to track minimum sandbox size r=bholley

Have updated the patch to fix this. Will be landed shortly.

Crash Signature: [@ nsExpatDriver::ConsumeToken] [@ nsExpatDriver::WillBuildModel] [@ OOM | large | NS_ABORT_OOM | nsParser::Parse] [@ w2c_memset] → [@ w2c_memset]
Flags: needinfo?(shravanrn)
Pushed by bholley@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/693727e2df8b part 1 - Move woff2 memory estimation code outside rlbox sandbox r=bholley https://hg.mozilla.org/integration/autoland/rev/f21aa87c2301 part 2 - Update woff2 RLBoxSandboxPool to track minimum sandbox size r=bholley

Should the dropped nsExpatDriver crash signatures get a new bug?

Flags: needinfo?(shravanrn)
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 97 Branch

Sorry, could you clarify your question? Is there something wrong with crash signatures?

Flags: needinfo?(shravanrn) → needinfo?(aryx.bugmail)

(In reply to Shravan Narayan from comment #13)

Sorry, could you clarify your question? Is there something wrong with crash signatures?

Sebastian added some new crash signatures right before comment 6, and you removed them (probably unintentionally) in comment 9.

Sebastian, please do file a separate bug for those.

The crash reason for those is "RLBox crash: Called memcpy for memory larger than the sandbox", which suggests we may need to apply a similar trick for expat.

The patch landed in nightly and beta is affected.
:shravanrn, is this bug important enough to require an uplift?
If not please set status_beta to wontfix.

For more information, please visit auto_nag documentation.

Flags: needinfo?(shravanrn)

Comment on attachment 9254226 [details]
Bug 1744460 part 2 - Update woff2 RLBoxSandboxPool to track minimum sandbox size r=bholley

Beta/Release Uplift Approval Request

  • User impact if declined: Content Process crashes on 32-bit builds loading certain rare large fonts.
  • Is this code covered by automated tests?: No
  • Has the fix been verified in Nightly?: No
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Crashes fixed on Nightly. Patches have some light refactoring, but mostly just ensure that the sandbox is big enough.
  • String changes made/needed:
Attachment #9254226 - Flags: approval-mozilla-beta?
Attachment #9253979 - Flags: approval-mozilla-beta?
Flags: needinfo?(shravanrn)

Comment on attachment 9254226 [details]
Bug 1744460 part 2 - Update woff2 RLBoxSandboxPool to track minimum sandbox size r=bholley

Approved for 96.0b5

Attachment #9254226 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9253979 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Flags: qe-verify+
QA Whiteboard: [qa-triaged]

I reproduced the crash with the signature reported here [@ w2c_memset] using old Nightly build https://crash-stats.mozilla.org/report/index/6f90c406-ce87-4bc5-94f8-99e9a0211221.
Using latest Nightly (97.0a1) and Beta (96.0b7) builds I still get a crash using steps from comment 0 but with a different crash signature [@ moz_wasm2c_trap_handler], not sure if they are related or not. Shravanrn could you please take a look at these crashes?

https://crash-stats.mozilla.org/report/index/1ac73c92-cb61-4c29-b9a3-cd0070211221 - Nightly
https://crash-stats.mozilla.org/report/index/ee216d5b-9c20-4455-8227-bcb8f0211221 - Beta

Flags: needinfo?(shravanrn)

I am able to repro the crash on the latest nightly. Investigating now

Status: RESOLVED → REOPENED
Resolution: FIXED → ---

Closing this bug, moving the new report to bug 1747586.

Status: REOPENED → RESOLVED
Closed: 3 years ago3 years ago
Flags: needinfo?(shravanrn)
Resolution: --- → FIXED

Closing based on the last comments. The remaining issue is addressed in bug 1747586.
Furthermore, the original crash signature is no longer reproducing in fixed builds (Nightly builds after v97.0a1 from 2021-12-21 or Beta 96.0b7).

Status: RESOLVED → VERIFIED
Flags: qe-verify+
Has Regression Range: --- → yes
Blocks: 1758626
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: