diff --git a/pkg/sentry/platform/kvm/machine_amd64.go b/pkg/sentry/platform/kvm/machine_amd64.go index 3054f450a..5e8e3b511 100644 --- a/pkg/sentry/platform/kvm/machine_amd64.go +++ b/pkg/sentry/platform/kvm/machine_amd64.go @@ -445,7 +445,7 @@ func (c *vCPU) SwitchToUser(switchOpts ring0.SwitchOpts, info *linux.SignalInfo) func (m *machine) mapUpperHalf(pageTable *pagetables.PageTables) { // Map all the executable regions so that all the entry functions // are mapped in the upper half. - applyVirtualRegions(func(vr virtualRegion) { + if err := applyVirtualRegions(func(vr virtualRegion) { if excludeVirtualRegion(vr) || vr.filename == "[vsyscall]" { return } @@ -462,7 +462,9 @@ func (m *machine) mapUpperHalf(pageTable *pagetables.PageTables) { pagetables.MapOpts{AccessType: hostarch.Execute, Global: true}, physical) } - }) + }); err != nil { + panic(fmt.Sprintf("error parsing /proc/self/maps: %v", err)) + } for start, end := range m.kernel.EntryRegions() { regionLen := end - start physical, length, ok := translateToPhysical(start) diff --git a/pkg/sentry/platform/kvm/machine_arm64.go b/pkg/sentry/platform/kvm/machine_arm64.go index cbdc42e84..54a414abb 100644 --- a/pkg/sentry/platform/kvm/machine_arm64.go +++ b/pkg/sentry/platform/kvm/machine_arm64.go @@ -18,6 +18,7 @@ package kvm import ( + "fmt" "runtime" "golang.org/x/sys/unix" @@ -65,7 +66,7 @@ func (m *machine) mapUpperHalf(pageTable *pagetables.PageTables) { // physical regions form them. func archPhysicalRegions(physicalRegions []physicalRegion) []physicalRegion { rdRegions := []virtualRegion{} - applyVirtualRegions(func(vr virtualRegion) { + if err := applyVirtualRegions(func(vr virtualRegion) { if excludeVirtualRegion(vr) { return // skip region. } @@ -74,7 +75,9 @@ func archPhysicalRegions(physicalRegions []physicalRegion) []physicalRegion { if !vr.accessType.Write && vr.accessType.Read { rdRegions = append(rdRegions, vr) } - }) + }); err != nil { + panic(fmt.Sprintf("error parsing /proc/self/maps: %v", err)) + } // Add an unreachable region. rdRegions = append(rdRegions, virtualRegion{ diff --git a/pkg/sentry/platform/kvm/physical_map.go b/pkg/sentry/platform/kvm/physical_map.go index d1a4147bc..f68414177 100644 --- a/pkg/sentry/platform/kvm/physical_map.go +++ b/pkg/sentry/platform/kvm/physical_map.go @@ -60,13 +60,15 @@ func fillAddressSpace() (excludedRegions []region) { pSize -= reservedMemory // Add specifically excluded regions; see excludeVirtualRegion. - applyVirtualRegions(func(vr virtualRegion) { + if err := applyVirtualRegions(func(vr virtualRegion) { if excludeVirtualRegion(vr) { excludedRegions = append(excludedRegions, vr.region) vSize -= vr.length log.Infof("excluded: virtual [%x,%x)", vr.virtual, vr.virtual+vr.length) } - }) + }); err != nil { + panic(fmt.Sprintf("error parsing /proc/self/maps: %v", err)) + } // Do we need any more work? if vSize < pSize {