Skip to content

Commit 6828e14

Browse files
authored
fix(sandbox): emit warning when Landlock filesystem sandbox degrades silently (#599)
* fix(sandbox): emit warning when Landlock filesystem sandbox degrades silently BestEffort Landlock previously swallowed failures at debug level, making sandbox bypass invisible to operators at default log levels. Upgrade the degradation log to warn with an actionable message pointing to the hard_requirement setting. Add info-level startup log showing the requested ABI and path counts so operators always know what Landlock protections are active. Closes #584 * fix(sandbox): revert unintended ABI bump from V2 to V5 Signed-off-by: John Myers <johntmyers@users.noreply.github.com> --------- Signed-off-by: John Myers <johntmyers@users.noreply.github.com> Co-authored-by: John Myers <johntmyers@users.noreply.github.com>
1 parent 0e5ebb6 commit 6828e14

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

crates/openshell-sandbox/src/sandbox/linux/landlock.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use landlock::{
1010
};
1111
use miette::{IntoDiagnostic, Result};
1212
use std::path::PathBuf;
13-
use tracing::debug;
13+
use tracing::{debug, info, warn};
1414

1515
pub fn apply(policy: &SandboxPolicy, workdir: Option<&str>) -> Result<()> {
1616
let read_only = policy.filesystem.read_only.clone();
@@ -29,8 +29,16 @@ pub fn apply(policy: &SandboxPolicy, workdir: Option<&str>) -> Result<()> {
2929
return Ok(());
3030
}
3131

32+
let abi = ABI::V2;
33+
info!(
34+
abi = ?abi,
35+
compatibility = ?policy.landlock.compatibility,
36+
read_only_paths = read_only.len(),
37+
read_write_paths = read_write.len(),
38+
"Applying Landlock filesystem sandbox"
39+
);
40+
3241
let result: Result<()> = (|| {
33-
let abi = ABI::V2;
3442
let access_all = AccessFs::from_all(abi);
3543
let access_read = AccessFs::from_read(abi);
3644

@@ -71,7 +79,11 @@ pub fn apply(policy: &SandboxPolicy, workdir: Option<&str>) -> Result<()> {
7179
policy.landlock.compatibility,
7280
LandlockCompatibility::BestEffort
7381
) {
74-
debug!(error = %err, "Landlock unavailable, continuing without filesystem sandbox");
82+
warn!(
83+
error = %err,
84+
"Landlock filesystem sandbox is UNAVAILABLE — running WITHOUT filesystem restrictions. \
85+
Set landlock.compatibility to 'hard_requirement' to make this a fatal error."
86+
);
7587
return Ok(());
7688
}
7789
return Err(err);

0 commit comments

Comments
 (0)