<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>254412</bug_id>
          
          <creation_ts>2023-03-24 06:26:02 -0700</creation_ts>
          <short_desc>[WASM] Memory Corruption in JSC::Wasm::isSubtype</short_desc>
          <delta_ts>2024-01-30 16:35:42 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>247394</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="CAO ZONG">cz18811105578</reporter>
          <assigned_to name="Asumu Takikawa">asumu</assigned_to>
          <cc>asumu</cc>
    
    <cc>bfulgham</cc>
    
    <cc>justin_michaud</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1943703</commentid>
    <comment_count>0</comment_count>
    <who name="CAO ZONG">cz18811105578</who>
    <bug_when>2023-03-24 06:26:02 -0700</bug_when>
    <thetext>Commit: cebd0f9727d7493fbbea4ebf321799bc0152642e
Build:  Release
Flag:   --useSinglePassBBQJIT=true 
        --useWebAssemblyTypedFunctionReferences=true 
        --useWebAssemblyGC=true

Poc:
```
var wasm_code = new Uint8Array([0,97,115,109,1,0,0,0,1,222,128,128,128,0,5,80,0,95,4,124,0,112,0,126,0,126,0,80,0,96,3,127,127,127,1,127,96,0,0,80,0,96,1,107,1,15,107,0,107,0,125,107,0,107,0,107,0,107,0,107,0,107,0,107,0,107,0,107,0,107,0,107,0,126,80,0,96,15,107,0,107,0,125,107,0,107,0,107,0,107,0,107,0,107,0,107,0,107,0,107,0,107,0,107,0,126,1,127,3,130,128,128,128,0,1,1,4,133,128,128,128,0,1,112,1,1,8,5,132,128,128,128,0,1,1,16,32,13,131,128,128,128,0,1,0,2,7,136,128,128,128,0,1,4,109,97,105,110,0,0,9,139,128,128,128,0,1,6,0,65,0,11,112,1,210,0,11,10,179,132,128,128,0,1,176,4,0,210,0,65,212,0,253,15,65,226,0,253,109,253,126,253,126,253,126,253,126,253,195,1,4,3,26,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,67,0,0,0,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,2,107,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,11,65,226,196,137,147,6,253,15,253,126,65,226,196,137,3,253,15,253,195,1,253,109,253,29,0,5,26,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,67,0,0,0,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,68,0,0,0,0,0,0,0,0,208,112,66,0,66,0,251,7,0,66,0,11,2,4,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,65,0,11,11]);
var wasm_module = new WebAssembly.Module(wasm_code);
var wasm_instance = new WebAssembly.Instance(wasm_module);
var f = wasm_instance.exports.main;
f();
```

Backtrace:
#0  0x0000555556b8e4dc in JSC::Wasm::TypeDefinition::unroll() const ()
#1  0x0000555556b8e936 in JSC::Wasm::TypeDefinition::expand() const ()
#2  0x0000555556a3c2a3 in JSC::Wasm::isSubtype(JSC::Wasm::Type, JSC::Wasm::Type) ()
#3  0x0000555556b0253e in JSC::Wasm::FunctionParser&lt;JSC::Wasm::LLIntGenerator&gt;::unify(JSC::Wasm::LLIntGenerator::ControlType const&amp;) ()
#4  0x0000555556af0095 in JSC::Wasm::FunctionParser&lt;JSC::Wasm::LLIntGenerator&gt;::parseExpression() ()
#5  0x0000555556ae825b in JSC::Wasm::FunctionParser&lt;JSC::Wasm::LLIntGenerator&gt;::parseBody() ()
#6  0x0000555556ae309f in JSC::Wasm::FunctionParser&lt;JSC::Wasm::LLIntGenerator&gt;::parse() ()
#7  0x0000555556ad1f72 in JSC::Wasm::parseAndCompileBytecode(unsigned char const*, unsigned long, JSC::Wasm::TypeDefinition const&amp;, JSC::Wasm::ModuleInformation&amp;, unsigned int) ()
#8  0x0000555556adfceb in JSC::Wasm::LLIntPlan::compileFunction(unsigned int) ()
#9  0x0000555556acddf0 in JSC::Wasm::EntryPlan::compileFunctions(JSC::Wasm::Plan::CompilationEffort) ()
#10 0x0000555556b95272 in JSC::Wasm::Worklist::Thread::work() ()
#11 0x0000555556c4afa3 in WTF::Detail::CallableWrapper&lt;WTF::AutomaticThread::start(WTF::AbstractLocker const&amp;)::$_0, void&gt;::call() ()
#12 0x0000555556c6c1ef in WTF::Thread::entryPoint(WTF::Thread::NewThreadContext*) ()
#13 0x0000555556cc71d6 in WTF::wtfThreadEntryPoint(void*) ()
#14 0x00007ffff5fd9609 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#15 0x00007ffff5ba6133 in clone () from /lib/x86_64-linux-gnu/libc.so.6</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1943704</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-03-24 06:26:12 -0700</bug_when>
    <thetext>&lt;rdar://problem/107184256&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1943818</commentid>
    <comment_count>2</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2023-03-24 11:59:19 -0700</bug_when>
    <thetext>&gt; --useWebAssemblyTypedFunctionReferences=true


This is not implemented fully &amp; not enabled. So, this is not a security issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1943819</commentid>
    <comment_count>3</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2023-03-24 11:59:42 -0700</bug_when>
    <thetext>Also, --useWebAssemblyGC=true is not implemented fully and not enabled.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2008061</commentid>
    <comment_count>4</comment_count>
    <who name="Asumu Takikawa">asumu</who>
    <bug_when>2024-01-26 16:00:53 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/23334</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2009150</commentid>
    <comment_count>5</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-01-30 16:35:40 -0800</bug_when>
    <thetext>Committed 273794@main (7b11aad047b2): &lt;https://commits.webkit.org/273794@main&gt;

Reviewed commits have been landed. Closing PR #23334 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>