Commit e024175
committed
Merged PR 12878779: Enhance uvm_state::hostMounts to track in-use mounts, and prevent unmounting or deleting in-use things
[cherry-picked from d0334883cd43eecbb401a6ded3e0317179a3e54b]
This set of changes adds some checks (when running with a confidential policy)
to prevent the host from trying to clean up mounts, overlays, or the container
states dir when the container is running (or when the overlay has not been
unmounted yet). This is through enhancing the existing `hostMounts` utility, as
well as adding a `terminated` flag to the Container struct.
The correct order of operations should always be:
- mount read-only layers and scratch (in any order, and individual containers
(not the sandbox) might not have their own scratch) - mount the overlay - start
the container - container terminates - unmount overlay - unmount read-only
layers and scratch
The starting up order is implied, and we now explicitly deny e.g. unmounting
layer/scratch before unmounting overlay, or unmounting the overlay while
container has not terminated.
We also deny deleteContainerState requests when the container is running or when
the overlay is mounted. Doing so when a container is running can result in
unexpectedly deleting its files, which breaks it in unpredictable ways and is
bad.
Signed-off-by: Tingmao Wang <tingmaowang@microsoft.com>1 parent d2a5931 commit e024175
File tree
6 files changed
+737
-98
lines changed- internal/guest
- bridge
- runtime/hcsv2
6 files changed
+737
-98
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
467 | 467 | | |
468 | 468 | | |
469 | 469 | | |
470 | | - | |
| 470 | + | |
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | 474 | | |
481 | 475 | | |
482 | 476 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
76 | 79 | | |
77 | 80 | | |
78 | 81 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
| 102 | + | |
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
| |||
0 commit comments