Skip to content

Set seccomp to trap in the shipped server configuration - #122577

Merged
alexey-milovidov merged 11 commits into
masterfrom
seccomp-trap-default
Oct 8, 2026
Merged

alexey-milovidov merged 11 commits into
masterfrom
seccomp-trap-default

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #119545, as asked in #119545 (comment): the config.xml shipped with the server packages (and so with the Docker image, which uses the same file) now sets seccomp to trap. The setting's own default stays log, so a configuration that omits it keeps running without an enforced policy.

Docker: it works with the default Docker seccomp profile (Docker 29.1, aarch64), so the Docker image needs no exception. The runtime's profile allows the seccomp system call, and the server's filter stacks on top of it: the server process shows Seccomp_filters: 2 and NoNewPrivs: 1 (the watchdog shows 1 and 0). A smoke workload (MergeTree insert/optimize, numbers_mt aggregation, system.stack_trace, url, system flush logs) raised no SIGSYS. A container runtime with a stricter profile that refuses seccomp stops the server from starting in this mode; the comment in the config tells users to switch to log or disabled in that case.

Because CI copies programs/server/config.xml for functional, stress, fuzzer and integration tests, this PR's CI also runs the whole test suite under the enforcing policy. test_seccomp now expects trap on the node that uses the shipped config; it passes locally (11/11).

Integration tests copy the current config.xml to instances that run an older server version from a Docker image (with_installed_binary). A version that already rejects unknown top-level elements but predates seccomp (26.8) would refuse to start, so the test helper now sets skip_check_for_incorrect_settings for such instances.

Changelog category (leave one):

  • Improvement

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

The server configuration file shipped with the packages and the Docker image now sets seccomp to trap, so a system call outside the server's policy terminates the server with a stack trace in the log. Set it to log or disabled if the server runs in a sandbox that refuses the seccomp system call.

Related: #119545

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/122577]

Version info

  • Merged into: 26.10.1.1869-master (included in 26.10 and later)

The setting keeps its `log` default, but the `config.xml` shipped with the
packages and the Docker image now enforces the policy. It works in Docker with
the default seccomp profile: the server's filter stacks on top of the runtime's.

Related: #119545 (comment)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a9a1160]

Summary: ✅


AI Review

Summary

This PR switches the shipped server configuration used by packages and the Docker image to seccomp = trap, fixes runtime reporting so system.server_settings reflects the mode actually in force, and keeps with_installed_binary integration instances bootable by stripping and restoring the setting around old-version upgrades. After reconciling the existing review threads with the current code and diff, I did not find any remaining correctness, safety, performance, or test-coverage issues that warrant new review comments.

Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Measured on commit a9a1160.

Metric Baseline Current Δ
Lines 88.30% 88.30% +0.00%
Functions 91.80% 92.10% +0.30%
Branches 79.70% 79.70% +0.00%

