Skip to content

Migrate Sandbox OCI owners into delegated cgroup children - #268

Merged
ZhiXiao-Lin merged 29 commits into
mainfrom
fix/sandbox-delegated-cgroup-child
Sep 9, 2026
Merged

ZhiXiao-Lin merged 29 commits into
mainfrom
fix/sandbox-delegated-cgroup-child

Conversation

@ZhiXiao-Lin

Copy link
Copy Markdown

Summary

  • Cloud Box provider conformance on pin 09e5874b failed advertised R17 profiles: rootless executor must run in a host-owned child below its empty cgroup delegation (executor in a3s-box-ci/probe, delegation in a3s-box-ci/delegated).
  • Spawn native-linux-service after migrating into a child of the delegated root, matching host-service composition.
  • Use the module-qualified --exact name for box_runtime_passes_all_advertised_profiles so the ignored test actually runs.

Test plan

  • Unit: prepares_a_child_below_the_delegated_cgroup_root
  • Box CI Linux no-KVM / Sandbox advertised profiles
  • Cloud Box provider conformance after pin bump

Closes nothing yet; required evidence for #172 / A3S-Lab/Cloud#85.

native-linux-service must start below an empty delegated root. CI harnesses
live in a sibling probe cgroup; migrate the owner child before exec so
advertised Runtime profiles can boot. Use the module-qualified R17 filter.
Advertised profiles under matched setpriv need the same owner elevation
wrapper as host-service composition, plus an A3S_HOME chown before the
harness runs.
@ZhiXiao-Lin

Copy link
Copy Markdown
Author

Follow-up: R17 now uses matched setpriv + SETPRIV_WRAPPER elevation (same as composition) after the cgroup child migration cleared the previous delegated-root error.

ZhiXiao-Lin and others added 26 commits September 9, 2026 08:54
Effective-root R17 launchers created 0700 parents as UID 0; after bootstrap
drop, native-linux-service could not inspect them. Assign the parent to the
real UID and keep the launcher as a direct exec so control FDs stay valid.
After device-policy drop the endpoint is owned by the sandbox ruid; euid-0
harnesses must wait on that durable owner identity instead of geteuid.
native-linux-service publishes the socket as the real UID; keep effective root
only through spawn, then match SO_PEERCRED without matched-cred elevate wrappers.
Keep saved UID/GID 0 across setresuid so conformance cleanup can remove
prepare-time state trees after SO_PEERCRED-matched SDK calls finish.
The helper is only for R17 cleanup inside a3s-box-runtime; do not re-export it.
Lifecycle locks and Runtime state created as effective root must stay writable
after the controller matches SO_PEERCRED; keep restore helper test-only.
create_dir_all left the shared sockets directory root:0700, so the real-UID
controller could not remove per-execution runtime socket trees on retire.
Device-policy owners drop to ruid before create; UID maps probed with geteuid 0
were rootful and rejected as not mapping container 0 to the durable host ID.
R17 records the certified a3s-oci path but execs a3s-box-sandbox-oci-launcher;
treat matching digests as the same owner executable for retire/inspect.
R17 runs many cases in one process; peer-auth drop must not permanently remove
CAP_SYS_ADMIN needed for later overlayfs prepares.
Peer-auth drops remove CAP_SYS_ADMIN; unmount merged before deleting box dirs
or retire leaves Device or resource busy on R17 long-running services.
Only seteuid/setegid(0) when getresuid retained saved root from the peer-auth
drop, then reclaim A3S_HOME to the current effective owner so Runtime state
checks pass without breaking ordinary unit tests.

Co-authored-by: Cursor <[email protected]>
Control sockets under /tmp/a3s-box-sockets were left root:0600 after bind, so
post-drop readiness heartbeats could not connect. Also restore effective root
before boot-failure overlay cleanup and retain the underlying boot error.

Co-authored-by: Cursor <[email protected]>
Permanent controller euid drops stripped CAP_NET_ADMIN and broke R17
networking relays plus overlay umount. Keep effective root for mounts and
TCP endpoints; seteuid to the real owner only around SO_PEERCRED connect.

Co-authored-by: Cursor <[email protected]>
Keep the controller at effective root for mounts and networking, but assign
each boxes/<id> tree to the real UID so native-linux-service can scan rootfs
device nodes after its device-policy drop.

Co-authored-by: Cursor <[email protected]>
Clear the euid/ruid mismatch before exec and keep PR_SET_KEEPCAPS across
temporary peer-auth seteuid so R17 can load bundled libkrun without
stripping CAP_SYS_ADMIN.

Co-authored-by: Cursor <[email protected]>
Recovery inspect compared endpoint ownership to geteuid(); with the
controller kept at euid 0 the dropped owner socket failed the contract.

Co-authored-by: Cursor <[email protected]>
Whole-tree chown walked into R17 read-only bind attachments and failed with
EROFS; hand off rootfs (plus the box dir inode) and skip EROFS paths.

Co-authored-by: Cursor <[email protected]>
Restore full boxes/<id> chown so merged/root is traversable after device-policy
drop, but do not recurse into sandbox/attachments (R17 EROFS bind mounts).

Co-authored-by: Cursor <[email protected]>
Skip detached open_tree after device-policy drop so R17 mounts can bind
sources owned by the durable mapped identity.

Co-authored-by: Cursor <[email protected]>
RO bind remounts after device-policy drop use mount_setattr instead of
MS_REMOUNT so the R17 security profile can apply readonly attributes.

Co-authored-by: Cursor <[email protected]>
Previous commit only refreshed the lock metadata while CI still packaged 1e0eba9a.

Co-authored-by: Cursor <[email protected]>
Keep Sandbox R17 fixes and pin OCI Runtime to 402949c2 (merged open_tree /
mount_setattr rootless path) while absorbing mainline KVM qualification and
owner-loss reconcile work.

Co-authored-by: Cursor <[email protected]>
@ZhiXiao-Lin
ZhiXiao-Lin merged commit 8b2804c into main Sep 9, 2026
14 checks passed
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.

1 participant