Skip to content

Add writev and shutdown to system-probe seccomp profile#2986

Merged
tbavelier merged 1 commit into
mainfrom
vitkyrka/disco-seccomp
May 7, 2026
Merged

Add writev and shutdown to system-probe seccomp profile#2986
tbavelier merged 1 commit into
mainfrom
vitkyrka/disco-seccomp

Conversation

@vitkyrka

@vitkyrka vitkyrka commented May 7, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds writev and shutdown to the default system-probe seccomp profile (SCMP_ACT_ERRNO default), in DefaultSyscallsForSystemProbe().

Motivation

Required by system-probe-lite (Rust/hyper-based) which uses vectored writes (writev) for HTTP responses and shutdown(2) to close the write half of connections. The Go-based system-probe didn't surface these as a problem because net/http buffers responses through bufio.Writer and writes them via plain write(2), and the HTTP/1 keep-alive happy path used by the agent's checks never triggers a shutdown(2) (Go only calls CloseWrite in edge cases like 431 oversized headers or partially-consumed request bodies).

Hyper, by contrast, calls shutdown(SHUT_WR) at the end of every served connection (proto/h1/dispatch.rsFuture::poll passes should_shutdown=true and the dispatcher invokes poll_shutdown once is_done()), and uses tokio's AsyncWrite::poll_write_vectored which translates to writev(2) — both of which the existing profile's SCMP_ACT_ERRNO default rejected with EPERM.

When the operator deploys an agent with serviceDiscovery.enabled: true and a node Agent image >= 7.78.0, the operator sets DD_DISCOVERY_USE_SYSTEM_PROBE_LITE=true, the system-probe binary execs into system-probe-lite, and hyper's first writev returns EPERM. The agent's pkg/system-probe/api/client/check.go:ensureStarted() retries GET /debug/stats every 5s and only ever sees EOF, blocking the discovery check from starting at all:

SYS-PROBE-LITE | ERROR | Error serving connection: error writing a body to connection
                                                  ^-- BodyWrite, EPERM (Operation not permitted)

CORE | WARN | system-probe not started yet: Get "http://sysprobe/debug/stats": EOF

After adding the two syscalls, both endpoints respond correctly and the discovery check runs cleanly.

Additional Notes

  • Mirrors the equivalent fix in helm-charts#2634 (which also adds chown — already allowed in the operator's profile, so not needed here).
  • writev and shutdown are not security-sensitive (basic socket I/O primitives); they are already in the upstream Docker default seccomp profile.
  • TestDefaultSyscallsForSystemProbe references DefaultSyscallsForSystemProbe() directly, so it picks up the additions automatically — no test update required.

Minimum Agent Versions

  • Agent: 7.78.0+ (only when serviceDiscovery.enabled: true causes the operator to set DD_DISCOVERY_USE_SYSTEM_PROBE_LITE=true)

Describe your test plan

Verified end-to-end on a kind cluster (aarch64): built the operator from this branch, deployed a DatadogAgent with features.serviceDiscovery.enabled: true and an agent image execing into system-probe-lite. With the fix:

  • kubectl exec ... -c system-probe -- curl --unix-socket /var/run/sysprobe/sysprobe.sock http://sysprobe/debug/stats returns {} (was empty reply).
  • 0 Error serving connection log lines in system-probe-lite.
  • 0 EOF warnings on the agent's ensureStarted() probe.
  • The seccomp configmap (datadog-system-probe-seccomp) generated by the operator includes both writev and shutdown (191 syscalls total).

Checklist

  • PR has at least one valid label: bug
  • PR has a milestone or the qa/skip-qa label
  • All commits are signed

Required by system-probe-lite (Rust/hyper-based) which uses vectored
writes (`writev`) for HTTP responses and `shutdown(2)` to close the
write half of connections. The Go-based system-probe didn't surface
these as a problem because net/http buffers responses through
bufio.Writer and writes them via plain `write(2)`, and the HTTP/1
keep-alive happy path used by the agent's checks never triggers a
`shutdown(2)` (Go only calls `CloseWrite` in edge cases like 431
oversized headers or partially-consumed request bodies).

Without this fix, the seccomp profile (defaultAction SCMP_ACT_ERRNO)
returns EPERM for `writev`/`shutdown`, surfacing as
"error writing a body to connection" / "error shutting down connection"
in system-probe-lite logs and "EOF" on the agent's
`GET /debug/stats` startup probe, preventing the discovery check from
ever starting.

Mirrors helm-charts#2634.
@vitkyrka vitkyrka added the bug Something isn't working label May 7, 2026
@vitkyrka vitkyrka added this to the v1.27.0 milestone May 7, 2026
@codecov-commenter

codecov-commenter commented May 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 40.76%. Comparing base (d3652e6) to head (f0312f5).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2986   +/-   ##
=======================================
  Coverage   40.75%   40.76%           
=======================================
  Files         332      332           
  Lines       28197    28199    +2     
=======================================
+ Hits        11493    11495    +2     
  Misses      15929    15929           
  Partials      775      775           
Flag Coverage Δ
unittests 40.76% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...controller/datadogagent/component/agent/default.go 44.23% <100.00%> (+0.15%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d3652e6...f0312f5. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@datadog-official

This comment has been minimized.

@vitkyrka
vitkyrka marked this pull request as ready for review May 7, 2026 11:06
@vitkyrka
vitkyrka requested review from a team May 7, 2026 11:06
@tbavelier
tbavelier merged commit 97a7761 into main May 7, 2026
48 of 50 checks passed
@tbavelier
tbavelier deleted the vitkyrka/disco-seccomp branch May 7, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working team/container-platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants