<meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; border-collapse: collapse; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><div>
<span class="Apple-style-span" style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; border-collapse: collapse; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">Observed 2 segmentation faults while using Suricata. The traffic used for the test was a (large) merged pcap of multiple pcaps available on <a href="http://pcapr.net">pcapr.net</a>. </span></div>
<div><span class="Apple-style-span" style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; border-collapse: collapse; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">Although that pcap cannot be retrieved and shared, I have noted some preliminary GDB analysis that might help identify the issues. </span></div>
<div><span class="Apple-style-span" style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; border-collapse: collapse; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><br>
</span></div><div><br></div><div>1) Segmentation fault occurred at <b><span class="Apple-style-span" style="font-weight: normal;">"</span>libhtp/htp/htp_response_generic.c" 279L</b></div>Code: size_t len = bstr_len(tx->response_line);<br>
<br></span><div><span class="Apple-style-span" style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; border-collapse: collapse; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">(gdb) p tx->response_line<br>
$24 = (bstr *) 0x0<br>(gdb) p tx->response_line.ptr<br>Cannot access memory at 0x0<br>Macro bstr_len tried to dereference a NULL pointer (response_line)</span><div><span class="Apple-style-span" style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; border-collapse: collapse; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><br>
</span></div><div><span class="Apple-style-span" style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; border-collapse: collapse; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><br>
</span></div><div><span class="Apple-style-span" style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; border-collapse: collapse; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><br>
</span></div><div><span class="Apple-style-span" style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; border-collapse: collapse; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">2) </span><span class="Apple-style-span" style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; border-collapse: collapse; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">Segmentation fault occurred at <b><span class="Apple-style-span" style="font-weight: normal;">"</span>src/detect-http-method.c" 697L</b></span></div>
<span class="Apple-style-span" style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; border-collapse: collapse; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">Code: for(idx = 0; idx < list_size(hs->connp->conn->transactions); idx++)<br>
<br></span><div><span class="Apple-style-span" style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; border-collapse: collapse; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">The pointer "hs" is NULL, and is being dereferenced. Suricata does have a check to detect whether this ptr is NULL. <br>
However, the check is performed before acquiring a semaphore. Apparently, things change by the time the semaphore is acquired. </span></div><div><span class="Apple-style-span" style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; border-collapse: collapse; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">Perhaps, the checks need to be performed before and after the semaphore operation.</span></div>
</div><div><span class="Apple-style-span" style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; border-collapse: collapse; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><br>
</span></div><div><span class="Apple-style-span" style="font-family: Helvetica, Arial, sans-serif; font-size: 13px; border-collapse: collapse; line-height: 17px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">-Ashwin.</span></div>