Skip to content

fix: Landlock probe environment and autofallback to BW#252

Draft
abhisek wants to merge 1 commit into
mainfrom
fix/linux-sandbox-driver-probe-landlock-access
Draft

fix: Landlock probe environment and autofallback to BW#252
abhisek wants to merge 1 commit into
mainfrom
fix/linux-sandbox-driver-probe-landlock-access

Conversation

@abhisek

@abhisek abhisek commented May 11, 2026

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings May 11, 2026 15:59
@safedep

safedep Bot commented May 11, 2026

Copy link
Copy Markdown

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

No dependency changes detected. Nothing to scan.

View complete scan results →

This report is generated by SafeDep Github App

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 8.77193% with 52 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.05%. Comparing base (00fd6d2) to head (81c161d).

Files with missing lines Patch % Lines
sandbox/platform/landlock_probe_linux.go 0.00% 32 Missing ⚠️
cmd/landlock/landlock_probe_linux.go 0.00% 11 Missing ⚠️
sandbox/platform/platform_linux.go 50.00% 3 Missing and 2 partials ⚠️
main.go 0.00% 2 Missing ⚠️
sandbox/platform/landlock_linux.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #252      +/-   ##
==========================================
- Coverage   46.18%   46.05%   -0.13%     
==========================================
  Files         112      114       +2     
  Lines        8103     8155      +52     
==========================================
+ Hits         3742     3756      +14     
- Misses       4040     4076      +36     
- Partials      321      323       +2     

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI 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.

Pull request overview

This PR improves Linux sandbox driver selection by adding an environment probe for Landlock’s “no-NNP seccomp shim” requirements and automatically falling back to Bubblewrap when that probe fails, plus adds unit tests and documentation updates to reflect the new behavior.

Changes:

  • Add a self-reexec Landlock shim probe used during Landlock sandbox initialization to validate required user-namespace + seccomp-notify behavior.
  • Refactor Linux sandbox selection to use injectable factories (enabling deterministic tests) and add coverage for fallback/forced-driver behavior.
  • Document the updated Landlock requirements and fallback conditions; wire a hidden __landlock_probe command into the CLI.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sandbox/platform/platform_linux.go Adds factory indirection and safer Landlock logging in driver selection + fallback logic.
sandbox/platform/platform_linux_test.go New tests validating default fallback, default Landlock selection, and forced-driver behavior.
sandbox/platform/landlock_probe_linux.go Implements the Landlock shim probe (self-reexec + seccomp install) and probe entrypoint.
sandbox/platform/landlock_linux.go Calls the probe as part of Landlock sandbox construction to gate driver availability.
main.go Registers the hidden __landlock_probe command in the root CLI.
cmd/landlock/landlock_probe_linux.go Adds the hidden Cobra command that runs the platform probe on Linux.
cmd/landlock/landlock_probe_other.go Returns nil for the probe command on non-Linux platforms.
docs/sandbox.md Updates Linux Landlock requirements and fallback explanation to include the shim probe.
docs/sandbox-landlock.md Updates Landlock limitations to note probing and fallback behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 35 to +45
// newLandlockSandbox creates a new Landlock sandbox instance after verifying
// that both Landlock and seccomp user notification are available on the system.
// that Landlock and the no-NNP seccomp shim path are available on the system.
func newLandlockSandbox() (sandbox.Sandbox, error) {
abi, err := landlockDetectABI()
if err != nil {
return nil, fmt.Errorf("landlock not available: %w", err)
}

if err := landlockShimProbe(); err != nil {
return nil, fmt.Errorf("landlock shim not available: %w", err)
}
Comment thread main.go
Comment on lines 144 to +148
cmd.AddCommand(subcmd)
}
if subcmd := landlockCmd.NewLandlockProbeCommand(); subcmd != nil {
cmd.AddCommand(subcmd)
}
Comment on lines +17 to +18
PersistentPreRun: func(cmd *cobra.Command, args []string) {
},
@abhisek abhisek marked this pull request as draft May 25, 2026 16:55
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