diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-05-06 01:03:25 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-05-06 01:03:25 +0000 |
commit | 568ef4b075849f04e329e964918dbbcaeb675602 (patch) | |
tree | 299f8cb983c4fc23824dc01239dd5df4a69c63f0 /pkg | |
parent | 2c48356c29a453e4dd0c6412f1d55115b1ee7742 (diff) | |
parent | 8416da33d25bf28cfcfdcbe658f696d6883eebcd (diff) |
Merge release-20200422.0-33-g8416da3 (automated)
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/sentry/pgalloc/pgalloc.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pkg/sentry/pgalloc/pgalloc.go b/pkg/sentry/pgalloc/pgalloc.go index 577e9306a..2b11ea4ae 100644 --- a/pkg/sentry/pgalloc/pgalloc.go +++ b/pkg/sentry/pgalloc/pgalloc.go @@ -180,6 +180,11 @@ type MemoryFileOpts struct { // notifications to determine when eviction is necessary. This option has // no effect unless DelayedEviction is DelayedEvictionEnabled. UseHostMemcgPressure bool + + // If ManualZeroing is true, MemoryFile must not assume that new pages + // obtained from the host are zero-filled, such that MemoryFile must manually + // zero newly-allocated pages. + ManualZeroing bool } // DelayedEvictionType is the type of MemoryFileOpts.DelayedEviction. @@ -432,6 +437,15 @@ func (f *MemoryFile) Allocate(length uint64, kind usage.MemoryKind) (platform.Fi // Mark selected pages as in use. fr := platform.FileRange{start, end} + if f.opts.ManualZeroing { + if err := f.forEachMappingSlice(fr, func(bs []byte) { + for i := range bs { + bs[i] = 0 + } + }); err != nil { + return platform.FileRange{}, err + } + } if !f.usage.Add(fr, usageInfo{ kind: kind, refs: 1, |