Skip to content

[blk-threaded - 3/5] seccomp: add block worker thread filter - #6131

Open
PierreBertholom wants to merge 4 commits into
pbertho/blk-threaded-04from
pbertho/blk-threaded-09
Open

PierreBertholom wants to merge 4 commits into
pbertho/blk-threaded-04from
pbertho/blk-threaded-09

Conversation

@PierreBertholom

@PierreBertholom PierreBertholom commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

[3/5] part of the PR stack starting with #6123

Add seccomp support for the block worker thread and update the related tools and documentation.

Changes

  • Fix: Truncate the shared memfd before each BPF export.
  • Fix: x86 partial-register analysis for syscall numbers.
  • Check rules from all Firecracker thread categories.
  • Add the optional blk_worker category.
  • Allow system calls for block requests, drive updates, discard, signals, and io_uring.
  • Apply the filter before the worker enters its event loop.
  • Document the allowed and mandatory thread categories.

@codecov

codecov Bot commented Aug 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.40%. Comparing base (dad9795) to head (b8eee34).

Files with missing lines Patch % Lines
src/seccompiler/src/lib.rs 0.00% 2 Missing ⚠️
src/vmm/src/devices/virtio/block/virtio/worker.rs 87.50% 1 Missing ⚠️
Additional details and impacted files
@@                     Coverage Diff                     @@
##           pbertho/blk-threaded-04    #6131      +/-   ##
===========================================================
- Coverage                    82.40%   82.40%   -0.01%     
===========================================================
  Files                          278      278              
  Lines                        31965    31979      +14     
===========================================================
+ Hits                         26342    26353      +11     
- Misses                        5623     5626       +3     
Flag Coverage Δ
5.10-m5n.metal 82.56% <85.00%> (-0.01%) ⬇️
5.10-m6a.metal 81.93% <85.00%> (+<0.01%) ⬆️
5.10-m6g.metal 79.45% <85.00%> (-0.01%) ⬇️
5.10-m6i.metal 82.57% <85.00%> (-0.01%) ⬇️
5.10-m7a.metal-48xl 81.92% <85.00%> (-0.01%) ⬇️
5.10-m7g.metal 79.45% <85.00%> (-0.01%) ⬇️
5.10-m7i.metal-24xl 82.54% <85.00%> (-0.01%) ⬇️
5.10-m7i.metal-48xl 82.54% <85.00%> (-0.01%) ⬇️
5.10-m8g.metal-24xl 79.45% <85.00%> (-0.01%) ⬇️
5.10-m8g.metal-48xl 79.45% <85.00%> (+<0.01%) ⬆️
5.10-m8i.metal-48xl 82.54% <85.00%> (-0.01%) ⬇️
5.10-m8i.metal-96xl 82.54% <85.00%> (-0.01%) ⬇️
5.10-m9g.metal-48xl 79.45% <85.00%> (-0.01%) ⬇️
6.1-m5n.metal 82.59% <85.00%> (-0.01%) ⬇️
6.1-m6a.metal 81.95% <85.00%> (-0.01%) ⬇️
6.1-m6g.metal 79.45% <85.00%> (-0.01%) ⬇️
6.1-m6i.metal 82.59% <85.00%> (-0.01%) ⬇️
6.1-m7a.metal-48xl 81.94% <85.00%> (-0.01%) ⬇️
6.1-m7g.metal 79.45% <85.00%> (-0.01%) ⬇️
6.1-m7i.metal-24xl 82.60% <85.00%> (+<0.01%) ⬆️
6.1-m7i.metal-48xl 82.60% <85.00%> (+<0.01%) ⬆️
6.1-m8g.metal-24xl 79.44% <85.00%> (-0.01%) ⬇️
6.1-m8g.metal-48xl 79.45% <85.00%> (+<0.01%) ⬆️
6.1-m8i.metal-48xl 82.60% <85.00%> (-0.01%) ⬇️
6.1-m8i.metal-96xl 82.61% <85.00%> (+<0.01%) ⬆️
6.1-m9g.metal-48xl 79.45% <85.00%> (+<0.01%) ⬆️
6.18-m5n.metal 82.59% <85.00%> (-0.01%) ⬇️
6.18-m6a.metal 81.95% <85.00%> (-0.01%) ⬇️
6.18-m6g.metal 79.56% <85.00%> (-0.01%) ⬇️
6.18-m6i.metal 82.58% <85.00%> (-0.02%) ⬇️
6.18-m7a.metal-48xl 81.94% <85.00%> (-0.01%) ⬇️
6.18-m7g.metal 79.56% <85.00%> (-0.01%) ⬇️
6.18-m7i.metal-24xl 82.60% <85.00%> (-0.01%) ⬇️
6.18-m7i.metal-48xl 82.60% <85.00%> (-0.01%) ⬇️
6.18-m8g.metal-24xl 79.55% <85.00%> (-0.01%) ⬇️
6.18-m8g.metal-48xl 79.55% <85.00%> (-0.01%) ⬇️
6.18-m8i.metal-48xl 82.60% <85.00%> (-0.01%) ⬇️
6.18-m8i.metal-96xl 82.61% <85.00%> (-0.01%) ⬇️
6.18-m9g.metal-48xl 79.55% <85.00%> (-0.01%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

Comment thread resources/seccomp/aarch64-unknown-linux-musl.json
@PierreBertholom
PierreBertholom removed this pull request from stack #6135 September 9, 2026 10:07
@PierreBertholom
PierreBertholom changed the base branch from pbertho/blk-threaded-08 to pbertho/blk-threaded-04 September 9, 2026 10:07
@PierreBertholom
PierreBertholom added this pull request to stack #6198 September 9, 2026 10:08
@PierreBertholom PierreBertholom changed the title [blk-threaded - 9/12] seccomp: add block worker thread filter [blk-threaded - 3/5] seccomp: add block worker thread filter Sep 9, 2026
@PierreBertholom
PierreBertholom force-pushed the pbertho/blk-threaded-09 branch 2 times, most recently from 4000847 to 76a788d Compare September 14, 2026 20:36
Reset the shared memfd before each export so a shorter filter cannot
retain instructions from the previous filter.

Signed-off-by: Pierre Bertholom <pbertho@amazon.com>
Resolve x86 syscall numbers written through partial registers while
preserving unaffected bits during backpropagation.
Inspect seccomp rules from all thread categories.

Signed-off-by: Pierre Bertholom <pbertho@amazon.com>
Add an optional seccomp category and a syscall allowlist for block
workers.
Keep existing custom filters valid when no block worker is needed.
Apply the filter before entering the worker event loop.

Signed-off-by: Pierre Bertholom <pbertho@amazon.com>
Document the allowed and mandatory Firecracker thread categories.
Explain when custom filters need the optional block worker category.

Signed-off-by: Pierre Bertholom <pbertho@amazon.com>

@ShadowCurse ShadowCurse left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Comment on lines +164 to +165
memfd.set_len(0).map_err(CompilationError::MemfdTruncate)?;
memfd.rewind().map_err(CompilationError::MemfdRewind)?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

heh, this forced me to take another look at this memfd dance we are doing here and as it appears we can just export to the buffer directly so I opened #6234 to fix this. Does not block this PR though.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants