[ovs-dev] [PATCH] oss-fuzz: Move oss-fuzz test harnesses and fuzzer configs to ovs source repo

Bhargava Shastry bshastry at sect.tu-berlin.de
Mon Jul 16 12:07:38 UTC 2018


Update: I fixed these errors in the attached patch that supersedes the
patch here (https://patchwork.ozlabs.org/patch/942118/)

The major change is that I add the following line for each fuzz target
binary in the tests/oss-fuzz/automake.mk file:

e.g.,
tests_oss_fuzz_flow_extract_target_LDFLAGS = $(LIB_FUZZING_ENGINE) \
                                            -lc++

Regards,
Bhargava

On 07/16/2018 11:45 AM, Bhargava Shastry wrote:
> Oops, here's the link failure log:
> 
> ```
> /usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../x86_64-linux-gnu/crt1.o: In
> function `_start':
> (.text+0x20): undefined reference to `main'
> clang-7: error: linker command failed with exit code 1 (use -v to see
> invocation)
> Makefile:4159: recipe for target 'tests/oss-fuzz/flow_extract_target' failed
> make: *** [tests/oss-fuzz/flow_extract_target] Error 1
> fuzzers build failed.
> ```
> 
> The main symbol is provided by libfuzzer (clang++ -lFuzzingEngine)
> 
> Regards,
> Bhargava
> 
> On 07/16/2018 11:36 AM, Bhargava Shastry wrote:
>> Hi Ben,
>>
>>> Never mind that one, I failed to check in some of that.
>>>
>>> I sent it formally:
>>>         https://patchwork.ozlabs.org/patch/942118/
>>
>> Thanks for the patch. This fixes the previous error. Now, there are some
>> new errors during the compilation/linking process. I think most of this
>> can be fixed if I figure out how automake works. In a nutshell, here's
>> the problem:
>>
>> - oss-fuzz provides compilation flags that can be plugged in like so
>> ```
>> CC=clang
>> CXX=clang++
>> CFLAGS=-O1 -fno-omit-frame-pointer -gline-tables-only
>> -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address
>> -fsanitize-address-use-after-scope -fsanitize=fuzzer-no-link
>> CXXFLAGS=-O1 -fno-omit-frame-pointer -gline-tables-only
>> -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address
>> -fsanitize-address-use-after-scope -fsanitize=fuzzer-no-link -stdlib=libc++
>> ```
>>
>> And here's what I used to do before
>>
>> - Use clang and CFLAGS above plus some additional includes to compile
>> each of the fuzzer tests
>> - Use clang++ and additional linker flags to link these into a fuzzer binary
>>
>> Now, I see that the compilation works
>> ```
>> depbase=`echo tests/oss-fuzz/flow_extract_target.o | sed
>> 's|[^/]*$|.deps/&|;s|\.o$||'`;\
>> clang -DHAVE_CONFIG_H -I.    -I ./include -I ./include -I ./lib -I ./lib
>> -I/usr/include   -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare
>> -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum
>> -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes
>> -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers
>> -Wthread-safety -fno-strict-aliasing -Wswitch-bool
>> -Wlogical-not-parentheses -Wsizeof-array-argument -Wshift-negative-value
>> -Qunused-arguments -Wshadow -Wno-null-pointer-arithmetic    -O1
>> -fno-omit-frame-pointer -gline-tables-only
>> -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address
>> -fsanitize-address-use-after-scope -fsanitize=fuzzer-no-link -MT
>> tests/oss-fuzz/flow_extract_target.o -MD -MP -MF $depbase.Tpo -c -o
>> tests/oss-fuzz/flow_extract_target.o
>> tests/oss-fuzz/flow_extract_target.c &&\
>> mv -f $depbase.Tpo $depbase.Po
>> ```
>>
>> However, the linking fails
>> ```
>> libtool: link: clang -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare
>> -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum
>> -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes
>> -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers
>> -Wthread-safety -fno-strict-aliasing -Wswitch-bool
>> -Wlogical-not-parentheses -Wsizeof-array-argument -Wshift-negative-value
>> -Qunused-arguments -Wshadow -Wno-null-pointer-arithmetic -O1
>> -fno-omit-frame-pointer -gline-tables-only
>> -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address
>> -fsanitize-address-use-after-scope -fsanitize=fuzzer-no-link -o
>> tests/oss-fuzz/flow_extract_target tests/oss-fuzz/flow_extract_target.o
>> -L/usr/lib lib/.libs/libopenvswitch.a -lssl -lcrypto -latomic
>> ```
>>
>> I think adding -lFuzzingEngine should fix this but another variable
>> between my build script and automake is the use of clang++ for linking.
>>
>> Do you know how I can experiment with different linker flags and
>> compiler/linker in automake?
>>
>> Regards,
>> Bhargava
>>
>>
> 

-- 
Bhargava Shastry <bshastry at sect.tu-berlin.de>
Security in Telecommunications
TU Berlin / Telekom Innovation Laboratories
Ernst-Reuter-Platz 7, Sekr TEL 17 / D - 10587 Berlin, Germany
phone: +49 30 8353 58235
Keybase: https://keybase.io/bshastry


More information about the dev mailing list