]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Increase timeout for fuzzers
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 10 Dec 2022 15:22:15 +0000 (09:22 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sat, 10 Dec 2022 17:28:49 +0000 (11:28 -0600)
Some tweaks to try and get backtraces on timeout

Make.inc.in
scripts/jlibtool.c
src/bin/fuzzer.mk
src/lib/util/debug.c

index 477ae3fcdbaf1bc1b9d580fabccbc0ba47c18c0a..11d1dcb01ffc80936f6b08c2a2e6a20eefcd5dff 100644 (file)
@@ -204,12 +204,13 @@ ANALYZE.c       := @clang_path@
 #
 #  Have wrappers for the test tools, so that they run.
 #
-#  We have a hardcoded maximum execution time of 30 seconds
-#  If your test takes > 30 seconds to run, you're doing
+#  We have a hardcoded maximum execution time of 300 seconds
+#  If your test takes > 300 seconds to run, you're doing
 #  something wrong.
 #
-TEST_BIN_DIR = ./$(BUILD_DIR)/bin/local
-TEST_BIN    =  $(JLIBTOOL) $(if ${VERBOSE},--debug,--silent) --timeout=30 --mode=execute $(TEST_BIN_DIR)
+TEST_BIN_DIR        = ./$(BUILD_DIR)/bin/local
+TEST_BIN            = $(JLIBTOOL) $(if ${VERBOSE},--debug,--silent) --timeout=300 --mode=execute $(TEST_BIN_DIR)
+TEST_BIN_NO_TIMEOUT = $(JLIBTOOL) $(if ${VERBOSE},--debug,--silent) --mode=execute $(TEST_BIN_DIR)
 
 #
 #  For creating documentation via doc/all.mk
index faf5ca3b81ebc2da3199c72ed5d5c83b67a2880f..0808592c9d1588fb8eb01b8abbbe2bebbfbf5fe4 100644 (file)
@@ -958,11 +958,10 @@ static int external_spawn(command_t *cmd, __attribute__((unused)) char const *fi
                         */
                        if (timeout) {
                                NOTICE("exec timeout\n");
-                               kill(spawn_pid, SIGKILL);
+                               kill(spawn_pid, SIGALRM);
 
                                waitpid(spawn_pid, &status, 0); /* Cleanup child state */
                                timeout = false;                /* Reset */
-                               return 128 + SIGALRM;           /* Allow the caller to figure out what happened */
                        }
 
                        /*
index 1c916347607eb737be5f3b0e7052699a9e101dec..5f927cbc7b72a27b4dbaac00e4216c310d7cd31f 100644 (file)
@@ -64,7 +64,7 @@ $(TEST_BIN_DIR)/fuzzer_$(PROTOCOL): $(BUILD_DIR)/lib/local/libfreeradius-$(PROTO
 #  increase the size of the corpus by several times.
 #
 fuzzer.$(PROTOCOL): $(TEST_BIN_DIR)/fuzzer_$(PROTOCOL) | src/tests/fuzzer-corpus/$(PROTOCOL)
-       ${Q}$(TEST_BIN)/fuzzer_$(PROTOCOL) \
+       ${Q}$(TEST_BIN_NO_TIMEOUT)/fuzzer_$(PROTOCOL) \
                -artifact_prefix="$(FUZZER_ARTIFACTS)/$(PROTOCOL)/" \
                -max_len=512 $(FUZZER_ARGUMENTS) \
                -D share/dictionary \
@@ -76,7 +76,7 @@ fuzzer.$(PROTOCOL): $(TEST_BIN_DIR)/fuzzer_$(PROTOCOL) | src/tests/fuzzer-corpus
 ifeq "$(CI)" ""
 test.fuzzer.$(PROTOCOL): $(TEST_BIN_DIR)/fuzzer_$(PROTOCOL) | src/tests/fuzzer-corpus/$(PROTOCOL)
        @echo TEST-FUZZER $(PROTOCOL) for $(FUZZER_TIMEOUT)s
-       ${Q}$(TEST_BIN)/fuzzer_$(PROTOCOL) \
+       ${Q}$(TEST_BIN_NO_TIMEOUT)/fuzzer_$(PROTOCOL) \
                -artifact_prefix="$(FUZZER_ARTIFACTS)/$(PROTOCOL)/" \
                -max_len=512 $(FUZZER_ARGUMENTS) \
                -max_total_time=$(FUZZER_TIMEOUT) \
@@ -86,7 +86,7 @@ else
 test.fuzzer.$(PROTOCOL): $(TEST_BIN_DIR)/fuzzer_$(PROTOCOL) | src/tests/fuzzer-corpus/$(PROTOCOL)
        @echo TEST-FUZZER $(PROTOCOL) for $(FUZZER_TIMEOUT)s
        @mkdir -p $(BUILD_DIR)/fuzzer
-       ${Q}if ! $(TEST_BIN)/fuzzer_$(PROTOCOL) \
+       ${Q}if ! $(TEST_BIN_NO_TIMEOUT)/fuzzer_$(PROTOCOL) \
                -artifact_prefix="$(FUZZER_ARTIFACTS)/$(PROTOCOL)/" \
                -max_len=512 $(FUZZER_ARGUMENTS) \
                -max_total_time=$(FUZZER_TIMEOUT) \
@@ -101,7 +101,7 @@ endif
 test.fuzzer.$(PROTOCOL).merge: | src/tests/fuzzer-corpus/$(PROTOCOL)
        @echo MERGE-FUZZER-CORPUS $(PROTOCOL)
        ${Q}[ -e "$(FUZZER_CORPUS_DIR)/$(PROTOCOL)_new" ] || mkdir "$(FUZZER_CORPUS_DIR)/$(PROTOCOL)_new"
-       ${Q}$(TEST_BIN)/fuzzer_$(PROTOCOL) \
+       ${Q}$(TEST_BIN_NO_TIMEOUT)/fuzzer_$(PROTOCOL) \
                -D share/dictionary \
                -max_len=512 $(FUZZER_ARGUMENTS) \
                -merge=1 \
@@ -113,7 +113,7 @@ test.fuzzer.$(PROTOCOL).merge: | src/tests/fuzzer-corpus/$(PROTOCOL)
        ${Q}rm -rf "$(FUZZER_CORPUS_DIR)/$(PROTOCOL)_new"
 
 test.fuzzer.$(PROTOCOL).crash: $(wildcard $(BUILD_DIR)/fuzzer/$(PROTOCOL)/crash-*) $(wildcard $(BUILD_DIR)/fuzzer/$(PROTOCOL)/timeout-*) $(wildcard $(BUILD_DIR)/fuzzer/$(PROTOCOL)/slow-unit-*) $(TEST_BIN_DIR)/fuzzer_$(PROTOCOL) | src/tests/fuzzer-corpus/$(PROTOCOL)
-       $(TEST_BIN)/fuzzer_$(PROTOCOL) \
+       $(TEST_BIN_NO_TIMEOUT)/fuzzer_$(PROTOCOL) \
                -artifact_prefix="$(FUZZER_ARTIFACTS)/$(PROTOCOL)/" \
                -max_len=512 $(FUZZER_ARGUMENTS) \
                -max_total_time=$(FUZZER_TIMEOUT) \
index 5f68ada62c7e6f7727ef997a8037f982d52131b4..6c9536e439ed84ed2d3780541da8220bd94c0df9 100644 (file)
@@ -1292,6 +1292,14 @@ int fr_fault_setup(TALLOC_CTX *ctx, char const *cmd, char const *program)
 #endif
 #ifdef SIGSEGV
                        if (fr_set_signal(SIGSEGV, fr_fault) < 0) return -1;
+#endif
+#ifdef SIGALRM
+                       /*
+                        *  This is used be jlibtool to terminate
+                        *  processes which have been running too
+                        *  long.
+                        */
+                       if (fr_set_signal(SIGALRM, fr_fault) < 0) return -1;
 #endif
                        break;