Skip to content

Commit 96c4929

Browse files
committed
sandlock-oci: enable port remapping so container servers can bind
Signed-off-by: Cong Wang <cwang@multikernel.io>
1 parent 25bcd6b commit 96c4929

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

crates/sandlock-oci/src/policy.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,15 @@ impl OciPolicy {
268268
builder = builder.user(ru.uid, ru.gid);
269269
}
270270

271+
// Container workloads legitimately run servers (nginx, etc.). sandlock
272+
// gates bind() by default-deny (Landlock BIND_TCP), so without this an
273+
// in-container server fails bind() with EACCES and the container exits,
274+
// which in turn hangs any readiness/verification exec that waits on it.
275+
// Enable port remapping: binds are emulated on-behalf and succeed,
276+
// using the requested port when free and a fresh host port only on
277+
// conflict, so co-located sandboxes never collide on a host port.
278+
builder = builder.port_remap(true);
279+
271280
builder.build_unchecked().map_err(Into::into)
272281
}
273282
}
@@ -718,6 +727,9 @@ mod tests {
718727
assert!(sandbox.chroot.is_some());
719728
assert!(sandbox.cwd.is_some());
720729
assert!(!sandbox.env.is_empty());
730+
// Container workloads must be able to bind ports (servers); port
731+
// remapping is enabled so bind() succeeds instead of EACCES-exiting.
732+
assert!(sandbox.port_remap, "OCI containers must allow port binding");
721733
}
722734

723735
#[test]

0 commit comments

Comments
 (0)