From 91ba13054a47dd114c0f46ca54e75bc347cb058a Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sun, 17 Mar 2024 15:53:23 +0100 Subject: [PATCH] test,ci: fix [AM]San, disable ASLR (#4365) The kernel that ships with the new Ubuntu 22.04 CI image seems to have a PIE slide that is bigger than the sanitizer runtimes can handle. It makes ASan fail with thousands of "AddressSanitizer:DEADLYSIGNAL" warnings, and MSan error with complaints about memory accesses outside known ranges. Disabling address space layout randomization fixes both. This commit also fixes a small bug in the platform_output test where the cgroups v1 logic did not handle the "unlimited quota" special case properly. Ubuntu 20.04 still uses cgroups v1. --- .github/workflows/sanitizer.yml | 5 +++++ test/test-platform-output.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sanitizer.yml b/.github/workflows/sanitizer.yml index 4fca161d..fb2f1eb2 100644 --- a/.github/workflows/sanitizer.yml +++ b/.github/workflows/sanitizer.yml @@ -23,6 +23,11 @@ jobs: - name: Envinfo run: npx envinfo + # [AM]SAN fail on newer kernels due to a bigger PIE slide + - name: Disable ASLR + run: | + sudo sysctl -w kernel.randomize_va_space=0 + - name: ASAN Build run: | mkdir build-asan diff --git a/test/test-platform-output.c b/test/test-platform-output.c index f5218c58..4e5300da 100644 --- a/test/test-platform-output.c +++ b/test/test-platform-output.c @@ -110,7 +110,7 @@ TEST_IMPL(platform_output) { if (cgroup_version == 0) { file = fopen("/sys/fs/cgroup/cpu,cpuacct/cpu.cfs_quota_us", "r"); if (file) { - if (fscanf(file, "%lu", "a) == 1 && quota > 0) { + if (fscanf(file, "%lu", "a) == 1 && quota > 0 && quota < ~0ULL) { fclose(file); file = fopen("/sys/fs/cgroup/cpu,cpuacct/cpu.cfs_period_us", "r"); if (file && fscanf(file, "%lu", &period) == 1) {