Closed Bug 1764715 Opened 3 years ago Closed 3 years ago

Assertion failure: depth == bce_->bytecodeSection().stackDepth(), at frontend/OptionalEmitter.cpp:128 with OOM in module parsing

Categories

(Core :: JavaScript Engine, defect, P1)

x86_64
Linux
defect

Tracking

()

VERIFIED FIXED
101 Branch
Tracking Status
firefox-esr91 --- unaffected
firefox99 --- unaffected
firefox100 + fixed
firefox101 + verified

People

(Reporter: decoder, Assigned: jandem)

References

(Blocks 1 open bug, Regression)

Details

(4 keywords, Whiteboard: [bugmon:update,bisected,confirmed])

Attachments

(3 files)

The following testcase crashes on mozilla-central revision 20220411-87b37ed2950d (debug build, run with --fuzzing-safe --cpu-count=2 --ion-offthread-compile=off):

r(`
  while (true) {
    var line = y.shift();
    if (y.shift() == null) {
      let m94 = parseModule(undefined);
      for (var i72 = 0; i72 < 5; i72++)
        a1 = strictAssign();
    }
    a3 = class extends a93?.b34 {}.get();
  }
`);
function r(src) {
  oomTest(function() {
    let m = parseModule(src);
  });
}

Backtrace:

received signal SIGSEGV, Segmentation fault.
0x00005555574989be in js::frontend::OptionalEmitter::emitOptionalJumpTarget(JSOp, js::frontend::OptionalEmitter::Kind) ()
#0  0x00005555574989be in js::frontend::OptionalEmitter::emitOptionalJumpTarget(JSOp, js::frontend::OptionalEmitter::Kind) ()
#1  0x0000555557458ba7 in js::frontend::BytecodeEmitter::emitOptionalChain(js::frontend::UnaryNode*, js::frontend::ValueUsage) ()
#2  0x000055555743fd66 in js::frontend::BytecodeEmitter::emitTree(js::frontend::ParseNode*, js::frontend::ValueUsage, js::frontend::BytecodeEmitter::EmitLineNumberNote) ()
#3  0x000055555744692b in js::frontend::BytecodeEmitter::emitClass(js::frontend::ClassNode*, js::frontend::BytecodeEmitter::ClassNameKind, js::frontend::TaggedParserAtomIndex) ()
#4  0x000055555743fec7 in js::frontend::BytecodeEmitter::emitTree(js::frontend::ParseNode*, js::frontend::ValueUsage, js::frontend::BytecodeEmitter::EmitLineNumberNote) ()
#5  0x000055555743f49f in js::frontend::BytecodeEmitter::emitPropLHS(js::frontend::PropertyAccess*) ()
#6  0x000055555745717e in js::frontend::BytecodeEmitter::emitCalleeAndThis(js::frontend::ParseNode*, js::frontend::ParseNode*, js::frontend::CallOrNewEmitter&) ()
#7  0x00005555574581e2 in js::frontend::BytecodeEmitter::emitCallOrNew(js::frontend::CallNode*, js::frontend::ValueUsage) ()
#8  0x000055555743f91d in js::frontend::BytecodeEmitter::emitTree(js::frontend::ParseNode*, js::frontend::ValueUsage, js::frontend::BytecodeEmitter::EmitLineNumberNote) ()
#9  0x000055555744ac25 in js::frontend::BytecodeEmitter::emitAssignmentOrInit(js::frontend::ParseNodeKind, js::frontend::ParseNode*, js::frontend::ParseNode*) ()
#10 0x000055555743f8bb in js::frontend::BytecodeEmitter::emitTree(js::frontend::ParseNode*, js::frontend::ValueUsage, js::frontend::BytecodeEmitter::EmitLineNumberNote) ()
#11 0x0000555557453200 in js::frontend::BytecodeEmitter::emitExpressionStatement(js::frontend::UnaryNode*) ()
#12 0x000055555743fba5 in js::frontend::BytecodeEmitter::emitTree(js::frontend::ParseNode*, js::frontend::ValueUsage, js::frontend::BytecodeEmitter::EmitLineNumberNote) ()
#13 0x000055555745304f in js::frontend::BytecodeEmitter::emitStatementList(js::frontend::ListNode*) ()
#14 0x000055555743fd96 in js::frontend::BytecodeEmitter::emitTree(js::frontend::ParseNode*, js::frontend::ValueUsage, js::frontend::BytecodeEmitter::EmitLineNumberNote) ()
#15 0x000055555744d68e in js::frontend::BytecodeEmitter::emitLexicalScope(js::frontend::LexicalScopeNode*) ()
#16 0x000055555743fafe in js::frontend::BytecodeEmitter::emitTree(js::frontend::ParseNode*, js::frontend::ValueUsage, js::frontend::BytecodeEmitter::EmitLineNumberNote) ()
#17 0x0000555557450811 in js::frontend::BytecodeEmitter::emitWhile(js::frontend::BinaryNode*) ()
#18 0x000055555743fe3b in js::frontend::BytecodeEmitter::emitTree(js::frontend::ParseNode*, js::frontend::ValueUsage, js::frontend::BytecodeEmitter::EmitLineNumberNote) ()
#19 0x000055555745304f in js::frontend::BytecodeEmitter::emitStatementList(js::frontend::ListNode*) ()
#20 0x000055555743fd96 in js::frontend::BytecodeEmitter::emitTree(js::frontend::ParseNode*, js::frontend::ValueUsage, js::frontend::BytecodeEmitter::EmitLineNumberNote) ()
#21 0x00005555574434c2 in js::frontend::BytecodeEmitter::emitScript(js::frontend::ParseNode*) ()
#22 0x000055555746a8ee in ModuleCompiler<char16_t>::compile(JSContext*) ()
#23 0x000055555746a303 in bool ParseModuleToStencilAndMaybeInstantiate<char16_t>(JSContext*, js::frontend::CompilationInput&, JS::SourceText<char16_t>&, mozilla::Variant<mozilla::UniquePtr<js::frontend::ExtensibleCompilationStencil, JS::DeletePolicy<js::frontend::ExtensibleCompilationStencil> >, RefPtr<js::frontend::CompilationStencil>, js::frontend::CompilationGCOutput*>&) ()
#24 0x0000555557434019 in js::frontend::CompileModule(JSContext*, JS::ReadOnlyCompileOptions const&, JS::SourceText<char16_t>&) ()
#25 0x0000555556b67b3e in ParseModule(JSContext*, unsigned int, JS::Value*) ()
#26 0x00002504b4fef0df in ?? ()
[...]
#30 0x0000000000000000 in ?? ()
rax	0x5555557fb8a5	93824995014821
rbx	0x7fffffff8c30	140737488325680
rcx	0x555558207138	93825039102264
rdx	0x0	0
rsi	0x7ffff7105770	140737338431344
rdi	0x7ffff7104540	140737338426688
rbp	0x7fffffff8c20	140737488325664
rsp	0x7fffffff8c00	140737488325632
r8	0x7ffff7105770	140737338431344
r9	0x7ffff7f99840	140737353717824
r10	0x0	0
r11	0x0	0
r12	0x1	1
r13	0x0	0
r14	0x1	1
r15	0x0	0
rip	0x5555574989be <js::frontend::OptionalEmitter::emitOptionalJumpTarget(JSOp, js::frontend::OptionalEmitter::Kind)+238>
=> 0x5555574989be <_ZN2js8frontend15OptionalEmitter22emitOptionalJumpTargetE4JSOpNS1_4KindE+238>:	movl   $0x80,0x0
   0x5555574989c9 <_ZN2js8frontend15OptionalEmitter22emitOptionalJumpTargetE4JSOpNS1_4KindE+249>:	callq  0x555556bcb517 <abort>

