<div dir="ltr">Hi Shikhar,<div><br></div><div>You don't need to build the library with `-fsanitize-coverage=...`, using `-fsanitize=fuzzer-no-link,address` should be sufficient. Without being able to inspect, it seems like you're building the library/fuzz target in a sane manner (although you can actually build object files/shared libraries with -fsanitize=fuzzer, and the libFuzzer main won't be linked, if this makes your build process easier).</div><div><br></div><div>I've run a quick grep and can't find anything that would match "apifunc() resp=0x7ff38f83ac20 uninitialized, fixing it." in libFuzzer (or compiler-rt). What version of compiler-rt/llvm/clang are you trying this with?</div><div><br></div><div>Have you tried <a href="https://github.com/google/fuzzing/blob/master/tutorial/libFuzzerTutorial.md#visualizing-coverage">visualising the coverage</a> that the fuzz target is generating? It may give you an insight as to why your desired function under test isn't being hit.</div><div><br></div><div>- Mitch</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 12, 2019 at 9:16 AM Shikhar Singh via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></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 style="margin:0px;padding:0px 0px 20px;width:1644.25px;font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:medium"><div><div id="gmail-m_5872114806333856756gmail-:1hb" style="font-size:0.875rem;direction:ltr;margin:8px 0px 0px;padding:0px"><div id="gmail-m_5872114806333856756gmail-:ni" style="overflow:hidden;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:small;line-height:1.5;font-family:Arial,Helvetica,sans-serif"><div dir="ltr"><div style="padding:20px 0px 0px;font-size:0.875rem"><span style="font-size:small">I am working of using libfuzzer and asan to test out a third-party library.</span><br><span style="font-size:small">As demonstrated in the tutorial, I wrote a fuzz target to fuzz a specific function in the library. The fuzz target is then linked to the library and compiles clean and I do see some tests generated by the fuzzer. However, I have some questions regarding the "right" way to go about doing this. I have doubts that the fuzzer taking coverage feedback from the fuzztarget and not the library functions (not sure though). Suppose the function in the library being tested is called -</span><span style="font-size:small"> </span><b style="font-size:small">apifunc()</b><span style="font-size:small">. The libfuzzer log has a line which says - </span><b style="font-size:small">apifunc() resp=0x7ff38f83ac20 uninitialized, fixing it</b><span style="font-size:small">. I am not sure what this means. Also, I can see that the apifunc is called and it runs but it does not show up in the </span><span style="font-size:small"> </span><b style="font-size:small">NEW_FUNC[x/xxx]: </b><span style="font-size:small">log lines in the libfuzzer output. </span><table cellpadding="0" style="border-collapse:collapse;margin-top:0px;width:auto;font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:0.875rem;letter-spacing:0.2px;display:block"></table></div><div><div id="gmail-m_5872114806333856756gmail-m_-4875253864227967866gmail-:14q" style="font-size:0.875rem;direction:ltr;margin:8px 0px 0px;padding:0px"><div id="gmail-m_5872114806333856756gmail-m_-4875253864227967866gmail-:13i" style="overflow:hidden;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:small;line-height:1.5"><div dir="ltr"><div><br></div><div>To enable fuzzing. First I build the library with the following libfuzzer flags.</div><div><b>-fsanitize=fuzzer-no-link,address -fsanitize-coverage=edge,indirect-calls</b><br></div><div>I also had to make a blacklist to avoid some buffer overflow and use after free error during this build.<br></div><div><br></div><div>After this, I link the fuzz target with the library and use the following libfuzzer options.</div><div><b>-fsanitize=fuzzer,address</b><br></div><div><b><br></b></div><div>I am looking for some guidance and feedback if this is the right way to go about fuzzing the library and the meaning of <b>uninitialized fixing it </b>line in the log.</div></div></div></div></div></div></div></div></div></div>-- <br><div dir="ltr"><div dir="ltr"><div>Live long and Prosper,</div><div><br></div><div>Shikhar Singh</div></div></div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>