<?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>285496</bug_id>
          
          <creation_ts>2025-01-07 00:02:27 -0800</creation_ts>
          <short_desc>Missing Trailing Code Validation in end Instruction</short_desc>
          <delta_ts>2025-01-16 01:33:34 -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>WebAssembly</component>
          <version>Other</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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>tombox1337</reporter>
          <assigned_to name="Yijia Huang">yijia_huang</assigned_to>
          <cc>d_degazio</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2085329</commentid>
    <comment_count>0</comment_count>
      <attachid>473820</attachid>
    <who name="">tombox1337</who>
    <bug_when>2025-01-07 00:02:27 -0800</bug_when>
    <thetext>Created attachment 473820
program.js

### Description
WebKit does not enforce the requirement for validating the presence of trailing code after the end instruction in WebAssembly functions. This behavior allows the execution of WebAssembly modules with trailing code without raising errors, violating the expected behavior where an error should occur for trailing code after the function end.


### Environment

- OS: Ubuntu 20.04  
- CPU: amd64  
- WebKit Version: 146fa28a329d220785d2972c1d691555141e6406 (The latest)
- Commands:  
```bash
./JSCOnly/Debug/bin/jsc ./program.js
```

### Test Case

program.js



### Current State
```plaintext
./JSCOnly/Debug/bin/jsc ./program.js
0
```

### Expected Behavior

The WebAssembly module should fail validation and report an error similar to:

- Like gecko-dev:
  ```plaintext
  function body length mismatch
  ```
- Like v8:
  ```plaintext
  trailing code after function end
  ```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2086986</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-01-14 00:03:15 -0800</bug_when>
    <thetext>&lt;rdar://problem/142866140&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2087291</commentid>
    <comment_count>2</comment_count>
    <who name="Yijia Huang">yijia_huang</who>
    <bug_when>2025-01-14 17:15:10 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/39043</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2087708</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-01-16 01:33:31 -0800</bug_when>
    <thetext>Committed 288996@main (5c94b688c7a1): &lt;https://commits.webkit.org/288996@main&gt;

Reviewed commits have been landed. Closing PR #39043 and removing active labels.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>473820</attachid>
            <date>2025-01-07 00:02:27 -0800</date>
            <delta_ts>2025-01-07 00:02:27 -0800</delta_ts>
            <desc>program.js</desc>
            <filename>program.js</filename>
            <type>application/x-javascript</type>
            <size>428</size>
            <attacher>tombox1337</attacher>
            
              <data encoding="base64">CnZhciB3YXNtX2NvZGUgPSBuZXcgVWludDhBcnJheShbMCw5NywxMTUsMTA5LDEsMCwwLDAsMSw2
LDEsOTYsMSwxMjcsMSwxMjcsMywyLDEsMCw3LDgsMSw0LDEwOSw5NywxMDUsMTEwLDAsMCwxMCwx
OCwxLDE2LDAsMzIsMCw2NSwxMCw3NCw0LDEyNyw2NSwxLDUsNjUsMCwxMSwxMSwxMSwwLDI0LDQs
MTEwLDk3LDEwOSwxMDEsMSw3LDEsMCw0LDEwOSw5NywxMDUsMTEwLDIsOCwxLDAsMSwwLDMsMTEw
LDExNywxMDksXSk7CnZhciB3YXNtX21vZHVsZSA9IG5ldyBXZWJBc3NlbWJseS5Nb2R1bGUod2Fz
bV9jb2RlKTsKdmFyIHdhc21faW5zdGFuY2UgPSBuZXcgV2ViQXNzZW1ibHkuSW5zdGFuY2Uod2Fz
bV9tb2R1bGUpOwpjb25zdCB7ICdtYWluJzogZnVuYyB9ID0gd2FzbV9pbnN0YW5jZS5leHBvcnRz
Owp2YXIgYSA9IGZ1bmMoMSk7CnByaW50KGEpOwo=
</data>

          </attachment>
      

    </bug>

</bugzilla>