● Zion Boggan
repos/Cyclops V2/targets/deep_campaign.sh
zionboggan.com ↗
53 lines · bash
History for this file →
1
set -e
2
export CYCLOPS_HOME=/opt/cyclops-v2
3
PY=/opt/cyclops-venv/bin/python
4
T=/opt/cyclops-v2/targets/src/llama.cpp
5
H=/opt/cyclops-v2/oracle/harnesses
6
W=/opt/cyclops-v2/oracle/work/llamacpp
7
mkdir -p "$W/deep" "$W/deep/crashes" "$W/corpus2"
8
 
9
echo "=== [1/4] guard shallow div-by-zero sites for depth ==="
10
$PY /opt/cyclops-v2/targets/patch_gguf_fuzzdepth.py
11
 
12
echo "=== [2/4] rebuild libggml-base (patched) with ASan ==="
13
cd "$T"
14
cmake --build build-asan --target ggml-base -j4 > "$W/deep/rebuild.log" 2>&1
15
echo "rebuilt: $(find build-asan -name libggml-base.a)"
16
LIBS=$(find "$T/build-asan" -name "libggml*.a" | tr '\n' ' ')
17
 
18
echo "=== [3/4] build deep harness (no_alloc=false: allocates tensors) ==="
19
cat > "$H/llamacpp_gguf_deep.cpp" <<'EOF'
20
// Deep path: no_alloc=false + a ggml_context => parser allocates tensor data,
21
// exercising tensor-offset/size handling where memory-corruption would live.
22
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
23
    if (size > (8u<<20)) return 0;           // cap to keep allocations sane
24
    FILE *f = fmemopen((void*)data, size, "rb");
25
    if (!f) return 0;
26
    struct ggml_context *ctx_data = nullptr;
27
    struct gguf_init_params p; p.no_alloc = false; p.ctx = &ctx_data;
28
    struct gguf_context *ctx = gguf_init_from_file_ptr(f, p);
29
    if (ctx) gguf_free(ctx);
30
    if (ctx_data) ggml_free(ctx_data);
31
    fclose(f);
32
    return 0;
33
}
34
EOF
35
clang++ -g -O1 -fsanitize=fuzzer,address,undefined -fno-omit-frame-pointer \
36
  "$H/llamacpp_gguf_deep.cpp" -I"$T/ggml/include" $LIBS -lm -lpthread -lgomp \
37
  -o "$W/fuzz_deep" 2>"$W/deep/compile.log" \
38
  && echo "DEEP HARNESS COMPILED" || { echo "COMPILE FAILED"; tail -12 "$W/deep/compile.log"; exit 1; }
39
clang++ -g -O1 -fsanitize=fuzzer,address,undefined -fno-omit-frame-pointer \
40
  "$H/llamacpp_gguf_harness.cpp" -I"$T/ggml/include" $LIBS -lm -lpthread -lgomp \
41
  -o "$W/fuzz_meta" 2>>"$W/deep/compile.log" && echo "META HARNESS REBUILT" || true
42
 
43
echo "=== [4/4] launch fork-mode campaign (6h, ignore_crashes, accumulate distinct) ==="
44
cp "$W/seeds/"* "$W/corpus2/" 2>/dev/null || true
45
cd "$W/deep"
46
ASAN_OPTIONS=detect_leaks=0:abort_on_error=1 nohup "$W/fuzz_deep" \
47
  -fork=2 -ignore_crashes=1 -max_total_time=21600 -rss_limit_mb=4096 -timeout=30 \
48
  -artifact_prefix="$W/deep/crashes/d-" "$W/corpus2" "$W/seeds" \
49
  > "$W/deep/fuzz_deep.log" 2>&1 &
50
echo "DEEP_FUZZ_PID=$!"
51
sleep 15
52
echo "=== early deep status ==="; tail -6 "$W/deep/fuzz_deep.log" 2>/dev/null
53
echo "crashes so far: $(ls $W/deep/crashes/ 2>/dev/null | wc -l)"