Skip to content

SSL/ACVP Test Integration for FIPS#1503

Open
DimensionWieldr wants to merge 9 commits intoAltinity:releases/25.3.8-fipsfrom
DimensionWieldr:releases/25.3.8-fips-ssl
Open

SSL/ACVP Test Integration for FIPS#1503
DimensionWieldr wants to merge 9 commits intoAltinity:releases/25.3.8-fipsfrom
DimensionWieldr:releases/25.3.8-fips-ssl

Conversation

@DimensionWieldr
Copy link
Collaborator

@DimensionWieldr DimensionWieldr commented Mar 10, 2026

Changelog category (leave one):

  • Testing/Packaging Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

  • The AWS-LC SSL test runner can be run against the ClickHouse FIPS binary: ./runner_binary -shim-path .../build/programs/clickhouse-ssl-shim -handshaker-path .../build/programs/clickhouse-ssl-handshaker
  • The AWS-LC ACVP tests can be run against the ClickHouse FIPS binary: go run check_expected.go -tool .../aws-lc/build/acvptool -module-wrappers "modulewrapper:/whereveryoubuiltCH/programs/clickhouse-acvp-server,testmodulewrapper:/aws-lc/build/testmodulewrapper" -tests tests.json
  • The musl-based posix_spawn in the glibc-compat layer never applied file actions (close/dup2/open/chdir). The child process now runs the full file-actions list before exec, so split-handshake tests work when the shim spawns the handshaker.
  • Added clickhouse-ssl-shim, clickhouse-ssl-handshaker, and clickhouse-acvp-server as modes of the main binary (same pattern as other tools). They wrap the unmodified AWS-LC shim/handshaker logic (or act as a module wrapper for ACVP) and are built only when FIPS_CLICKHOUSE=ON and AWSLC_SRC_DIR is set.

CI/CD Options

Exclude tests:

  • Fast test
  • Integration Tests
  • Stateless tests
  • Stateful tests
  • Performance tests
  • All with ASAN
  • All with TSAN
  • All with MSAN
  • All with UBSAN
  • All with Coverage
  • All with Aarch64
  • All Regression
  • Disable CI Cache

Regression jobs to run:

  • Fast suites (mostly <1h)
  • Aggregate Functions (2h)
  • Alter (1.5h)
  • Benchmark (30m)
  • ClickHouse Keeper (1h)
  • Iceberg (2h)
  • LDAP (1h)
  • Parquet (1.5h)
  • RBAC (1.5h)
  • SSL Server (1h)
  • S3 (2h)
  • Tiered Storage (2h)

Made-with: Cursor
Signed-off-by: Julian Huang <jhuang@altinity.com>
Signed-off-by: Julian Huang <jhuang@altinity.com>
@DimensionWieldr DimensionWieldr force-pushed the releases/25.3.8-fips-ssl branch from b1703f1 to f4233e2 Compare March 10, 2026 21:08
Copy link
Collaborator

@zvonand zvonand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have two identic glibc_compat.c files? Can it be moved into one place?

…ndshaker

Move the identical glibc_compat.c files from ssl-shim/ and ssl-handshaker/
into a shared programs/ssl-common/ directory. Also add the gtest include
path required by test_util.cc to both CMakeLists.

Signed-off-by: Julian Huang <jhuang@altinity.com>
The FIPS 2.0.0 shim sources do not include any gtest headers,
so this include path is not needed.

Signed-off-by: Julian Huang <jhuang@altinity.com>
@DimensionWieldr DimensionWieldr force-pushed the releases/25.3.8-fips-ssl branch from 7e737fe to 4e4f1cf Compare March 11, 2026 00:27
@svb-alt svb-alt added fips Work related to Altinity FIPS releases fips-25.3 labels Mar 11, 2026
Signed-off-by: Julian Huang <jhuang@altinity.com>
@DimensionWieldr DimensionWieldr changed the title SSL Test Integration for FIPS SSL/ACVP Test Integration for FIPS Mar 11, 2026
@vzakaznikov
Copy link
Collaborator

Quick review notes (actionable):

  1. Build-guard mismatch can break linking
  • programs/main.cpp registers ssl-shim / ssl-handshaker / acvp-server under #if defined(FIPS_CLICKHOUSE).
  • But the corresponding targets are only created when FIPS_CLICKHOUSE AND DEFINED AWSLC_SRC_DIR (and Linux-only for handshaker/acvp).
  • This can produce unresolved entrypoints in some valid config combos.
  • Suggested fix: gate main.cpp declarations/registrations with the same conditions as target creation.
  1. Global --allow-multiple-definition is broader than needed
  • programs/CMakeLists.txt applies target_link_options(clickhouse ... --allow-multiple-definition) to the main binary whenever FIPS+AWSLC is enabled.
  • This can mask unintended duplicate-symbol regressions outside the shim/handshaker scope.
  • Suggested fix: constrain this to the smallest possible link boundary (or switch to a narrower symbol/target strategy).

The posix_spawn file-actions restoration itself looks necessary and directionally correct.

@vzakaznikov
Copy link
Collaborator

Follow-up finding on posix_spawn:

I checked upstream musl, and yes — the original full implementation includes the full file-actions path (addclose, adddup2, addopen, addchdir_np, addfchdir_np) plus additional safety logic.

For the split-handshake path in AWS-LC (which relies on posix_spawn_file_actions_addclose/adddup2 before posix_spawn), upstream musl behavior is a direct fit and should work for this PR’s intended use.

Useful upstream references:

Notably, upstream also has robustness around file-actions potentially clobbering the internal error-reporting pipe fd during spawn.

Gate ssl-shim/ssl-handshaker/acvp-server declarations in main.cpp with
per-target ENABLE_CLICKHOUSE_* defines (via config_tools.h) that match
the exact CMake conditions under which targets are created, preventing
unresolved symbols when FIPS_CLICKHOUSE is set without AWSLC_SRC_DIR
or on non-Linux platforms.

Move the --allow-multiple-definition linker flag from the global
clickhouse target into each of the three library targets as an INTERFACE
property, so the flag only enters the link when those specific libraries
are actually consumed.

Signed-off-by: Julian Huang <jhuang@altinity.com>
Made-with: Cursor
Replace the partial posix_spawn with the complete upstream musl
implementation (https://git.musl-libc.org/cgit/musl/tree/src/process/posix_spawn.c),
adapted for the glibc sysroot headers used by ClickHouse.

Key safety improvements from upstream:
- Pipe fd clobbering protection: if a file action targets the
  error-reporting pipe fd, dup it to an unoccupied fd first
- Close-on-exec set after file actions (pipe may have been moved)
- Block all signals before pipe2/clone; unblock after exec
- EPIPE-aware error reporting back to parent
- Support for POSIX_SPAWN_SETSID, SETPGROUP, RESETIDS, SETSIGDEF
- Larger stack (1024 + PATH_MAX)

Adaptations from upstream musl:
- Uses glibc sysroot field names (__ss/__sd vs __mask/__def)
- Keeps __posix_spawnx exec-function parameter (glibc attr has no __fn)
- Omits LOCK(__abort_lock) (musl-internal, not available)
- Omits __get_handler_set (musl-internal; signals are blocked for the
  child's brief pre-exec window so parent handlers cannot fire)
- Uses clone() instead of musl-internal __clone()

Signed-off-by: Julian Huang <jhuang@altinity.com>
Made-with: Cursor
…2, used only for ssl/acvp tests

Signed-off-by: Julian Huang <jhuang@altinity.com>
…t the rest of CH

Signed-off-by: Julian Huang <jhuang@altinity.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fips Work related to Altinity FIPS releases fips-25.3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants