Skip to content

Commit c938236

Browse files
committed
Attach EFI VHD in read-only mode by default
EFI VHDs should always be attached as read-only by default to block UVMs from writing to it and corrupting its contents. Signed-off-by: Amit Barve <ambarve@microsoft.com>
1 parent 8fb5561 commit c938236

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

internal/oci/uvm.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ func handleWCOWSecurityPolicy(ctx context.Context, a map[string]string, wopts *u
245245
wopts.SecurityPolicyEnforcer = ParseAnnotationsString(a, annotations.WCOWSecurityPolicyEnforcer, wopts.SecurityPolicyEnforcer)
246246
wopts.DisableSecureBoot = ParseAnnotationsBool(ctx, a, annotations.WCOWDisableSecureBoot, false)
247247
wopts.GuestStateFilePath = ParseAnnotationsString(a, annotations.WCOWGuestStateFile, uvm.GetDefaultConfidentialVMGSPath())
248+
wopts.WritableEFI = ParseAnnotationsBool(ctx, a, annotations.WCOWWritableEFI, false)
248249
if ParseAnnotationsBool(ctx, a, annotations.WCOWNoSecurityHardware, false) {
249250
wopts.NoSecurityHardware = true
250251
wopts.IsolationType = "VirtualizationBasedSecurity"

internal/uvm/create_wcow.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type ConfidentialWCOWOptions struct {
4242
IsolationType string
4343
DisableSecureBoot bool
4444
FirmwareParameters string
45+
WritableEFI bool
4546
}
4647

4748
// OptionsWCOW are the set of options passed to CreateWCOW() to create a utility vm.
@@ -402,8 +403,9 @@ func prepareSecurityConfigDoc(ctx context.Context, uvm *UtilityVM, opts *Options
402403
Type_: "VirtualDisk",
403404
}
404405
doc.VirtualMachine.Devices.Scsi[guestrequest.ScsiControllerGuids[0]].Attachments["1"] = hcsschema.Attachment{
405-
Path: opts.BootFiles.BlockCIMFiles.EFIVHDPath,
406-
Type_: "VirtualDisk",
406+
Path: opts.BootFiles.BlockCIMFiles.EFIVHDPath,
407+
Type_: "VirtualDisk",
408+
ReadOnly: !opts.WritableEFI,
407409
}
408410
doc.VirtualMachine.Devices.Scsi[guestrequest.ScsiControllerGuids[0]].Attachments["2"] = hcsschema.Attachment{
409411
Path: opts.BootFiles.BlockCIMFiles.BootCIMVHDPath,

pkg/annotations/annotations.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ const (
205205
// Allows disabling secure boot for testing and debugging scenarios, secure boot doesn't apply to confidential LCOW so
206206
// this is a WCOW only config
207207
WCOWDisableSecureBoot = "io.microsoft.virtualmachine.wcow.no_secure_boot"
208+
209+
// Attaches the EFI/boot VHD in the writable mode (instead of the default read-only mode). This is usually required
210+
// when debugging boot to capture bootstat traces.
211+
WCOWWritableEFI = "io.microsoft.virtualmachine.wcow.writable_efi"
208212
)
209213

210214
// WCOW host process container annotations.

0 commit comments

Comments
 (0)