Commit c6972af
* fix(guest): give TTY containers a per-container cgroup (#11 follow-up)
The PTY path (CRI tty:true workloads) never created a ContainerCgroup, so tty
containers escaped ALL resource limits — cpu.max, pids.max, memory.* were
unenforced even though the pod requested them. (The seccomp/caps/no_new_privs
gap was closed separately.)
Create the per-container cgroup from the same A3S_SEC_* limit vars the exec
path consumes (memory.max/low/swap, cpu.max/weight, pids.max) in the parent
before the fork, and have the child join it (write its PID to cgroup.procs)
FIRST — before chroot makes /sys/fs/cgroup unreachable — with the same
async-signal-safe open+getpid+itoa+write used by the exec path. The handle
lives for the connection so the cgroup dir is reclaimed once the child exits.
Completes #11: tty containers now get the same cgroup + security confinement as
the exec path.
* fix(guest): apply MaskedPaths/ReadonlyPaths/readonly-rootfs on the PTY path (#11)
The PTY path also skipped the container rootfs path-restrictions the exec path
applies — a tty container's securityContext MaskedPaths (e.g. /proc/kcore),
ReadonlyPaths and readOnlyRootFilesystem went unenforced. Apply them in the PTY
parent before the fork (the child shares the mount namespace and chroots in),
reusing the exec path's critest-validated apply_container_path_restrictions /
remount_rootfs_readonly (now pub(crate)) so the behavior is identical. Best-
effort, matching exec: a masked path that doesn't exist is skipped.
Together with the cgroup commit this closes the remaining #11 surface: tty
containers now get the same security confinement, cgroup limits, and rootfs
path restrictions as the exec path. (parse/apply reuse the exec functions, so
they inherit the exec path's conformance coverage; a CRI-tty-with-rootfs harness
to measure masking directly is a follow-up — exec -t carries no rootfs.)
* fix(guest): set up /proc + /dev on the PTY rootfs path too (#11)
The PTY path with a rootfs (a CRI tty container main carries the container
rootfs) never mounted the container pseudo-filesystems (/proc, /sys) or the
standard /dev nodes — only the exec path did, per spawn. A tty container was
therefore missing /proc and /dev entirely (many workloads read /proc/self/* or
/dev/urandom and won't start), AND the masked-paths added in the previous commit
were no-ops because /proc wasn't mounted to mask under.
Mirror the exec path's full rootfs setup in the PTY parent before the fork
(ensure_container_pseudo_filesystems + ensure_container_dev_nodes, now
pub(crate)), in the exec path's order: pseudo-fs -> dev -> masked/readonly ->
readonly-rootfs. All reuse the exec path's critest-validated functions, so the
behavior is identical; idempotent and best-effort.
With this the PTY path performs the SAME container setup as the exec path —
closing the functionality gap and making the masked-path restrictions effective.
---------
Co-authored-by: Roy Lin <roylin@a3s.box>
1 parent 9887858 commit c6972af
2 files changed
Lines changed: 102 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1518 | 1518 | | |
1519 | 1519 | | |
1520 | 1520 | | |
1521 | | - | |
| 1521 | + | |
1522 | 1522 | | |
1523 | 1523 | | |
1524 | 1524 | | |
| |||
1559 | 1559 | | |
1560 | 1560 | | |
1561 | 1561 | | |
1562 | | - | |
| 1562 | + | |
1563 | 1563 | | |
1564 | 1564 | | |
1565 | 1565 | | |
| |||
1635 | 1635 | | |
1636 | 1636 | | |
1637 | 1637 | | |
1638 | | - | |
| 1638 | + | |
1639 | 1639 | | |
1640 | 1640 | | |
1641 | 1641 | | |
| |||
1654 | 1654 | | |
1655 | 1655 | | |
1656 | 1656 | | |
1657 | | - | |
| 1657 | + | |
1658 | 1658 | | |
1659 | 1659 | | |
1660 | 1660 | | |
| |||
1790 | 1790 | | |
1791 | 1791 | | |
1792 | 1792 | | |
1793 | | - | |
| 1793 | + | |
1794 | 1794 | | |
1795 | 1795 | | |
1796 | 1796 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
236 | 302 | | |
237 | 303 | | |
238 | 304 | | |
| |||
247 | 313 | | |
248 | 314 | | |
249 | 315 | | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
250 | 347 | | |
251 | 348 | | |
252 | 349 | | |
| |||
0 commit comments