<div dir="ltr">-krasin@</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 16, 2017 at 11:05 AM, Kostya Serebryany <span dir="ltr"><<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Thu, Jun 15, 2017 at 10:39 PM, Enes Göktaş <span dir="ltr"><<a href="mailto:enes.goktas@gmail.com" target="_blank">enes.goktas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div>Hi Kostya,<br><br></div><div>Please find attached the minimized motivation test.<br></div><div>I hope it is minimized enough. If not please let me know so I can try to make it more minimal.<br></div><div>Were you expecting something like this?<br></div><div><br></div>Also I think the tests that I should provide along with the patch should be in a special format right?</div></div></blockquote><div><br></div></span><div>Yes. Take a look at other tests in <span style="color:rgb(0,0,0)">llvm/projects/compiler-rt/t<wbr>est/cfi</span></div><div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)">(I did not study your patch or tests in detail yet, and probably won't have time until mid Jul. But others may)</span></div><div><br></div><div>My major concern with any such patch is that it complicates the implementation. </div><div>For many parts of compiler extra complexity is acceptable, but CFI is a security mitigation feature and as such should be minimal. </div><div><br></div><div>--kcc </div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div> I think I should be looking at <a href="http://llvm.org/docs/DeveloperPolicy.html#test-cases" target="_blank">http://llvm.org/docs/Developer<wbr>Policy.html#test-cases</a>, and <a href="http://llvm.org/docs/TestingGuide.html" target="_blank">http://llvm.org/docs/TestingGu<wbr>ide.html</a> for more information for adding tests to the patch. Any other handy links by any chance?<br></div><div><br>--<br></div>Enes<br></div><div class="m_8831410146251183385m_413356906208142547gmail-HOEnZb"><div class="m_8831410146251183385m_413356906208142547gmail-h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 15, 2017 at 1:51 PM, Kostya Serebryany <span dir="ltr"><<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Enes, <div><br></div><div>I usually find it nearly impossible to discuss complex issues likes this w/o having a minimized motivation test. </div><div>Could you please provide such a test with one of the patches?</div><div>(And in general, please try to provide tests with any patch)</div><div><br></div><div>Thanks! </div><div><br></div><div>--kcc</div><div><br></div></div><div class="m_8831410146251183385m_413356906208142547gmail-m_2046620451593056489HOEnZb"><div class="m_8831410146251183385m_413356906208142547gmail-m_2046620451593056489h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 15, 2017 at 5:08 AM, Enes Göktaş <span dir="ltr"><<a href="mailto:enes.goktas@gmail.com" target="_blank">enes.goktas@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div>Hi,<br><br></div>I would like to propose extending the Control-Flow Integrity (CFI) mechanism in LLVM/Clang with a feature that allows users to explicitly link classes that have no inheritance link. Usually, if one class is used at locations in code where this class is not expected, this will create a CFI error at runtime, assuming the application is built with CFI enabled. However, in cases where the user has a complex code structure or design that should allow this behavior, there is currently no solution but disabling the CFI checks. Disabling the CFI checks is not a preferable option when one wants to protect against memory corruption exploitation.<br></div><div><br>This feature prevents the CFI errors by expanding the valid vtable sets at virtual callsites with vtables of classes specified in a sanitizer blacklist file by the user. This allows keeping the CFI checks enabled.<br></div></div><div><br></div><div>When applying CFI to Firefox, I had to use this feature to solve the CFI errors caused by XPCOM in Firefox. XPCOM is a fundamental technique in Firefox and its design is so complex and intricate that changing XPCOM  to solve the CFI errors would be very difficult. XPCOM allows components to be written in multiple languages and allows them being used from different languages. For example, components implemented in JavaScript(JS) can be used from C++ through their corresponding classes defined in C++. However, it is worth mentioning that these classes are not implemented in C++ but in JS. Behind the scenes, during runtime a generic proxy class is used for all JS-component classes within the C++ code. This proxy class leads the execution to the JS code.<br></div><div>When CFI is applied, the CFI checks at virtual callsites that have the type of a JS-component class, fail, because at runtime the vtable of the generic proxy class is used at these virtual callsites, while there is no inheritance link between the JS-component and the generic proxy class.<br></div><div><br></div><div>With the following patches I was able to specify the links between these classes such that during compilation the vtable of the generic proxy class was added to the vtable sets at virtual callsites with the type of the JS-component classes:<br>- <a href="https://reviews.llvm.org/D34233" target="_blank">https://reviews.llvm.org/D3423<wbr>3</a><br>- <a href="https://reviews.llvm.org/D34231" target="_blank">https://reviews.llvm.org/D3423<wbr>1</a><br></div><div><br></div><div>Without these patches, XPCOM would have to be significantly changed and probably written from scratch. Simply making the JS-component classes a descendant of the generic proxy class, or vice versa,  is not an option, because this would break the design. Making the generic proxy class a descendant of the JS-component classes would result in a bad design in which the proxy class inherits from tens of classes. Also the vtable of the proxy class should overlay the structure of the JS-component vtables in a very specific way. Making one a descendant of the other will break the overlaying property.<br><br></div><div>Kind regards,<br></div><div>Enes<br></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></span></div><br></div></div>
</blockquote></div><br></div>