Closed Bug 1699647 Opened 4 years ago Closed 4 years ago

Assertion failure: size_t(reg) < std::size(names), at /storagejs/src/jit/x86-shared/Constants-x86-shared.h:194

Categories

(Core :: JavaScript: WebAssembly, defect, P1)

x86
Linux
defect

Tracking

()

RESOLVED FIXED
89 Branch
Tracking Status
firefox-esr78 --- disabled
firefox86 --- disabled
firefox87 --- disabled
firefox88 --- fixed
firefox89 --- fixed

People

(Reporter: decoder, Assigned: yury)

References

(Blocks 1 open bug)

Details

(4 keywords, Whiteboard: [fuzzblocker])

Attachments

(3 files)

The attached testcase crashes on mozilla-central revision a96c49a026f6 (build with --target=i686-pc-linux-gnu --enable-gczeal --enable-optimize --enable-debug --enable-fuzzing, run with --no-threads --fuzzing-safe --baseline-warmup-threshold=0 --disable-oom-functions test.js).

Backtrace:

==29603==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x00000000 (pc 0x58a3fffc bp 0xffd59f98 sp 0xffd59f40 T29603)
    #0 0x58a3fffb in AnnotateMozCrashReason(char const*) js/src/debug32fuzzing/dist/include/mozilla/Assertions.h:42:19
    #1 0x58a3fffb in js::jit::X86Encoding::GPReg8Name(js::jit::X86Encoding::RegisterID) js/src/jit/x86-shared/Constants-x86-shared.h:194:3
    #2 0x58a3fffb in js::jit::X86Encoding::BaseAssembler::setCC_r(js::jit::X86Encoding::Condition, js::jit::X86Encoding::RegisterID) js/src/jit/x86-shared/BaseAssembler-x86-shared.h:2034:41
    #3 0x58a3fffb in js::jit::AssemblerX86Shared::setCC(js::jit::AssemblerX86Shared::Condition, js::jit::Register) js/src/jit/x86-shared/Assembler-x86-shared.h:1208:10
    #4 0x58a3fffb in js::jit::MacroAssembler::allTrueInt16x8(js::jit::FloatRegister, js::jit::Register) js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h:1407:3
    #5 0x58a3f5bb in js::jit::CodeGenerator::visitWasmReduceSimd128(js::jit::LWasmReduceSimd128*) js/src/jit/x86-shared/CodeGenerator-x86-shared.cpp:3448:12
    #6 0x58cdaf3b in js::jit::CodeGenerator::generateBody() js/src/jit/CodeGenerator.cpp:6571:9
    #7 0x58d33b82 in js::jit::CodeGenerator::generateWasm(js::wasm::TypeIdDesc, js::wasm::BytecodeOffset, js::wasm::ArgTypeVector const&, js::jit::MachineState const&, unsigned int, js::wasm::FuncOffsets*, js::wasm::StackMaps*) js/src/jit/CodeGenerator.cpp:11359:8
    #8 0x59234ea4 in js::wasm::IonCompileFunctions(js::wasm::ModuleEnvironment const&, js::wasm::CompilerEnvironment const&, js::LifoAlloc&, mozilla::Vector<js::wasm::FuncCompileInput, 8u, js::SystemAllocPolicy> const&, js::wasm::CompiledCode*, mozilla::UniquePtr<char [], JS::FreePolicy>*) js/src/wasm/WasmIonCompile.cpp:5659:20
    #9 0x591f114b in ExecuteCompileTask(js::wasm::CompileTask*, mozilla::UniquePtr<char [], JS::FreePolicy>*) js/src/wasm/WasmGenerator.cpp:782:16
    #10 0x591f2c1c in js::wasm::ModuleGenerator::locallyCompileCurrentTask() js/src/wasm/WasmGenerator.cpp:831:8
    #11 0x591f2c1c in js::wasm::ModuleGenerator::finishFuncDefs() js/src/wasm/WasmGenerator.cpp:969:24
    #12 0x5912d858 in bool DecodeCodeSection<js::wasm::Decoder>(js::wasm::ModuleEnvironment const&, js::wasm::Decoder&, js::wasm::ModuleGenerator&) js/src/wasm/WasmCompile.cpp:678:13
    #13 0x5912d2b1 in js::wasm::CompileBuffer(js::wasm::CompileArgs const&, js::wasm::ShareableBytes const&, mozilla::UniquePtr<char [], JS::FreePolicy>*, mozilla::Vector<mozilla::UniquePtr<char [], JS::FreePolicy>, 0u, js::SystemAllocPolicy>*, JS::OptimizedEncodingListener*) js/src/wasm/WasmCompile.cpp:700:8
    #14 0x5926d4cf in js::WasmModuleObject::construct(JSContext*, unsigned int, JS::Value*) js/src/wasm/WasmJS.cpp:1598:7
    #15 0x57db361a in CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), js::CallReason, JS::CallArgs const&) js/src/vm/Interpreter.cpp:435:13
    #16 0x57db77e9 in CallJSNativeConstructor(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), JS::CallArgs const&) js/src/vm/Interpreter.cpp:451:8
    #17 0x57da79be in InternalConstruct(JSContext*, js::AnyConstructArgs const&) js/src/vm/Interpreter.cpp:624:14
    #18 0x57da75d6 in js::ConstructFromStack(JSContext*, JS::CallArgs const&) js/src/vm/Interpreter.cpp:670:10
    #19 0x588cba98 in js::jit::DoCallFallback(JSContext*, js::jit::BaselineFrame*, js::jit::ICCall_Fallback*, unsigned int, JS::Value*, JS::MutableHandle<JS::Value>) js/src/jit/BaselineIC.cpp:1821:10
    #20 0x326745b9  (<unknown module>)

This is x86 (32-bit) only and blocking further fuzzing.

Attached file Testcase

Sigh. setcc requires a register with an 8-bit personality on x86. Elsewhere I think we've punted on this by just choosing a fixed register such as eax. Yury, perhaps you can take a look?

Assignee: nobody → ydelendik
Status: NEW → ASSIGNED

Compact test with pre-built wasm binary:

const module = new Uint8Array([
    0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,
    5,4,1,1,0,0,7,10,1,6,109,101,109,111,114,121,2,0,10,49,
    1,47,0,65,16,253,1,1,1,253,253,1,253,131,1,65,158,232,
    68,253,1,1,1,253,100,65,16,253,1,1,1,253,11,0,0,253,1,1,
    1,65,158,232,68,253,1,1,0,0,11,0,14,4,110,97,109,101,1,
    7,1,0,4,109,97,105,110]);
new WebAssembly.Module(module)

If you don't want to choose a fixed reg (eg eax), on 32-bit only, another kludgey
fix is to accept any register (that is, one of eax/ebx/ecx/edx/esi/edi). If it is
one of the first 4, then just use setcc as at present. If esi or edi, emit
swapl eax, reg ; setcc eax ; swapl eax, reg.
swapl eax, reg has a one-byte encoding in 32-bit mode, so it's only 2 bytes extra
code in total.

Cool, for now I used the same logic as in emitSet. Let me know if swapl one is better.

Nightly-only code. Should be good to land after the freeze ends. Yury, it would be good if you could get it uplifted to Beta 88 ASAP so that it won't bite Bergamot.

Severity: -- → S2
Keywords: sec-moderate
Priority: -- → P1

Comment on attachment 9210362 [details]
Bug 1699647 - Use setCC only when register has 8bit personality. r?lth

Beta/Release Uplift Approval Request

  • User impact if declined: Web application (e.g. Google Hangout), that use WebAssembly SIMD may crash.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce: Test included
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): SIMD is new technology in WebAssembly but used in some apps now there is a small risk that similar crash can happen in the wild now.

https://treeherder.mozilla.org/#/jobs?repo=try&revision=b683eaeb2a74d454af062bbe2f3c256bf5ca2cd3

  • String changes made/needed:
Attachment #9210362 - Flags: approval-mozilla-beta?

Limited test to the affected platforms via // |jit-test| skip-if: !wasmSimdEnabled() || !getBuildConfiguration().x86

https://treeherder.mozilla.org/#/jobs?repo=try&revision=26f00e6bc1bf83daed51797ca81077438e8a72f7

Attachment #9210362 - Flags: approval-mozilla-beta?

Comment on attachment 9211040 [details]
Bug 1699647 - Use setCC only when register has 8bit personality. r=lth

Beta/Release Uplift Approval Request

  • User impact if declined: Web application (e.g. Google Hangout), that use WebAssembly SIMD may crash.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce: jit-test for affected platforms included
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): SIMD is new technology in WebAssembly but used in some apps now there is a small risk that similar crash can happen in the wild now.
  • String changes made/needed: np
Attachment #9211040 - Flags: approval-mozilla-beta?
Group: javascript-core-security → core-security-release
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 89 Branch

Comment on attachment 9211040 [details]
Bug 1699647 - Use setCC only when register has 8bit personality. r=lth

Approved for 88.0b3.

Attachment #9211040 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Flags: qe-verify-
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: