Skip to content

Commit a1890d8

Browse files
committed
hcsv2/uvm: Restrict SCSI mount options in confidential mode
In C-LCOW, we do not want to host to be able to arbitrarily control mount options. Currently there are two possible ways mount options might be specified by the host: 1. For read-only mounts (image layers), option "ro" is specified (see addLCOWLayer). 2. If the OCI spec passed by containerd contains physical/virtual disk mounts, it might contain mount options, and hcsshim would pass this through to GCS (see allocateLinuxResources). We can allow 1 (and in fact, require it to be consistent with the readOnly field in the request), and today C-LCOW does not support external disk mounts, and so we can reject any other mount options passed via route 2. Signed-off-by: Tingmao Wang <[email protected]>
1 parent 89076fc commit a1890d8

File tree

1 file changed

+18
-0
lines changed
  • internal/guest/runtime/hcsv2

1 file changed

+18
-0
lines changed

internal/guest/runtime/hcsv2/uvm.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,24 @@ func (h *Host) modifyMappedVirtualDisk(
12251225
mountCtx, cancel := context.WithTimeout(ctx, time.Second*5)
12261226
defer cancel()
12271227
if mvd.MountPath != "" {
1228+
if h.HasSecurityPolicy() {
1229+
// The only option we allow if there is policy enforcement is
1230+
// "ro", and it must match the readonly field in the request.
1231+
mountOptionHasRo := false
1232+
for _, opt := range mvd.Options {
1233+
if opt == "ro" {
1234+
mountOptionHasRo = true
1235+
continue
1236+
}
1237+
return errors.Errorf("mounting scsi device controller %d lun %d onto %s: mount option %q denied by policy", mvd.Controller, mvd.Lun, mvd.MountPath, opt)
1238+
}
1239+
if mvd.ReadOnly != mountOptionHasRo {
1240+
return errors.Errorf(
1241+
"mounting scsi device controller %d lun %d onto %s with mount option %q failed due to mount option mismatch: mvd.ReadOnly=%t but mountOptionHasRo=%t",
1242+
mvd.Controller, mvd.Lun, mvd.MountPath, strings.Join(mvd.Options, ","), mvd.ReadOnly, mountOptionHasRo,
1243+
)
1244+
}
1245+
}
12281246
if mvd.ReadOnly {
12291247
var deviceHash string
12301248
if verityInfo != nil {

0 commit comments

Comments
 (0)