Changed lines: Changed C/C++ lines covered: 53/55 (96.36%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Sep 27, 2026

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

LGTM

@alexey-milovidov alexey-milovidov self-assigned this Sep 27, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-config Server configuration infrastructure: XML/YAML config parsing, preprocessor (includes, substitutio... label Sep 27, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Commit a9a11605ac2b8b08763684a164bb84c50814d692 was not compared: the CI logs cluster did not answer (every POST attempt failed with an exception; stopped retrying after the 1250 s read budget).

See the job log for details.

@clickhouse-gh

clickhouse-gh Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 32 queries analysed

This PR sets seccomp to trap in the shipped config.xml and splits the record of the requested mode from the mode actually in force (including a non-Linux fallback). None of that runs during query execution. The log and trap modes install the same syscall filter and differ only in what happens on a syscall outside the policy, so the PR cannot speed up queries. I downgraded the four flagged improvements (ClickBench Q33 -13.3%, Q34 -14.5%; TPC-H Q1 -20.0%, Q7 -24.7%) to not_sure. On TPC-H Q1 and Q7 the PR medians fall inside master's current range and the base medians fall above it, so the baseline looks older than master's current state. A fresh baseline from the exact base commit should confirm there is no change.

clickbench

⚠️ 3 inconclusive

Flagged queries (3 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 28 not_sure 1064 1008 -5.2% <0.0001 Already not_sure: the -5.2% shift is borderline, the two tests disagree, and the source runs were noisy. The PR changes only seccomp startup logic and the shipped config, not query execution.
⚠️ 33 not_sure 1153 1000 -13.3% <0.0001 aggregation: The -13.3% gain and lower CPU are on a heavy GROUP BY path this PR does not touch. Moving the shipped config from the log filter to an identical trap filter cannot make queries faster.
⚠️ 34 not_sure 1164 995 -14.5% <0.0001 aggregation: The -14.5% change follows the same pattern as Q33, but the diff only changes seccomp mode tracking at startup and the default config value. No code on the aggregation path changed.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

⚠️ 2 inconclusive

Flagged queries (2 of 22)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 1 not_sure 65 52 -20.0% <0.0001 The PR median of 52 ms is inside master's current range of 50-64 ms, while the base median of 65 ms is above it. The -20.0% looks like a baseline drift on a noisy query, not an effect of the seccomp change.
⚠️ 7 not_sure 81 61 -24.7% <0.0001 join_operator: The PR median of 61 ms is inside master's current range of 60-78 ms, while the base median of 81 ms is above it. The -24.7% reflects an older baseline, not this config-only change.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

Debug info
  • StressHouse run: 28db21a2-5335-41bb-8584-feb306b39ad4
  • MIRAI run: 0a9d0a57-2cf2-43be-98b5-dae3be1624ef
  • PR check IDs:
    • clickbench_383711_1791474297
    • clickbench_383717_1791474297
    • clickbench_383723_1791474297
    • tpch_adapted_1_official_383735_1791474297
    • tpch_adapted_1_official_383745_1791474297
    • tpch_adapted_1_official_384347_1791474443

alexey-milovidov and others added 2 commits October 3, 2026 14:30
… `config.xml`

Integration tests copy `programs/server/config.xml` from the current sources to every
instance, including those running an older server version from a Docker image
(`with_installed_binary=True`). Since the shipped config sets `seccomp`, a 26.8 server,
which already rejects unknown top-level elements but does not know `seccomp`, refused
to start with `UNKNOWN_ELEMENT_IN_CONFIG`, failing all of `test_text_index_upgrade`.

Set `skip_check_for_incorrect_settings` for such instances.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=122577&sha=836e40dc2785917ab940e6b8761aca52b9588af6&name_0=PR&name_1=Integration%20tests%20%28amd_llvm_coverage%2C%201%2F8%29
#122577

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 The test_text_index_upgrade failures came from the 26.8 node: integration tests copy the current config.xml to instances that run an older version from a Docker image, and 26.8 already refuses unknown top-level elements but does not know seccomp (UNKNOWN_ELEMENT_IN_CONFIG). Commit 307a458 sets skip_check_for_incorrect_settings for with_installed_binary instances. test_text_index_upgrade passes locally (6/6). I also merged master. The std::terminate in TransactionManager::finalizeCommittedTransaction from the sync run is unrelated (signal 6, not SIGSYS) and is tracked in #115501.

Comment thread programs/server/config.xml Resolved
alexey-milovidov and others added 2 commits October 5, 2026 06:46
… exists only on x86_64 and aarch64

On other architectures `installSeccompFilter` only sets `PR_SET_NO_NEW_PRIVS` and the server logs a
warning and runs without a policy, so say that next to `<seccomp>trap</seccomp>` instead of implying
that every Linux build enforces it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failures: 04825_quantile_deterministic_alter_add_modify_column (https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=122577&sha=50a761d9f048f9a6713b6580fdd77150328a8da8&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29, 27 PRs in the last 10 days) and 04819_dynamic_aggregate_function_state_version (https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=122577&sha=50a761d9f048f9a6713b6580fdd77150328a8da8&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20s3%20storage%2C%20DBReplicated%2C%20parallel%2C%201%2F2%29, 48 PRs in the last 10 days, previously #116341) and provide a fix in a separate PR. If the fix is already in progress, link it here. (The Build (amd_fuzzers) failure was a master breakage on 2026-10-03, which has since been fixed; master is merged into this branch.)

Comment thread tests/integration/helpers/cluster.py Resolved
Comment thread src/Core/ServerSettings.cpp Resolved
@groeneai

groeneai commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

alexey-milovidov and others added 2 commits October 6, 2026 05:46
…force, strip `seccomp` from the config of old-version test instances

`system.server_settings` now shows the mode of the filter actually installed:
`disabled` on architectures without a policy and in the `log` mode when the
kernel cannot install its filter. The reload warning compares against the
requested mode, tracked separately by `getRequestedSeccompMode`.

Integration-test instances with `with_installed_binary` no longer disable
`skip_check_for_incorrect_settings` for their whole lifetime; only the
`seccomp` element unknown to older versions is removed from their copy of
`config.xml`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread tests/integration/helpers/cluster.py Resolved
…to the latest version

`with_installed_binary` instances strip `seccomp` from the main config so that
the old version starts, but `restart_with_latest_version` reused that config,
so the fresh binary ran with the built-in default instead of the shipped
`trap`. Put the stripped element into `config.d` before starting the latest
version, and remove it again in `restart_with_original_version`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread tests/integration/helpers/cluster.py Resolved
…ping `seccomp` for old versions

Support YAML main configs, write the restored setting under `config_root_name`,
and fail fast for unsupported main config formats in `with_installed_binary` instances.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread programs/server/config.xml Resolved
…n non-Linux builds

The shipped `config.xml` is also embedded into the generic installer used on
macOS and FreeBSD, where `<seccomp>trap</seccomp>` was silently inert: no
startup warning, and `system.server_settings` showed `trap`. Now
`installSeccompFilter` exists on every OS; outside Linux it installs nothing,
records `disabled` as the mode in force, and the server logs a warning.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=122577&sha=a1d992f20183e70cb1e9902d4155d200ff653897&name_0=PR&name_1=Upgrade%20check%20%28amd_release%29 (Error message in clickhouse-server.log: a stress-phase mutation with throwIf(1) keeps being retried with FUNCTION_THROW_IF_VALUE_IS_NON_ZERO, despite #120978) and provide a fix in a separate PR. It is unrelated to the seccomp change here. If the fix is already in progress, link it here.

@groeneai

groeneai commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Acknowledged. I'm investigating this; I'll follow up here with a separate PR (or my findings) shortly.

What this job's logs show so far: 04341_broken_mutation_part_log_flush.sql left test_7.t_failed_mutation_part_log with its failing throwIf(1) mutation (its DROP is ignored under --upgrade-check), which is the case #120978 kills. But 01160_table_dependencies.sh then ran detach database test_7 on the shared stress database (13:58:04). It had detached that table and most of the others, and was still running when the old server was stopped. system.mutations lists only attached tables, so the kill step (13:59:12) found 0 unfinished mutations. DETACH DATABASE is undone by a restart, so the upgraded server attached test_7 again and retried the mutation from 14:00:37 to 14:01:37.

#123841 (open) cancels leftover queries before the kill, but does not bring the detached tables back, so it does not cover this. I'll send a separate PR so that the kill step also reaches the tables the stress phase left detached, and link it here.

@groeneai

groeneai commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

The fix is in #124532: it restarts the previous release right before the kill step, so the kill also sees the mutations of tables that an unfinished DETACH left detached.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 Thanks @groeneai: the Upgrade check fix is tracked in #124532.

Merged master to refresh the branch. The CH Inc sync failure is not caused by the seccomp change: the Received signal 6 aborts there are std::terminate in the noexcept MergeTreeTransaction::afterCommit (a QUERY_WAS_CANCELLED from the distributed cache). A seccomp trap would show up as SIGSYS, not as an abort. That crash is tracked in the private repository and was already fixed on its master, so the new sync run will include the fix. The other failures, a distributed cache test timeout and test_storage_iceberg_with_spark/test_compaction.py, do not touch the code paths this PR changes.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Oct 8, 2026
Merged via the queue into master with commit 4790728 Oct 8, 2026
153 checks passed
@alexey-milovidov
alexey-milovidov deleted the seccomp-trap-default branch October 8, 2026 22:19
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 8, 2026
@clickgapai

Copy link
Copy Markdown
Contributor

@alexey-milovidov — title/description suggestions:

Description (currently misleading):

  • Why: The body says the integration test helper sets skip_check_for_incorrect_settings for with_installed_binary instances. The merged cluster.py does not: it strips <seccomp> from their copy of config.xml and restores it in config.d/zz_seccomp_latest_version.xml on restart_with_latest_version (changed in 8cb4df3). The changelog entry is only a link.

  • Suggested addition:

    Integration tests: for with_installed_binary instances the helper removes <seccomp> from their copy of config.xml, because old versions such as 26.8 reject the unknown element, and writes it back to config.d/zz_seccomp_latest_version.xml on restart_with_latest_version. Unknown-setting validation stays on for both binaries.

Ignore if intentional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-config Server configuration infrastructure: XML/YAML config parsing, preprocessor (includes, substitutio... pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants