Skip to content
Memory corruption Disclosed report Advanced CVE-2022-31740

Assertion failure: *def->output() == alloc, at jit/RegisterAllocator.cpp:270

Gary Kwong Follow

Originally disclosed on Mozilla

  • Fixed in 6 days
  • Paid in 12 days
  • Disclosed after 6 days
Text
Created attachment 9274191
stack

'''js
new WebAssembly.Module(wasmTextToBinary(`
(module
  (global $global$1
    (mut i32)
    (i32.const 0)
  )
  (func $0
    (param $0 f64)
    (param $1 f32)
    (result f32)
    (f32.copysign
      (local.get $1)
      (f32.const 0)
    )
  )
)
`));
'''

'''
(gdb) bt
#0  js::jit::AllocationIntegrityState::checkIntegrity (this=this@entry=0x7fffffff7800, block=block@entry=0x7ffff5f1cfa0, ins=0x7ffff5f1d158, ins@entry=0x7ffff5f1e020, vreg=vreg@entry=4, alloc=...) at /home/skygentoo/trees/mozilla-central/js/src/jit/RegisterAllocator.cpp:270
#1  0x0000555557be4538 in js::jit::AllocationIntegrityState::check (this=<optimized out>) at /home/skygentoo/trees/mozilla-central/js/src/jit/RegisterAllocator.cpp:207
#2  0x0000555557a9d11a in js::jit::GenerateLIR (mir=mir@entry=0x7fffffff7b50) at /home/skygentoo/trees/mozilla-central/js/src/jit/Ion.cpp:1534
#3  0x0000555557d41453 in js::wasm::IonCompileFunctions (moduleEnv=..., compilerEnv=..., lifo=..., inputs=..., code=<optimized out>, error=error@entry=0x7fffffffb828) at /home/skygentoo/trees/mozilla-central/js/src/wasm/WasmIonCompile.cpp:6944
#4  0x0000555557d0cbc3 in ExecuteCompileTask (task=0x7ffff6ace800, error=0x7fffffffb828) at /home/skygentoo/trees/mozilla-central/js/src/wasm/WasmGenerator.cpp:712
#5  0x0000555557d0d89a in js::wasm::ModuleGenerator::locallyCompileCurrentTask (this=0x7fffffffa2e0) at /home/skygentoo/trees/mozilla-central/js/src/wasm/WasmGenerator.cpp:773
#6  js::wasm::ModuleGenerator::finishFuncDefs (this=0x7fffffffa2e0) at /home/skygentoo/trees/mozilla-central/js/src/wasm/WasmGenerator.cpp:913
#7  0x0000555557cea100 in DecodeCodeSection<js::wasm::Decoder> (env=..., d=..., mg=...) at /home/skygentoo/trees/mozilla-central/js/src/wasm/WasmCompile.cpp:709
#8  0x0000555557ce9de7 in js::wasm::CompileBuffer (args=..., bytecode=..., error=error@entry=0x7fffffffb828, warnings=warnings@entry=0x7fffffffb858, listener=listener@entry=0x0) at /home/skygentoo/trees/mozilla-central/js/src/wasm/WasmCompile.cpp:731
#9  0x0000555557d5a8c9 in js::WasmModuleObject::construct (cx=cx@entry=0x7ffff6a2c200, argc=<optimized out>, vp=<optimized out>) at /home/skygentoo/trees/mozilla-central/js/src/wasm/WasmJS.cpp:1815
#10 0x0000555556c398d0 in CallJSNative (cx=cx@entry=0x7ffff6a2c200, native=native@entry=0x555557d5a730 <js::WasmModuleObject::construct(JSContext*, unsigned int, JS::Value*)>, reason=<optimized out>, reason@entry=js::CallReason::Call, args=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:420
#11 0x0000555556c3dd25 in CallJSNativeConstructor (cx=cx@entry=0x7ffff6a2c200, native=0x555557d5a730 <js::WasmModuleObject::construct(JSContext*, unsigned int, JS::Value*)>, args=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:436
#12 0x0000555556c2d4db in InternalConstruct (cx=<optimized out>, cx@entry=0x7ffff6a2c200, args=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:633
#13 0x0000555556c22503 in js::ConstructFromStack (cx=0x7ffff6a2c200, args=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:679
#14 Interpret (cx=cx@entry=0x7ffff6a2c200, state=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:3304
#15 0x0000555556c18dcf in js::RunScript (cx=cx@entry=0x7ffff6a2c200, state=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:389
#16 0x0000555556c2e4a4 in js::ExecuteKernel (cx=cx@entry=0x7ffff6a2c200, script=script@entry=..., envChainArg=envChainArg@entry=..., evalInFrame=evalInFrame@entry=..., result=result@entry=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:781
#17 0x0000555556c2e87c in js::Execute (cx=cx@entry=0x7ffff6a2c200, script=..., envChain=..., rval=..., rval@entry=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/Interpreter.cpp:813
#18 0x0000555556d93daf in ExecuteScript (cx=cx@entry=0x7ffff6a2c200, envChain=..., script=..., rval=rval@entry=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/CompilationAndEvaluation.cpp:509
#19 0x0000555556d93fd8 in JS_ExecuteScript (cx=cx@entry=0x7ffff6a2c200, scriptArg=scriptArg@entry=...) at /home/skygentoo/trees/mozilla-central/js/src/vm/CompilationAndEvaluation.cpp:533
#20 0x0000555556b5e7a1 in RunFile (cx=cx@entry=0x7ffff6a2c200, filename=0x7fffffffde82 "testcase.js", filename@entry=0x7ffff7864020 "\230$\255\373\344\344\344", <incomplete sequence \344>, file=<optimized out>, file@entry=0x7ffff7864020, compileMethod=compileMethod@entry=CompileUtf8::DontInflate, compileOnly=false) at /home/skygentoo/trees/mozilla-central/js/src/shell/js.cpp:1065
#21 0x0000555556b5ded2 in Process (cx=cx@entry=0x7ffff6a2c200, filename=<optimized out>, forceTTY=false, kind=kind@entry=FileScript) at /home/skygentoo/trees/mozilla-central/js/src/shell/js.cpp:1654
#22 0x0000555556b2443c in ProcessArgs (cx=0x7ffff6a2c200, op=<optimized out>) at /home/skygentoo/trees/mozilla-central/js/src/shell/js.cpp:10921
#23 Shell (cx=0x7ffff6a2c200, op=op@entry=0x7fffffffd6e8) at /home/skygentoo/trees/mozilla-central/js/src/shell/js.cpp:11660
#24 0x0000555556b1d81a in main (argc=<optimized out>, argv=<optimized out>) at /home/skygentoo/trees/mozilla-central/js/src/shell/js.cpp:12702
(gdb)
'''

Run with `--fuzzing-safe --no-threads --no-baseline --no-ion testcase.js`, compile with `AR=ar sh ./configure --enable-simulator=arm64 --enable-debug --with-ccache --enable-gczeal --enable-debug-symbols --disable-bootstrap --disable-tests`, tested on m-c rev 79a65e971e59.

Not sure if this is s-s, I'd leave it to Julian/Lars. Bisecting now...

The original report as published on Mozilla's Bugzilla, by Gary Kwong. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is known

A high-severity memory corruption bug in JavaScript: WebAssembly. Mozilla made it public on 4 May 2022 as CVE-2022-31740.

About Memory corruption

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Gary Kwong

View all

42 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.