fix(sandbox): skip non-existent paths instead of abandoning Landlock ruleset#669
Open
latenighthackathon wants to merge 1 commit intoNVIDIA:mainfrom
Open
Conversation
…ruleset When a single path in the filesystem policy did not exist, PathFd::new() failed and the error propagated via ? to abandon the entire Landlock ruleset. Under the default best_effort compatibility mode, this silently disabled all filesystem restrictions for the sandbox. Replace the ? operator with per-path match statements that warn and skip individual non-existent paths while continuing to build the ruleset from remaining valid paths. This preserves filesystem isolation even when optional paths like /app are missing from the container image. Closes NVIDIA#664 Signed-off-by: latenighthackathon <latenighthackathon@users.noreply.github.com>
Contributor
Author
|
I have read the DCO document and I hereby sign the DCO. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a single path in the filesystem policy did not exist (e.g.,
/appin container images without that directory),PathFd::new()failed and the?operator propagated the error to abandon the entire Landlock ruleset. Under the defaultbest_effortcompatibility mode, this silently disabled all filesystem restrictions for the sandbox.This is a critical security degradation: one missing optional path causes the entire filesystem sandbox to be dropped, leaving the container with zero filesystem isolation.
Fix
Replace the
?operator onPathFd::new()with per-pathmatchstatements that:The existing error handling for ruleset creation and
restrict_self()is unchanged. OnlyPathFd::new()failures are handled per-path.Test plan
/app): warning logged, remaining paths still enforcedbest_effortdegradation behavior unchangedhard_requirementmode with missing path: still returns error (unchanged)cargo testpassesCloses #664
I have read the DCO document and I hereby sign the DCO.