This is an OOM but the assertion doesn't look good and varies based on the testcase (and the fact that it requires an OOM condition doesn't necessarily make it less exploitable). Marking this s-s until investigated further.

Attached file Testcase
Flags: needinfo?(jdemooij)
Assignee: nobody → jdemooij
Status: NEW → ASSIGNED
Flags: needinfo?(jdemooij)
Regressed by: 1761755

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

Has Regression Range: --- → yes

Comment on attachment 9272275 [details]
Bug 1764715 - Add missing return for OOM handling. r?arai!

Security Approval Request

  • How easily could an exploit be constructed based on the patch?: Hard. It's an OOM issue that's likely pretty hard to trigger reliably.
  • 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?: 100+ (beta)
  • If not all supported branches, which bug introduced the flaw?: Bug 1761755
  • Do you have backports for the affected branches?: Yes
  • If not, how different, hard to create, and risky will they be?: Should apply.
  • How likely is this patch to cause regressions; how much testing does it need?: Extremely unlikely.
Attachment #9272275 - Flags: sec-approval?

Bugmon Analysis
Verified bug as reproducible on mozilla-central 20220414092955-6c55ba30c858.
The bug appears to have been introduced in the following build range:

Start: b8f0d45667874418d4d040d401e9ee16cc4c8e9b (20220329090411)
End: 79f4d29fb759c9ab71e271a3cd646a90c51cd1af (20220329090547)
Pushlog: https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=b8f0d45667874418d4d040d401e9ee16cc4c8e9b&tochange=79f4d29fb759c9ab71e271a3cd646a90c51cd1af

Whiteboard: [bugmon:update,bisect] → [bugmon:update,bisected,confirmed]

S3, because this is a worrying assertion, but probably difficult to exploit given that this is a OOM handling issue.

Blocks: sm-frontend
Severity: -- → S3
Priority: -- → P1

Comment on attachment 9272275 [details]
Bug 1764715 - Add missing return for OOM handling. r?arai!

Approved to land and uplift

Attachment #9272275 - Flags: sec-approval? → sec-approval+

Comment on attachment 9272275 [details]
Bug 1764715 - Add missing return for OOM handling. r?arai!

Beta/Release Uplift Approval Request

  • User impact if declined: Crashes, maybe security issues.
  • Is this code covered by automated tests?: Yes
  • 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): Very safe patch, just adds a missing return statement to handle an out-of-memory case.
  • String changes made/needed: N/A
Attachment #9272275 - Flags: approval-mozilla-beta?
Group: javascript-core-security → core-security-release
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 101 Branch

Bugmon Analysis
Verified bug as fixed on rev mozilla-central 20220420215300-a33cd50e2f73.
Removing bugmon keyword as no further action possible. Please review the bug and re-add the keyword for further analysis.

Status: RESOLVED → VERIFIED
Keywords: bugmon

Comment on attachment 9272275 [details]
Bug 1764715 - Add missing return for OOM handling. r?arai!

Approved for 100.0b9

Attachment #9272275 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Group: core-security-release
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: