Skip to content

Commit 912869b

Browse files
TheodorNEngoysonatique
authored andcommitted
CI(linux): ASan/UBSan + hardening; staged install (DESTDIR); bounded BOS fuzzer smoke inside linux job
Closes libusb#1707
1 parent 993d72a commit 912869b

File tree

2 files changed

+43
-11
lines changed

2 files changed

+43
-11
lines changed

.github/workflows/linux.yml

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
11
name: linux
22

3-
# Controls when the action will run. Triggers the workflow on push or pull request
4-
# events but only for the master branch
53
on: [push, pull_request]
64

7-
# A workflow run is made up of one or more jobs that can run
8-
# sequentially or in parallel
95
jobs:
10-
# This workflow contains a single job called "build"
116
build:
127
runs-on: ubuntu-latest
13-
14-
# Steps represent a sequence of tasks that will be executed as part of the job
158
steps:
16-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job
17-
# can access it
189
- uses: actions/checkout@v3
1910

2011
- name: setup prerequisites
2112
run: |
2213
sudo apt update
23-
sudo apt install autoconf automake libtool libudev-dev m4
14+
sudo apt install -y autoconf automake libtool libudev-dev m4 pkg-config clang llvm
2415
2516
- name: bootstrap
2617
run: ./bootstrap.sh
@@ -48,3 +39,44 @@ jobs:
4839

4940
- name: umockdev test
5041
run: .private/ci-container-build.sh docker.io/amd64/ubuntu:rolling
42+
43+
# --- Sanitizers + BOS fuzzer smoke, inside linux job (PRs only) ---
44+
- name: Sanitized rebuild (ASan/UBSan + hardening flags)
45+
if: ${{ github.event_name == 'pull_request' }}
46+
env:
47+
CC: clang
48+
CXX: clang++
49+
CFLAGS: "-O1 -g -fsanitize=address,undefined -fno-omit-frame-pointer -fstack-protector-all -ftrivial-auto-var-init=pattern -Wwrite-strings"
50+
CXXFLAGS: "-O1 -g -fsanitize=address,undefined -fno-omit-frame-pointer -fstack-protector-all -ftrivial-auto-var-init=pattern -Wwrite-strings"
51+
LDFLAGS: "-fsanitize=address,undefined"
52+
run: |
53+
rm -rf build-asan
54+
mkdir -p build-asan
55+
cd build-asan
56+
CC=$CC CXX=$CXX CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS" ../configure
57+
make -j
58+
59+
- name: Stage install (pkg-config + runtime)
60+
if: ${{ github.event_name == 'pull_request' }}
61+
run: |
62+
make -C build-asan install DESTDIR="$PWD/build-asan/stage"
63+
echo "PKG_CONFIG_PATH=$PWD/build-asan/stage/usr/local/lib/pkgconfig" >> $GITHUB_ENV
64+
echo "LD_LIBRARY_PATH=$PWD/build-asan/stage/usr/local/lib" >> $GITHUB_ENV
65+
66+
- name: Build & smoke BOS descriptor fuzzer (C, sanitized, bounded)
67+
if: ${{ github.event_name == 'pull_request' }}
68+
env:
69+
ASAN_OPTIONS: "detect_leaks=0:allocator_may_return_null=1"
70+
UBSAN_OPTIONS: "print_stacktrace=1:halt_on_error=1"
71+
run: |
72+
# Compile against the STAGED headers/libs (DESTDIR), not /usr/local
73+
clang -std=c99 tests/fuzz/fuzz_bos_descriptor.c \
74+
-I"$PWD/build-asan/stage/usr/local/include/libusb-1.0" \
75+
-fsanitize=fuzzer,address,undefined -fno-omit-frame-pointer \
76+
-fstack-protector-all -ftrivial-auto-var-init=pattern -Wwrite-strings \
77+
-L"$PWD/build-asan/stage/usr/local/lib" -lusb-1.0 \
78+
-o fuzz_bos_descriptor
79+
80+
./fuzz_bos_descriptor tests/fuzz/corpus/bos \
81+
-seed=1 -runs=200 -max_total_time=15 -timeout=5 -rss_limit_mb=1536 -print_final_stats=1
82+
# --- end sanitizers + fuzzer smoke ---

libusb/version_nano.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
#define LIBUSB_NANO 11989
1+
#define LIBUSB_NANO 11990

0 commit comments

Comments
 (0)