forked from dlundquist/sniproxy
-
Notifications
You must be signed in to change notification settings - Fork 4
450 lines (373 loc) · 15 KB
/
sanitizers.yml
File metadata and controls
450 lines (373 loc) · 15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
name: Sanitizers (ASAN/MSAN/UBSAN)
on:
push:
branches: ["*"]
pull_request:
jobs:
address-sanitizer:
name: AddressSanitizer
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install dependencies
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y \
build-essential autoconf automake libtool pkg-config \
libev-dev libpcre2-dev libc-ares-dev libssl-dev \
libbsd-dev clang
- name: Generate build system
run: |
set -euo pipefail
AUTOCONF_VERSION=2.71 AUTOMAKE_VERSION=1.16 ./autogen.sh
- name: Configure with AddressSanitizer
env:
CC: clang
run: |
set -euo pipefail
./configure --disable-dependency-tracking --enable-asan
- name: Build
run: make -j$(nproc)
- name: Run tests with ASAN
env:
ASAN_OPTIONS: detect_leaks=1:check_initialization_order=1:strict_init_order=1:detect_stack_use_after_return=1:detect_invalid_pointer_pairs=2:strict_string_checks=1
SKIP_BAD_REQUEST_TEST: 1
run: |
set -euo pipefail
make check
- name: Upload test logs
if: failure()
uses: actions/upload-artifact@v7
with:
name: asan-test-logs
path: tests/*.log
if-no-files-found: ignore
memory-sanitizer:
name: MemorySanitizer
runs-on: ubuntu-latest
timeout-minutes: 120
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install build dependencies
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y \
build-essential autoconf automake libtool pkg-config \
clang cmake ninja-build python3
- name: Cache MSAN instrumented libraries
id: cache-msan-libs
uses: actions/cache@v5
with:
path: ~/msan-libs
key: msan-libs-${{ runner.os }}-clang-${{ hashFiles('.github/workflows/sanitizers.yml') }}-v3
- name: Build instrumented libc++ and libc++abi
if: steps.cache-msan-libs.outputs.cache-hit != 'true'
run: |
set -euo pipefail
# Create installation directory
mkdir -p ~/msan-libs
export MSAN_PREFIX=~/msan-libs
# Clone LLVM project for libc++ sources
cd /tmp
git clone --depth=1 --branch=release/17.x https://github.com/llvm/llvm-project.git
cd llvm-project
# Build non-sanitized llvm-tblgen to avoid MSAN aborts in TableGen
mkdir build-tools
cd build-tools
cmake -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_TARGETS_TO_BUILD="X86" \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_ENABLE_WERROR=OFF \
-DLIBCXX_ENABLE_WERROR=OFF \
-DLIBCXXABI_ENABLE_WERROR=OFF \
../llvm
ninja llvm-tblgen
export HOST_LLVM_TABLEGEN="$(pwd)/bin/llvm-tblgen"
cd ..
# Build instrumented libc++ and libc++abi
mkdir build-msan
cd build-msan
# Limit to X86 and skip utils/tests to avoid MSAN noise in TableGen and speed up
cmake -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \
-DLLVM_TARGETS_TO_BUILD="X86" \
-DLLVM_BUILD_UTILS=OFF \
-DLLVM_INCLUDE_UTILS=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_ENABLE_WERROR=OFF \
-DLIBCXX_ENABLE_WERROR=OFF \
-DLIBCXXABI_ENABLE_WERROR=OFF \
-DLLVM_TABLEGEN="$HOST_LLVM_TABLEGEN" \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_INSTALL_PREFIX="$MSAN_PREFIX" \
-DLLVM_USE_SANITIZER=MemoryWithOrigins \
-DCMAKE_C_FLAGS="-fsanitize=memory -fsanitize-memory-track-origins -Wno-strict-overflow" \
-DCMAKE_CXX_FLAGS="-fsanitize=memory -fsanitize-memory-track-origins -Wno-deprecated-declarations -Wno-strict-overflow -Wno-user-defined-literals" \
-DRUNTIMES_CMAKE_ARGS="-DCMAKE_C_COMPILER=clang;-DCMAKE_CXX_COMPILER=clang++;-DCMAKE_LINKER=ld.lld;-DCMAKE_C_FLAGS=-fsanitize=memory -fsanitize-memory-track-origins -Wno-strict-overflow;-DCMAKE_CXX_FLAGS=-fsanitize=memory -fsanitize-memory-track-origins -Wno-deprecated-declarations -Wno-strict-overflow -Wno-user-defined-literals;-DCMAKE_EXE_LINKER_FLAGS=-fsanitize=memory -fuse-ld=lld -rtlib=compiler-rt -Wl,--warn-unresolved-symbols;-DCMAKE_SHARED_LINKER_FLAGS=-fsanitize=memory -fuse-ld=lld -rtlib=compiler-rt -Wl,--warn-unresolved-symbols" \
../llvm
# Disable MSAN error reporting during build (build tools use uninstrumented system libs)
export MSAN_OPTIONS=halt_on_error=0:exitcode=0
ninja cxx cxxabi
ninja install-cxx install-cxxabi
unset MSAN_OPTIONS
echo "✓ Instrumented libc++ built and installed to $MSAN_PREFIX"
- name: Build instrumented libmd
if: steps.cache-msan-libs.outputs.cache-hit != 'true'
run: |
set -euo pipefail
export MSAN_PREFIX=~/msan-libs
cd /tmp
LIBMD_VERSION=1.1.0
if ! wget https://archive.hadrons.org/software/libmd/libmd-${LIBMD_VERSION}.tar.xz; then
echo "ERROR: libmd ${LIBMD_VERSION} not found. Update version in workflow."
exit 1
fi
tar xf libmd-${LIBMD_VERSION}.tar.xz
cd libmd-${LIBMD_VERSION}
CC=clang \
CFLAGS="-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -g -O1" \
LDFLAGS="-fsanitize=memory" \
./configure --prefix="$MSAN_PREFIX"
make -j$(nproc)
make install
echo "✓ Instrumented libmd built"
- name: Build instrumented libev
if: steps.cache-msan-libs.outputs.cache-hit != 'true'
run: |
set -euo pipefail
export MSAN_PREFIX=~/msan-libs
cd /tmp
git clone https://github.com/enki/libev.git
cd libev
# Use latest stable release tag
git fetch --tags
git checkout $(git tag | grep -E '^[0-9]+\.[0-9]+$' | sort -V | tail -n1 || echo master)
sh autogen.sh
# Point configure to our MSAN-instrumented libmd
export PKG_CONFIG_PATH="$MSAN_PREFIX/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
CC=clang \
CPPFLAGS="-I$MSAN_PREFIX/include" \
CFLAGS="-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -g -O1" \
LDFLAGS="-L$MSAN_PREFIX/lib -fsanitize=memory" \
./configure --prefix="$MSAN_PREFIX"
make -j$(nproc)
make install
echo "✓ Instrumented libev built"
- name: Build instrumented PCRE2
if: steps.cache-msan-libs.outputs.cache-hit != 'true'
run: |
set -euo pipefail
export MSAN_PREFIX=~/msan-libs
cd /tmp
PCRE2_VERSION=10.42
if ! wget https://github.com/PCRE2Project/pcre2/releases/download/pcre2-${PCRE2_VERSION}/pcre2-${PCRE2_VERSION}.tar.gz; then
echo "ERROR: PCRE2 ${PCRE2_VERSION} not found. Update version in workflow."
exit 1
fi
tar xzf pcre2-${PCRE2_VERSION}.tar.gz
cd pcre2-${PCRE2_VERSION}
CC=clang \
CFLAGS="-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -g -O1" \
LDFLAGS="-fsanitize=memory" \
./configure --prefix="$MSAN_PREFIX"
make -j$(nproc)
make install
echo "✓ Instrumented PCRE2 built"
- name: Build instrumented c-ares
if: steps.cache-msan-libs.outputs.cache-hit != 'true'
run: |
set -euo pipefail
export MSAN_PREFIX=~/msan-libs
cd /tmp
git clone https://github.com/c-ares/c-ares.git
cd c-ares
# Use latest stable release tag
git fetch --tags
git checkout $(git tag | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n1)
mkdir build
cd build
cmake -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_INSTALL_PREFIX="$MSAN_PREFIX" \
-DCMAKE_C_FLAGS="-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -g -O1" \
-DCMAKE_CXX_FLAGS="-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -g -O1" \
-DCMAKE_EXE_LINKER_FLAGS="-fsanitize=memory" \
-DCMAKE_SHARED_LINKER_FLAGS="-fsanitize=memory" \
..
ninja
ninja install
echo "✓ Instrumented c-ares built"
- name: Build instrumented LibreSSL
if: steps.cache-msan-libs.outputs.cache-hit != 'true'
run: |
set -euo pipefail
export MSAN_PREFIX=~/msan-libs
cd /tmp
LIBRESSL_VERSION=4.2.1
if ! wget https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${LIBRESSL_VERSION}.tar.gz; then
echo "ERROR: LibreSSL ${LIBRESSL_VERSION} not found. Update version in workflow."
exit 1
fi
tar xzf libressl-${LIBRESSL_VERSION}.tar.gz
cd libressl-${LIBRESSL_VERSION}
CC=clang \
CFLAGS="-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -g -O1" \
LDFLAGS="-fsanitize=memory" \
./configure --prefix="$MSAN_PREFIX"
make -j$(nproc)
make install
echo "✓ Instrumented LibreSSL built"
- name: Build instrumented libbsd
if: steps.cache-msan-libs.outputs.cache-hit != 'true'
run: |
set -euo pipefail
export MSAN_PREFIX=~/msan-libs
cd /tmp
LIBBSD_VERSION=0.11.7
if ! wget https://libbsd.freedesktop.org/releases/libbsd-${LIBBSD_VERSION}.tar.xz; then
echo "ERROR: libbsd ${LIBBSD_VERSION} not found. Update version in workflow."
exit 1
fi
tar xf libbsd-${LIBBSD_VERSION}.tar.xz
cd libbsd-${LIBBSD_VERSION}
# Point configure to our MSAN-instrumented libmd
export PKG_CONFIG_PATH="$MSAN_PREFIX/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
CC=clang \
CPPFLAGS="-I$MSAN_PREFIX/include" \
CFLAGS="-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -g -O1" \
LDFLAGS="-L$MSAN_PREFIX/lib -fsanitize=memory" \
./configure --prefix="$MSAN_PREFIX"
make -j$(nproc)
make install
echo "✓ Instrumented libbsd built"
# Create summary
echo "=== MSAN Instrumented Libraries Summary ==="
ls -lh "$MSAN_PREFIX/lib" | head -20
- name: Generate build system
run: |
set -euo pipefail
AUTOCONF_VERSION=2.71 AUTOMAKE_VERSION=1.16 ./autogen.sh
- name: Configure with MemorySanitizer
env:
CC: clang
CXX: clang++
run: |
set -euo pipefail
export MSAN_PREFIX=~/msan-libs
# Configure with MSAN using instrumented libraries
# Set MSAN flags explicitly so configure tests work correctly
export PKG_CONFIG_PATH="$MSAN_PREFIX/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
export CFLAGS="-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -g -I$MSAN_PREFIX/include"
export CXXFLAGS="-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -g -I$MSAN_PREFIX/include -stdlib=libc++ -nostdinc++ -isystem $MSAN_PREFIX/include/c++/v1"
export LDFLAGS="-fsanitize=memory -L$MSAN_PREFIX/lib -Wl,-rpath,$MSAN_PREFIX/lib -stdlib=libc++"
./configure --disable-dependency-tracking
- name: Build
run: |
make -j$(nproc)
- name: Run tests with MSAN
env:
MSAN_OPTIONS: halt_on_error=1:print_stats=1:exitcode=1
SKIP_BAD_REQUEST_TEST: 1
run: |
set -euo pipefail
make check
- name: Upload test logs
if: failure()
uses: actions/upload-artifact@v7
with:
name: msan-test-logs
path: tests/*.log
if-no-files-found: ignore
undefined-behavior-sanitizer:
name: UndefinedBehaviorSanitizer
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install dependencies
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y \
build-essential autoconf automake libtool pkg-config \
libev-dev libpcre2-dev libc-ares-dev libssl-dev \
libbsd-dev clang
- name: Generate build system
run: |
set -euo pipefail
AUTOCONF_VERSION=2.71 AUTOMAKE_VERSION=1.16 ./autogen.sh
- name: Configure with UBSan
env:
CC: clang
run: |
set -euo pipefail
./configure --disable-dependency-tracking --enable-ubsan
- name: Build
run: make -j$(nproc)
- name: Run tests with UBSan
env:
UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1
SKIP_BAD_REQUEST_TEST: 1
run: |
set -euo pipefail
make check
- name: Upload test logs
if: failure()
uses: actions/upload-artifact@v7
with:
name: ubsan-test-logs
path: tests/*.log
if-no-files-found: ignore
combined-sanitizers:
name: ASAN+UBSAN Combined
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install dependencies
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y \
build-essential autoconf automake libtool pkg-config \
libev-dev libpcre2-dev libc-ares-dev libssl-dev \
libbsd-dev clang
- name: Generate build system
run: |
set -euo pipefail
AUTOCONF_VERSION=2.71 AUTOMAKE_VERSION=1.16 ./autogen.sh
- name: Configure with ASAN+UBSan
env:
CC: clang
run: |
set -euo pipefail
./configure --disable-dependency-tracking --enable-asan --enable-ubsan
- name: Build
run: make -j$(nproc)
- name: Run tests with ASAN+UBSan
env:
ASAN_OPTIONS: detect_leaks=1:check_initialization_order=1:strict_init_order=1:detect_stack_use_after_return=1:detect_invalid_pointer_pairs=2:strict_string_checks=1
UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1
SKIP_BAD_REQUEST_TEST: 1
run: |
set -euo pipefail
make check
- name: Upload test logs
if: failure()
uses: actions/upload-artifact@v7
with:
name: combined-sanitizer-test-logs
path: tests/*.log
if-no-files-found: ignore