<?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>188281</bug_id>
          
          <creation_ts>2018-08-02 15:35:26 -0700</creation_ts>
          <short_desc>JSLock::ownerThread seems racy</short_desc>
          <delta_ts>2019-01-20 14:50:33 -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>NEW</bug_status>
          <resolution></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 name="Saam Barati">saam</reporter>
          <assigned_to name="Saam Barati">saam</assigned_to>
          <cc>ap</cc>
    
    <cc>benjamin</cc>
    
    <cc>fpizlo</cc>
    
    <cc>ggaren</cc>
    
    <cc>gskachkov</cc>
    
    <cc>jfbastien</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>msaboff</cc>
    
    <cc>rmorisset</cc>
    
    <cc>ticaiolima</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1447414</commentid>
    <comment_count>0</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2018-08-02 15:35:26 -0700</bug_when>
    <thetext>Specifically, the race I&apos;m worried about is:

```
m_ownerThread = ...; // set to non null value some time long ago.
T1: VMTraps signal sender thread.
T2: VM main execution thread.

T1: tmp1 = m_ownerThread.m_ptr;
T2: tmp2 = m_ownerThread.m_ptr;
T2: m_ownerThread.m_ptr = nullptr;
T2: tmp2-&gt;deref(); // ref count going from 1-&gt;0
T2: ~(tmp2);
T1: tmp1-&gt;ref(); // UAF
```

Would be helpful if somebody else looked to see if there are errors in my logic here.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1447417</commentid>
    <comment_count>1</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2018-08-02 15:43:20 -0700</bug_when>
    <thetext>(In reply to Saam Barati from comment #0)
&gt; Specifically, the race I&apos;m worried about is:
&gt; 
&gt; ```
&gt; m_ownerThread = ...; // set to non null value some time long ago.
&gt; T1: VMTraps signal sender thread.
&gt; T2: VM main execution thread.
&gt; 
&gt; T1: tmp1 = m_ownerThread.m_ptr;
&gt; T2: tmp2 = m_ownerThread.m_ptr;
&gt; T2: m_ownerThread.m_ptr = nullptr;
&gt; T2: tmp2-&gt;deref(); // ref count going from 1-&gt;0
&gt; T2: ~(tmp2);
&gt; T1: tmp1-&gt;ref(); // UAF
&gt; ```
&gt; 
&gt; Would be helpful if somebody else looked to see if there are errors in my
&gt; logic here.

actually, it&apos;d look somewhat different, since we never null out that pointer, we just assign new pointers in, but race still holds I think:


```
m_ownerThread = ...; // set to non null a long time ago
T1: VMTraps signal sender thread.
T2: VM main execution thread.

T1: tmp1 = m_ownerThread.m_ptr;
T2: tmp2 = m_ownerThread.m_ptr;
T2: m_ownerThread.m_ptr = some other ptr;
T2: tmp2-&gt;deref(); // ref count going from 1-&gt;0
T2: ~(tmp2);
T1: tmp1-&gt;ref(); // UAF
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1496407</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-01-20 14:50:33 -0800</bug_when>
    <thetext>&lt;rdar://problem/47417563&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>