[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 09:36:01 UTC 2018


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