autobuild: extend autobuild with samba-fuzz job to build the fuzzers in AFL mode...
authorAndrew Bartlett <abartlet@samba.org>
Wed, 4 Dec 2019 09:52:06 +0000 (22:52 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 11 Dec 2019 02:55:32 +0000 (02:55 +0000)
This helps ensure the build_samba.sh file keeps working and the fuzzers build
(because they are excluded from the main build).

This is not in the default autobuild because it uses too much
space on sn-devel (4GB).

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@samba.org>
.gitlab-ci.yml
lib/fuzzing/oss-fuzz/build_samba.sh
lib/fuzzing/oss-fuzz/check_build.sh [new file with mode: 0755]
script/autobuild.py

index 36fe28359b4e6c9a3901814096cbe856c05e85f1..78710f55796b9e75cf427983236a8ab3ced416bf 100644 (file)
@@ -155,6 +155,9 @@ samba-libs:
 samba-static:
   extends: .shared_template
 
+samba-fuzz:
+  extends: .shared_template
+
 ctdb:
   extends: .shared_template
 
@@ -230,6 +233,7 @@ pages:
     - samba-ad-dc-6
     - samba-libs
     - samba-static
+    - samba-fuzz
     # - ctdb  # TODO
     - samba-ctdb
     - samba-ad-dc-ntvfs
index e4783442b207d2ac94c021e877691650a3334a1b..63b81af08106650af1f1672cf3f1ec3b394bf4c2 100755 (executable)
@@ -11,6 +11,9 @@
 #
 # CFLAGS are supplied by the caller, eg the oss-fuzz compile command
 #
+# Additional arguments are passed to configure, to allow this to be
+# tested in autobuild.py
+#
 ADDITIONAL_CFLAGS="$CFLAGS"
 export ADDITIONAL_CFLAGS
 CFLAGS=""
@@ -42,7 +45,9 @@ esac
            --disable-warnings-as-errors \
            --abi-check-disable \
            --fuzz-target-ldflags="$LIB_FUZZING_ENGINE" \
-           --nonshared-binary=ALL LINK_CC="$CXX"
+           --nonshared-binary=ALL \
+           "$@" \
+           LINK_CC="$CXX"
 
 make -j
 
diff --git a/lib/fuzzing/oss-fuzz/check_build.sh b/lib/fuzzing/oss-fuzz/check_build.sh
new file mode 100755 (executable)
index 0000000..cc69cf2
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh -eux
+#
+# A very simple check script to confirm we still provide binaries
+# that look like the targets oss-fuzz wants.
+#
+# A much stronger check is availble in oss-fuzz via
+# infra/helper.py check_build samba
+#
+
+# oss-fuzz provides an OUT variable, so for clarity this script
+# uses the same.  See build_samba.sh
+OUT=$1
+
+# build_samba.sh will have put a non-zero number of fuzzers here.  If
+# there are none, this will fail as it becomes literally fuzz_*
+for bin in $OUT/fuzz_*
+do
+    # Confirm that the chrpath was reset to lib/ in the same directory
+    # as the binary
+    chrpath -l $bin | grep 'RUNPATH=$ORIGIN/lib'
+
+    # Confirm that we link to at least some libraries in this
+    # directory (shows that the libraries were found and copied).
+    ldd $bin | grep "$OUT/lib"
+done
index 2a23c8dbb8700c47c2229f9245aba0a4cc295220..2a0b7da53e554eeed9d5cd2dc3809f7c77acec46 100755 (executable)
@@ -624,7 +624,14 @@ tasks = {
         # retry with nonshared smbd and smbtorture
         ("nonshared-distclean", "make distclean"),
         ("nonshared-configure", "./configure.developer " + samba_configure_params + " --bundled-libraries=talloc,tdb,pytdb,ldb,pyldb,tevent,pytevent --with-static-modules=ALL --nonshared-binary=smbtorture,smbd/smbd"),
-        ("nonshared-make", "make -j"),
+        ("nonshared-make", "make -j")
+        ],
+
+    "samba-fuzz": [
+        # build the fuzzers (static) via the oss-fuzz script
+        ("fuzzers-mkdir-prefix", "mkdir -p ${PREFIX_DIR}"),
+        ("fuzzers-build", "OUT=${PREFIX_DIR} LIB_FUZZING_ENGINE= SANITIZER=address CXX= CFLAGS= ./lib/fuzzing/oss-fuzz/build_samba.sh --enable-afl"),
+        ("fuzzers-check", "./lib/fuzzing/oss-fuzz/check_build.sh ${PREFIX_DIR}")
         ],
 
     # Test Samba without python still builds.  When this test fails
@@ -788,10 +795,11 @@ tasks = {
 }
 
 defaulttasks = list(tasks.keys())
+
 defaulttasks.remove("pass")
 defaulttasks.remove("fail")
 defaulttasks.remove("samba-test-only")
-
+defaulttasks.remove("samba-fuzz")
 if os.environ.get("AUTOBUILD_SKIP_SAMBA_O3", "0") == "1":
     defaulttasks.remove("samba-o3")