Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
acdad47
CWCOW: Persist environment variable
MahatiC May 7, 2026
d83b752
CWCOW: Enforce MappedDirectory inside gcs-sidecar
MahatiC May 7, 2026
7fa1b7b
Use Windows path in environment variable tests
takuro-sato Jun 1, 2026
6dc7c8f
CWCOW: marshal sidecar exec rewrite via pointer
takuro-sato Jun 1, 2026
8a9015b
CWCOW: strict-decode ProcessParameters in sidecar executeProcess
takuro-sato Jun 2, 2026
e768db5
Add test for executeProcess env var filtering
takuro-sato Jun 23, 2026
5c658a5
Define UnmarshalJSONWithHresultStrict
takuro-sato Jun 24, 2026
b69031d
Revert "Define UnmarshalJSONWithHresultStrict"
takuro-sato Jun 24, 2026
d4923f5
Revert "CWCOW: strict-decode ProcessParameters in sidecar executeProc…
takuro-sato Jun 24, 2026
5bf3657
Remove duplicated test
takuro-sato Jun 25, 2026
ec3f8ba
Fix a bug where host can prevent security context dir from being put
takuro-sato Jun 25, 2026
61f0114
Add comments per discussion
takuro-sato Jun 25, 2026
b43f381
Add comments for create container enforcer per discussion
takuro-sato Jun 25, 2026
3db501f
Add a TODO comment for allow_registry_changes_dropping
takuro-sato Jun 25, 2026
7151b1c
Enforce ContainerPath and ReadOnly for mapped_directory policy
takuro-sato Jun 26, 2026
50f3410
Rewrite tests with existing pattern
takuro-sato Jun 26, 2026
3fde0e5
Update comments
takuro-sato Jun 29, 2026
bbe0c64
Enforce container's init exec using the result of create_container po…
takuro-sato Jun 29, 2026
5930305
Remove an unnecessary TODO
takuro-sato Jun 29, 2026
8da75d3
Remove the support of HostedSystem
takuro-sato Jun 29, 2026
9c42c06
Fix printing Container
takuro-sato Jun 29, 2026
96a404f
Add log for container object as indented json
takuro-sato Jun 29, 2026
dfd925f
Revert "Add log for container object as indented json"
takuro-sato Jun 29, 2026
ea2e45a
Add comment on startContainer
takuro-sato Jun 30, 2026
aa8fe54
Temporary comments
takuro-sato Jun 30, 2026
243936b
Add mounts enforcement point
takuro-sato Jul 2, 2026
9a9e198
Apply result of allowStdio policy
takuro-sato Jul 2, 2026
020d29a
Make registry_changes order-robust with dropping
takuro-sato Jul 3, 2026
6c0454c
Add allow_registry_changes_dropping swtich
takuro-sato Jul 3, 2026
67a1a6c
Add registry_changes.add_values support to the Windows policy producer
takuro-sato Jul 3, 2026
c5eb50e
Add allow_registry_changes_dropping swtich
takuro-sato Jul 7, 2026
543d7db
Add unmount_cim policy
takuro-sato Jul 7, 2026
57e4ed2
Cross-check the forwarded Container.Storage against values provided i…
takuro-sato Jul 7, 2026
72d6a3f
Deny unsupported fields in HostedSystem
takuro-sato Jul 7, 2026
f4cddc1
Reject MappedVirtualDisk and HvSocket in modifySettings; document net…
takuro-sato Jul 7, 2026
12c77ba
Add comment to explain the example request of createContainer
takuro-sato Jul 7, 2026
15b8c29
Deny unhandled request types in modifySettings switches
takuro-sato Jul 7, 2026
f9547ff
Enable log earlier for now
takuro-sato Jul 8, 2026
c24a641
Temporary comment
takuro-sato Jul 8, 2026
4fc5d27
Enforce ContainerRootPath format in CWCOWCombinedLayers
takuro-sato Jul 9, 2026
7c8ee5e
Revert accidental change of allowUnsupportedForDebug
takuro-sato Jul 9, 2026
ffd54b0
gcs-sidecar: validate container ID format in createContainer
takuro-sato Jul 9, 2026
4f1ce18
Update comment for HvSocket in modifySettings
takuro-sato Jul 9, 2026
917ff3c
Revert temporary early logs
takuro-sato Jul 9, 2026
d6d65b7
gcs-sidecar: deny combined-layers unmount while container root is in use
takuro-sato Jul 15, 2026
b58d0a4
gcs-sidecar: enforce deleteContainerState (deny running / still-mount…
takuro-sato Jul 15, 2026
e4c4e89
Merge remote-tracking branch 'upstream/main' into cwcow-policy-changes
takuro-sato Jul 15, 2026
09645b9
Note why Windows create-time mounts keep no state
takuro-sato Jul 16, 2026
8c8e2a5
gcs-sidecar: fail closed on forwarded mount/unmount failure
takuro-sato Jul 17, 2026
a012abc
Reject duplicate CWCOWCombinedLayers Add
takuro-sato Jul 17, 2026
6ea1608
Roll back policy state on block-CIM unmount failure
takuro-sato Jul 17, 2026
25c489d
Improve mount_cims errors
takuro-sato Jul 22, 2026
ae95830
Allow GuestOs to be set in createContainer
takuro-sato Jul 22, 2026
9790045
Forward MappedVirtualDisk Remove so container scratch can be detached
takuro-sato Jul 22, 2026
498c4b3
Fix comment on reconcileHostedSystemMounts
takuro-sato Aug 4, 2026
cc3bb87
Merge branch 'main' into cwcow-policy-changes
takuro-sato Aug 4, 2026
d97d6cf
Convert k (type WindowsRegistryKey) to registryKeyInternal instead of…
takuro-sato Aug 5, 2026
1090eb8
Check it's confidential before writing security context dir
takuro-sato Aug 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions internal/gcs-sidecar/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ type Bridge struct {
pendingMu sync.Mutex
pending map[sequenceID]chan *prot.ContainerExecuteProcessResponse

// monitoredMu guards monitoredIDs.
monitoredMu sync.Mutex
// monitoredIDs holds request IDs of forwarded combined-layers /
// mapped-directory mount/unmount operations whose inbox GCS response must be
// watched. The sidecar forwards those operations rather than performing them,
// so it cannot revert the policy state it staged; if the inbox reports a
// failure the UVM is failed closed (see monitorInboxResponse and
// Host.setUVMInconsistent).
monitoredIDs map[sequenceID]struct{}

hostState *Host
// List of handlers for handling different rpc message requests.
rpcHandlerList map[prot.RPCProc]HandlerFunc
Expand Down Expand Up @@ -81,6 +91,7 @@ func NewBridge(shimConn io.ReadWriteCloser, inboxGCSConn io.ReadWriteCloser, ini
hostState := NewHost(initialEnforcer, logWriter)
return &Bridge{
pending: make(map[sequenceID]chan *prot.ContainerExecuteProcessResponse),
monitoredIDs: make(map[sequenceID]struct{}),
rpcHandlerList: make(map[prot.RPCProc]HandlerFunc),
hostState: hostState,
shimConn: shimConn,
Expand Down Expand Up @@ -220,6 +231,36 @@ func (b *Bridge) forwardRequestToGcs(req *request) {
b.sendToGCSCh <- *req
}

// monitorInboxResponse records that the inbox GCS response for the given
// request ID must be watched. It is used for forwarded combined-layers and
// mapped-directory mount/unmount operations, whose real work happens in the
// inbox GCS: because the sidecar cannot revert the policy state it staged for
// them, a failure response fails the UVM closed instead (see the receive loop
// and Host.setUVMInconsistent).
func (b *Bridge) monitorInboxResponse(id sequenceID) {
b.monitoredMu.Lock()
b.monitoredIDs[id] = struct{}{}
b.monitoredMu.Unlock()
}

// responseFailure returns a non-nil error if the inbox GCS response message
// reports the operation failed (non-zero HResult). A response that cannot be
// parsed is treated as success (nil) so a malformed message does not by itself
// fail the UVM closed.
func responseFailure(message []byte) error {
var base prot.ResponseBase
if err := json.Unmarshal(message, &base); err != nil {
return nil
}
if base.Result != 0 {
if base.ErrorMessage != "" {
return errors.New(base.ErrorMessage)
}
return fmt.Errorf("inbox GCS returned HResult 0x%x", uint32(base.Result))
}
return nil
}

func getContextAndSpan(baseSpanCtx prot.Otelspancontext) (context.Context, trace.Span) {
var ctx context.Context
var span trace.Span
Expand Down Expand Up @@ -447,6 +488,43 @@ func (b *Bridge) ListenAndServeShimRequests() error {
b.pendingMu.Unlock()
}

// If this is a container-exit notification, mark the container
// terminated so a later combined-layers unmount isn't blocked as
// in-use.
const MsgNotifyContainer prot.MsgType = prot.MsgTypeNotify | prot.ComputeSystem | prot.NotifyContainer

if header.Type == MsgNotifyContainer {
var ntf prot.ContainerNotification
ntf.ResultInfo.Value = &json.RawMessage{}
if uerr := json.Unmarshal(message, &ntf); uerr != nil {
log.G(ctx).WithError(uerr).Error("failed to unmarshal container notification")
} else if c, cerr := b.hostState.GetCreatedContainer(ctx, ntf.ContainerID); cerr == nil {
// A not-found error just means the notification is for
// something we don't track (the UVM itself, or a container
// already deleted).
c.terminated.Store(true)
}
}

// If this response correlates to a forwarded mount/unmount
// operation we are monitoring (combined-layers or mapped
// directory) and it reports a failure, the sidecar's policy state
// may now be out of sync with what is actually mounted. Since we
// forwarded rather than performed the operation, we cannot safely
// revert; fail the UVM closed instead so no further container or
// mount operations proceed on possibly-desynced state.
b.monitoredMu.Lock()
_, monitored := b.monitoredIDs[header.ID]
if monitored {
delete(b.monitoredIDs, header.ID)
}
b.monitoredMu.Unlock()
if monitored {
if respErr := responseFailure(message); respErr != nil {
b.hostState.setUVMInconsistent(fmt.Errorf("forwarded mount/unmount operation (request %d) failed in inbox GCS: %w", header.ID, respErr))
}
}

// Forward to shim
resp := bridgeResponse{
ctx: context.Background(),
Expand Down
Loading