<html>
 <body>
  <div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
   <table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
    <tr>
     <td>
      This is an automatically generated e-mail. To reply, visit:
      <a href="https://reviewboard.asterisk.org/r/3067/">https://reviewboard.asterisk.org/r/3067/</a>
     </td>
    </tr>
   </table>
   <br />











<div>




<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
 <thead>
  <tr>
   <th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
    <a href="https://reviewboard.asterisk.org/r/3067/diff/3/?file=49747#file49747line986" style="color: black; font-weight: bold; text-decoration: underline;">/branches/12/main/core_unreal.c</a>
    <span style="font-weight: normal;">

     (Diff revision 3)

    </span>
   </th>
  </tr>
 </thead>

 <tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
  <tr>

   <td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">struct ast_channel *ast_unreal_new_channels(struct ast_unreal_pvt *p,</pre></td>

  </tr>
 </tbody>



 
 

 <tbody>

  <tr>
    <th bgcolor="#f0f0f0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">956</font></th>
    <td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="cm">/* Give the private a ref for each channel. */</span></pre></td>
    <th bgcolor="#f0f0f0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">970</font></th>
    <td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="cm">/* Give the private a ref for each channel. */</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#f0f0f0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">957</font></th>
    <td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="n">ao2_ref</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="o">+</span><span class="mi">2</span><span class="p">);</span></pre></td>
    <th bgcolor="#f0f0f0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">971</font></th>
    <td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="n">ao2_ref</span><span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="o">+</span><span class="mi">2</span><span class="p">);</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#f0f0f0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">958</font></th>
    <td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="n">p</span><span class="o">-></span><span class="n">owner</span> <span class="o">=</span> <span class="n">owner</span><span class="p">;</span></pre></td>
    <th bgcolor="#f0f0f0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">972</font></th>
    <td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="n">p</span><span class="o">-></span><span class="n">owner</span> <span class="o">=</span> <span class="n">owner</span><span class="p">;</span></pre></td>
  </tr>

  <tr>
    <th bgcolor="#f0f0f0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">959</font></th>
    <td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="n">p</span><span class="o">-></span><span class="n">chan</span> <span class="o">=</span> <span class="n">chan</span><span class="p">;</span></pre></td>
    <th bgcolor="#f0f0f0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">973</font></th>
    <td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; "><span class="tb">   </span><span class="n">p</span><span class="o">-></span><span class="n">chan</span> <span class="o">=</span> <span class="n">chan</span><span class="p">;</span></pre></td>
  </tr>

 </tbody>

</table>

<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I think this also needs to be split up and protected by the channel lock to protect against very early channel redirects (i.e. masquerade fixups).

Could probably just ignore this as too unlikely to happen.  I'm not sure how it could be cleaned up correctly if chan's alocation fails.</pre>
</div>
<br />



<p>- rmudgett</p>


<br />
<p>On December 17th, 2013, 11:20 p.m. UTC, Joshua Colp wrote:</p>








<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
 <tr>
  <td>

<div>Review request for Asterisk Developers.</div>
<div>By Joshua Colp.</div>


<p style="color: grey;"><i>Updated Dec. 17, 2013, 11:20 p.m.</i></p>









<div style="margin-top: 1.5em;">
 <b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
 <table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Currently when allocating a channel it is possible for external entities to become aware of the channel and try to interact with it before it is completely set up. This occurs because the channel is returned unlocked, and the caller allocating it is then expected to lock, populate it, and unlock. This leaves a small window where something else can get the channel.

The attached change makes it so ast_channel_alloc returns the allocated channel locked. It is expected that the caller then populates and unlocks. This leaves no window for something external to get and use it.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
 <tr>
  <td>
   <pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Placed calls, ran tests, all work as expected.</pre>
  </td>
 </tr>
</table>


<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">

 <li>/branches/12/tests/test_voicemail_api.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/tests/test_substitution.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/tests/test_stasis_channels.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/tests/test_cel.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/tests/test_cdr.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/tests/test_app.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/res/res_stasis_snoop.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/res/res_calendar.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/res/parking/parking_tests.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/main/pbx.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/main/message.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/main/core_unreal.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/main/channel.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/include/asterisk/channel.h <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_vpb.cc <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_unistim.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_skinny.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_sip.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_pjsip.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_phone.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_oss.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_nbs.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_multicast_rtp.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_motif.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_misdn.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_mgcp.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_jingle.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_iax2.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_h323.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_gtalk.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_dahdi.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_console.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/channels/chan_alsa.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/apps/confbridge/conf_chan_record.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/apps/app_voicemail.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/apps/app_meetme.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/addons/chan_ooh323.c <span style="color: grey">(404026)</span></li>

 <li>/branches/12/addons/chan_mobile.c <span style="color: grey">(404026)</span></li>

</ul>

<p><a href="https://reviewboard.asterisk.org/r/3067/diff/" style="margin-left: 3em;">View Diff</a></p>







  </td>
 </tr>
</table>








  </div>
 </body>
</html>