diff options
Diffstat (limited to 'pkg/sentry')
74 files changed, 387 insertions, 290 deletions
diff --git a/pkg/sentry/arch/arch_aarch64_state_autogen.go b/pkg/sentry/arch/arch_aarch64_state_autogen.go index 3e0685928..9c6dfdf2e 100755 --- a/pkg/sentry/arch/arch_aarch64_state_autogen.go +++ b/pkg/sentry/arch/arch_aarch64_state_autogen.go @@ -4,4 +4,3 @@ // +build arm64 package arch - diff --git a/pkg/sentry/arch/arch_arm64_state_autogen.go b/pkg/sentry/arch/arch_arm64_state_autogen.go index 4d56ebcca..49f2e3d67 100755 --- a/pkg/sentry/arch/arch_arm64_state_autogen.go +++ b/pkg/sentry/arch/arch_arm64_state_autogen.go @@ -3,4 +3,3 @@ // +build arm64 package arch - diff --git a/pkg/sentry/arch/arch_x86.go b/pkg/sentry/arch/arch_x86.go index a18093155..3db8bd34b 100644 --- a/pkg/sentry/arch/arch_x86.go +++ b/pkg/sentry/arch/arch_x86.go @@ -114,6 +114,10 @@ func newX86FPStateSlice() []byte { size, align := cpuid.HostFeatureSet().ExtendedStateSize() capacity := size // Always use at least 4096 bytes. + // + // For the KVM platform, this state is a fixed 4096 bytes, so make sure + // that the underlying array is at _least_ that size otherwise we will + // corrupt random memory. This is not a pleasant thing to debug. if capacity < 4096 { capacity = 4096 } diff --git a/pkg/sentry/arch/signal_amd64.go b/pkg/sentry/arch/signal_amd64.go index 81b92bb43..6fb756f0e 100644 --- a/pkg/sentry/arch/signal_amd64.go +++ b/pkg/sentry/arch/signal_amd64.go @@ -55,7 +55,7 @@ type SignalContext64 struct { Trapno uint64 Oldmask linux.SignalSet Cr2 uint64 - // Pointer to a struct _fpstate. + // Pointer to a struct _fpstate. See b/33003106#comment8. Fpstate uint64 Reserved [8]uint64 } diff --git a/pkg/sentry/control/control_state_autogen.go b/pkg/sentry/control/control_state_autogen.go index a1de4bc6d..bd5797221 100755 --- a/pkg/sentry/control/control_state_autogen.go +++ b/pkg/sentry/control/control_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package control - diff --git a/pkg/sentry/fs/anon/anon_state_autogen.go b/pkg/sentry/fs/anon/anon_state_autogen.go index fcb914212..b2b1a466e 100755 --- a/pkg/sentry/fs/anon/anon_state_autogen.go +++ b/pkg/sentry/fs/anon/anon_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package anon - diff --git a/pkg/sentry/fs/fdpipe/fdpipe_state_autogen.go b/pkg/sentry/fs/fdpipe/fdpipe_state_autogen.go index 38c1ed916..045e3c015 100755 --- a/pkg/sentry/fs/fdpipe/fdpipe_state_autogen.go +++ b/pkg/sentry/fs/fdpipe/fdpipe_state_autogen.go @@ -3,8 +3,8 @@ package fdpipe import ( - "gvisor.dev/gvisor/pkg/state" "gvisor.dev/gvisor/pkg/sentry/fs" + "gvisor.dev/gvisor/pkg/state" ) func (x *pipeOperations) save(m state.Map) { diff --git a/pkg/sentry/fs/fs_state_autogen.go b/pkg/sentry/fs/fs_state_autogen.go index a6820867d..18495fc95 100755 --- a/pkg/sentry/fs/fs_state_autogen.go +++ b/pkg/sentry/fs/fs_state_autogen.go @@ -192,8 +192,12 @@ func (x *Dirent) load(m state.Map) { func (x *DirentCache) beforeSave() {} func (x *DirentCache) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.currentSize) { m.Failf("currentSize is %v, expected zero", x.currentSize) } - if !state.IsZeroValue(x.list) { m.Failf("list is %v, expected zero", x.list) } + if !state.IsZeroValue(x.currentSize) { + m.Failf("currentSize is %v, expected zero", x.currentSize) + } + if !state.IsZeroValue(x.list) { + m.Failf("list is %v, expected zero", x.list) + } m.Save("maxSize", &x.maxSize) m.Save("limit", &x.limit) } @@ -207,7 +211,9 @@ func (x *DirentCache) load(m state.Map) { func (x *DirentCacheLimiter) beforeSave() {} func (x *DirentCacheLimiter) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.count) { m.Failf("count is %v, expected zero", x.count) } + if !state.IsZeroValue(x.count) { + m.Failf("count is %v, expected zero", x.count) + } m.Save("max", &x.max) } diff --git a/pkg/sentry/fs/fsutil/fsutil_impl_state_autogen.go b/pkg/sentry/fs/fsutil/fsutil_impl_state_autogen.go new file mode 100755 index 000000000..59bd445ac --- /dev/null +++ b/pkg/sentry/fs/fsutil/fsutil_impl_state_autogen.go @@ -0,0 +1,169 @@ +// automatically generated by stateify. + +package fsutil + +import ( + "gvisor.dev/gvisor/pkg/state" +) + +func (x *DirtySet) beforeSave() {} +func (x *DirtySet) save(m state.Map) { + x.beforeSave() + var root *DirtySegmentDataSlices = x.saveRoot() + m.SaveValue("root", root) +} + +func (x *DirtySet) afterLoad() {} +func (x *DirtySet) load(m state.Map) { + m.LoadValue("root", new(*DirtySegmentDataSlices), func(y interface{}) { x.loadRoot(y.(*DirtySegmentDataSlices)) }) +} + +func (x *Dirtynode) beforeSave() {} +func (x *Dirtynode) save(m state.Map) { + x.beforeSave() + m.Save("nrSegments", &x.nrSegments) + m.Save("parent", &x.parent) + m.Save("parentIndex", &x.parentIndex) + m.Save("hasChildren", &x.hasChildren) + m.Save("keys", &x.keys) + m.Save("values", &x.values) + m.Save("children", &x.children) +} + +func (x *Dirtynode) afterLoad() {} +func (x *Dirtynode) load(m state.Map) { + m.Load("nrSegments", &x.nrSegments) + m.Load("parent", &x.parent) + m.Load("parentIndex", &x.parentIndex) + m.Load("hasChildren", &x.hasChildren) + m.Load("keys", &x.keys) + m.Load("values", &x.values) + m.Load("children", &x.children) +} + +func (x *DirtySegmentDataSlices) beforeSave() {} +func (x *DirtySegmentDataSlices) save(m state.Map) { + x.beforeSave() + m.Save("Start", &x.Start) + m.Save("End", &x.End) + m.Save("Values", &x.Values) +} + +func (x *DirtySegmentDataSlices) afterLoad() {} +func (x *DirtySegmentDataSlices) load(m state.Map) { + m.Load("Start", &x.Start) + m.Load("End", &x.End) + m.Load("Values", &x.Values) +} + +func (x *FileRangeSet) beforeSave() {} +func (x *FileRangeSet) save(m state.Map) { + x.beforeSave() + var root *FileRangeSegmentDataSlices = x.saveRoot() + m.SaveValue("root", root) +} + +func (x *FileRangeSet) afterLoad() {} +func (x *FileRangeSet) load(m state.Map) { + m.LoadValue("root", new(*FileRangeSegmentDataSlices), func(y interface{}) { x.loadRoot(y.(*FileRangeSegmentDataSlices)) }) +} + +func (x *FileRangenode) beforeSave() {} +func (x *FileRangenode) save(m state.Map) { + x.beforeSave() + m.Save("nrSegments", &x.nrSegments) + m.Save("parent", &x.parent) + m.Save("parentIndex", &x.parentIndex) + m.Save("hasChildren", &x.hasChildren) + m.Save("keys", &x.keys) + m.Save("values", &x.values) + m.Save("children", &x.children) +} + +func (x *FileRangenode) afterLoad() {} +func (x *FileRangenode) load(m state.Map) { + m.Load("nrSegments", &x.nrSegments) + m.Load("parent", &x.parent) + m.Load("parentIndex", &x.parentIndex) + m.Load("hasChildren", &x.hasChildren) + m.Load("keys", &x.keys) + m.Load("values", &x.values) + m.Load("children", &x.children) +} + +func (x *FileRangeSegmentDataSlices) beforeSave() {} +func (x *FileRangeSegmentDataSlices) save(m state.Map) { + x.beforeSave() + m.Save("Start", &x.Start) + m.Save("End", &x.End) + m.Save("Values", &x.Values) +} + +func (x *FileRangeSegmentDataSlices) afterLoad() {} +func (x *FileRangeSegmentDataSlices) load(m state.Map) { + m.Load("Start", &x.Start) + m.Load("End", &x.End) + m.Load("Values", &x.Values) +} + +func (x *FrameRefSet) beforeSave() {} +func (x *FrameRefSet) save(m state.Map) { + x.beforeSave() + var root *FrameRefSegmentDataSlices = x.saveRoot() + m.SaveValue("root", root) +} + +func (x *FrameRefSet) afterLoad() {} +func (x *FrameRefSet) load(m state.Map) { + m.LoadValue("root", new(*FrameRefSegmentDataSlices), func(y interface{}) { x.loadRoot(y.(*FrameRefSegmentDataSlices)) }) +} + +func (x *FrameRefnode) beforeSave() {} +func (x *FrameRefnode) save(m state.Map) { + x.beforeSave() + m.Save("nrSegments", &x.nrSegments) + m.Save("parent", &x.parent) + m.Save("parentIndex", &x.parentIndex) + m.Save("hasChildren", &x.hasChildren) + m.Save("keys", &x.keys) + m.Save("values", &x.values) + m.Save("children", &x.children) +} + +func (x *FrameRefnode) afterLoad() {} +func (x *FrameRefnode) load(m state.Map) { + m.Load("nrSegments", &x.nrSegments) + m.Load("parent", &x.parent) + m.Load("parentIndex", &x.parentIndex) + m.Load("hasChildren", &x.hasChildren) + m.Load("keys", &x.keys) + m.Load("values", &x.values) + m.Load("children", &x.children) +} + +func (x *FrameRefSegmentDataSlices) beforeSave() {} +func (x *FrameRefSegmentDataSlices) save(m state.Map) { + x.beforeSave() + m.Save("Start", &x.Start) + m.Save("End", &x.End) + m.Save("Values", &x.Values) +} + +func (x *FrameRefSegmentDataSlices) afterLoad() {} +func (x *FrameRefSegmentDataSlices) load(m state.Map) { + m.Load("Start", &x.Start) + m.Load("End", &x.End) + m.Load("Values", &x.Values) +} + +func init() { + state.Register("fsutil.DirtySet", (*DirtySet)(nil), state.Fns{Save: (*DirtySet).save, Load: (*DirtySet).load}) + state.Register("fsutil.Dirtynode", (*Dirtynode)(nil), state.Fns{Save: (*Dirtynode).save, Load: (*Dirtynode).load}) + state.Register("fsutil.DirtySegmentDataSlices", (*DirtySegmentDataSlices)(nil), state.Fns{Save: (*DirtySegmentDataSlices).save, Load: (*DirtySegmentDataSlices).load}) + state.Register("fsutil.FileRangeSet", (*FileRangeSet)(nil), state.Fns{Save: (*FileRangeSet).save, Load: (*FileRangeSet).load}) + state.Register("fsutil.FileRangenode", (*FileRangenode)(nil), state.Fns{Save: (*FileRangenode).save, Load: (*FileRangenode).load}) + state.Register("fsutil.FileRangeSegmentDataSlices", (*FileRangeSegmentDataSlices)(nil), state.Fns{Save: (*FileRangeSegmentDataSlices).save, Load: (*FileRangeSegmentDataSlices).load}) + state.Register("fsutil.FrameRefSet", (*FrameRefSet)(nil), state.Fns{Save: (*FrameRefSet).save, Load: (*FrameRefSet).load}) + state.Register("fsutil.FrameRefnode", (*FrameRefnode)(nil), state.Fns{Save: (*FrameRefnode).save, Load: (*FrameRefnode).load}) + state.Register("fsutil.FrameRefSegmentDataSlices", (*FrameRefSegmentDataSlices)(nil), state.Fns{Save: (*FrameRefSegmentDataSlices).save, Load: (*FrameRefSegmentDataSlices).load}) +} diff --git a/pkg/sentry/fs/fsutil/fsutil_state_autogen.go b/pkg/sentry/fs/fsutil/fsutil_state_autogen.go index 3f710099f..284c3dab6 100755 --- a/pkg/sentry/fs/fsutil/fsutil_state_autogen.go +++ b/pkg/sentry/fs/fsutil/fsutil_state_autogen.go @@ -17,56 +17,6 @@ func (x *DirtyInfo) load(m state.Map) { m.Load("Keep", &x.Keep) } -func (x *DirtySet) beforeSave() {} -func (x *DirtySet) save(m state.Map) { - x.beforeSave() - var root *DirtySegmentDataSlices = x.saveRoot() - m.SaveValue("root", root) -} - -func (x *DirtySet) afterLoad() {} -func (x *DirtySet) load(m state.Map) { - m.LoadValue("root", new(*DirtySegmentDataSlices), func(y interface{}) { x.loadRoot(y.(*DirtySegmentDataSlices)) }) -} - -func (x *Dirtynode) beforeSave() {} -func (x *Dirtynode) save(m state.Map) { - x.beforeSave() - m.Save("nrSegments", &x.nrSegments) - m.Save("parent", &x.parent) - m.Save("parentIndex", &x.parentIndex) - m.Save("hasChildren", &x.hasChildren) - m.Save("keys", &x.keys) - m.Save("values", &x.values) - m.Save("children", &x.children) -} - -func (x *Dirtynode) afterLoad() {} -func (x *Dirtynode) load(m state.Map) { - m.Load("nrSegments", &x.nrSegments) - m.Load("parent", &x.parent) - m.Load("parentIndex", &x.parentIndex) - m.Load("hasChildren", &x.hasChildren) - m.Load("keys", &x.keys) - m.Load("values", &x.values) - m.Load("children", &x.children) -} - -func (x *DirtySegmentDataSlices) beforeSave() {} -func (x *DirtySegmentDataSlices) save(m state.Map) { - x.beforeSave() - m.Save("Start", &x.Start) - m.Save("End", &x.End) - m.Save("Values", &x.Values) -} - -func (x *DirtySegmentDataSlices) afterLoad() {} -func (x *DirtySegmentDataSlices) load(m state.Map) { - m.Load("Start", &x.Start) - m.Load("End", &x.End) - m.Load("Values", &x.Values) -} - func (x *StaticDirFileOperations) beforeSave() {} func (x *StaticDirFileOperations) save(m state.Map) { x.beforeSave() @@ -100,106 +50,6 @@ func (x *FileStaticContentReader) load(m state.Map) { m.Load("content", &x.content) } -func (x *FileRangeSet) beforeSave() {} -func (x *FileRangeSet) save(m state.Map) { - x.beforeSave() - var root *FileRangeSegmentDataSlices = x.saveRoot() - m.SaveValue("root", root) -} - -func (x *FileRangeSet) afterLoad() {} -func (x *FileRangeSet) load(m state.Map) { - m.LoadValue("root", new(*FileRangeSegmentDataSlices), func(y interface{}) { x.loadRoot(y.(*FileRangeSegmentDataSlices)) }) -} - -func (x *FileRangenode) beforeSave() {} -func (x *FileRangenode) save(m state.Map) { - x.beforeSave() - m.Save("nrSegments", &x.nrSegments) - m.Save("parent", &x.parent) - m.Save("parentIndex", &x.parentIndex) - m.Save("hasChildren", &x.hasChildren) - m.Save("keys", &x.keys) - m.Save("values", &x.values) - m.Save("children", &x.children) -} - -func (x *FileRangenode) afterLoad() {} -func (x *FileRangenode) load(m state.Map) { - m.Load("nrSegments", &x.nrSegments) - m.Load("parent", &x.parent) - m.Load("parentIndex", &x.parentIndex) - m.Load("hasChildren", &x.hasChildren) - m.Load("keys", &x.keys) - m.Load("values", &x.values) - m.Load("children", &x.children) -} - -func (x *FileRangeSegmentDataSlices) beforeSave() {} -func (x *FileRangeSegmentDataSlices) save(m state.Map) { - x.beforeSave() - m.Save("Start", &x.Start) - m.Save("End", &x.End) - m.Save("Values", &x.Values) -} - -func (x *FileRangeSegmentDataSlices) afterLoad() {} -func (x *FileRangeSegmentDataSlices) load(m state.Map) { - m.Load("Start", &x.Start) - m.Load("End", &x.End) - m.Load("Values", &x.Values) -} - -func (x *FrameRefSet) beforeSave() {} -func (x *FrameRefSet) save(m state.Map) { - x.beforeSave() - var root *FrameRefSegmentDataSlices = x.saveRoot() - m.SaveValue("root", root) -} - -func (x *FrameRefSet) afterLoad() {} -func (x *FrameRefSet) load(m state.Map) { - m.LoadValue("root", new(*FrameRefSegmentDataSlices), func(y interface{}) { x.loadRoot(y.(*FrameRefSegmentDataSlices)) }) -} - -func (x *FrameRefnode) beforeSave() {} -func (x *FrameRefnode) save(m state.Map) { - x.beforeSave() - m.Save("nrSegments", &x.nrSegments) - m.Save("parent", &x.parent) - m.Save("parentIndex", &x.parentIndex) - m.Save("hasChildren", &x.hasChildren) - m.Save("keys", &x.keys) - m.Save("values", &x.values) - m.Save("children", &x.children) -} - -func (x *FrameRefnode) afterLoad() {} -func (x *FrameRefnode) load(m state.Map) { - m.Load("nrSegments", &x.nrSegments) - m.Load("parent", &x.parent) - m.Load("parentIndex", &x.parentIndex) - m.Load("hasChildren", &x.hasChildren) - m.Load("keys", &x.keys) - m.Load("values", &x.values) - m.Load("children", &x.children) -} - -func (x *FrameRefSegmentDataSlices) beforeSave() {} -func (x *FrameRefSegmentDataSlices) save(m state.Map) { - x.beforeSave() - m.Save("Start", &x.Start) - m.Save("End", &x.End) - m.Save("Values", &x.Values) -} - -func (x *FrameRefSegmentDataSlices) afterLoad() {} -func (x *FrameRefSegmentDataSlices) load(m state.Map) { - m.Load("Start", &x.Start) - m.Load("End", &x.End) - m.Load("Values", &x.Values) -} - func (x *HostFileMapper) beforeSave() {} func (x *HostFileMapper) save(m state.Map) { x.beforeSave() @@ -338,18 +188,9 @@ func (x *CachingInodeOperationsOptions) load(m state.Map) { func init() { state.Register("fsutil.DirtyInfo", (*DirtyInfo)(nil), state.Fns{Save: (*DirtyInfo).save, Load: (*DirtyInfo).load}) - state.Register("fsutil.DirtySet", (*DirtySet)(nil), state.Fns{Save: (*DirtySet).save, Load: (*DirtySet).load}) - state.Register("fsutil.Dirtynode", (*Dirtynode)(nil), state.Fns{Save: (*Dirtynode).save, Load: (*Dirtynode).load}) - state.Register("fsutil.DirtySegmentDataSlices", (*DirtySegmentDataSlices)(nil), state.Fns{Save: (*DirtySegmentDataSlices).save, Load: (*DirtySegmentDataSlices).load}) state.Register("fsutil.StaticDirFileOperations", (*StaticDirFileOperations)(nil), state.Fns{Save: (*StaticDirFileOperations).save, Load: (*StaticDirFileOperations).load}) state.Register("fsutil.NoReadWriteFile", (*NoReadWriteFile)(nil), state.Fns{Save: (*NoReadWriteFile).save, Load: (*NoReadWriteFile).load}) state.Register("fsutil.FileStaticContentReader", (*FileStaticContentReader)(nil), state.Fns{Save: (*FileStaticContentReader).save, Load: (*FileStaticContentReader).load}) - state.Register("fsutil.FileRangeSet", (*FileRangeSet)(nil), state.Fns{Save: (*FileRangeSet).save, Load: (*FileRangeSet).load}) - state.Register("fsutil.FileRangenode", (*FileRangenode)(nil), state.Fns{Save: (*FileRangenode).save, Load: (*FileRangenode).load}) - state.Register("fsutil.FileRangeSegmentDataSlices", (*FileRangeSegmentDataSlices)(nil), state.Fns{Save: (*FileRangeSegmentDataSlices).save, Load: (*FileRangeSegmentDataSlices).load}) - state.Register("fsutil.FrameRefSet", (*FrameRefSet)(nil), state.Fns{Save: (*FrameRefSet).save, Load: (*FrameRefSet).load}) - state.Register("fsutil.FrameRefnode", (*FrameRefnode)(nil), state.Fns{Save: (*FrameRefnode).save, Load: (*FrameRefnode).load}) - state.Register("fsutil.FrameRefSegmentDataSlices", (*FrameRefSegmentDataSlices)(nil), state.Fns{Save: (*FrameRefSegmentDataSlices).save, Load: (*FrameRefSegmentDataSlices).load}) state.Register("fsutil.HostFileMapper", (*HostFileMapper)(nil), state.Fns{Save: (*HostFileMapper).save, Load: (*HostFileMapper).load}) state.Register("fsutil.HostMappable", (*HostMappable)(nil), state.Fns{Save: (*HostMappable).save, Load: (*HostMappable).load}) state.Register("fsutil.SimpleFileInode", (*SimpleFileInode)(nil), state.Fns{Save: (*SimpleFileInode).save, Load: (*SimpleFileInode).load}) diff --git a/pkg/sentry/fs/host/host_amd64_unsafe_state_autogen.go b/pkg/sentry/fs/host/host_amd64_unsafe_state_autogen.go index de35761e1..488cbdfcf 100755 --- a/pkg/sentry/fs/host/host_amd64_unsafe_state_autogen.go +++ b/pkg/sentry/fs/host/host_amd64_unsafe_state_autogen.go @@ -3,4 +3,3 @@ // +build amd64 package host - diff --git a/pkg/sentry/fs/host/host_arm64_unsafe_state_autogen.go b/pkg/sentry/fs/host/host_arm64_unsafe_state_autogen.go index ecbc3dd77..7371b44db 100755 --- a/pkg/sentry/fs/host/host_arm64_unsafe_state_autogen.go +++ b/pkg/sentry/fs/host/host_arm64_unsafe_state_autogen.go @@ -3,4 +3,3 @@ // +build arm64 package host - diff --git a/pkg/sentry/fs/host/host_state_autogen.go b/pkg/sentry/fs/host/host_state_autogen.go index e5c487320..d2c40f456 100755 --- a/pkg/sentry/fs/host/host_state_autogen.go +++ b/pkg/sentry/fs/host/host_state_autogen.go @@ -78,7 +78,9 @@ func (x *inodeOperations) load(m state.Map) { func (x *inodeFileState) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.queue) { m.Failf("queue is %v, expected zero", x.queue) } + if !state.IsZeroValue(x.queue) { + m.Failf("queue is %v, expected zero", x.queue) + } m.Save("mops", &x.mops) m.Save("descriptor", &x.descriptor) m.Save("sattr", &x.sattr) diff --git a/pkg/sentry/fs/lock/lock_state_autogen.go b/pkg/sentry/fs/lock/lock_state_autogen.go index cb69e2cd0..ff1200c4c 100755 --- a/pkg/sentry/fs/lock/lock_state_autogen.go +++ b/pkg/sentry/fs/lock/lock_state_autogen.go @@ -24,7 +24,9 @@ func (x *Lock) load(m state.Map) { func (x *Locks) beforeSave() {} func (x *Locks) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.blockedQueue) { m.Failf("blockedQueue is %v, expected zero", x.blockedQueue) } + if !state.IsZeroValue(x.blockedQueue) { + m.Failf("blockedQueue is %v, expected zero", x.blockedQueue) + } m.Save("locks", &x.locks) } diff --git a/pkg/sentry/fs/proc/device/device_state_autogen.go b/pkg/sentry/fs/proc/device/device_state_autogen.go index be407ac45..4a5e3cc88 100755 --- a/pkg/sentry/fs/proc/device/device_state_autogen.go +++ b/pkg/sentry/fs/proc/device/device_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package device - diff --git a/pkg/sentry/fs/timerfd/timerfd_state_autogen.go b/pkg/sentry/fs/timerfd/timerfd_state_autogen.go index e8d98af97..cbbbf972c 100755 --- a/pkg/sentry/fs/timerfd/timerfd_state_autogen.go +++ b/pkg/sentry/fs/timerfd/timerfd_state_autogen.go @@ -9,7 +9,9 @@ import ( func (x *TimerOperations) beforeSave() {} func (x *TimerOperations) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.events) { m.Failf("events is %v, expected zero", x.events) } + if !state.IsZeroValue(x.events) { + m.Failf("events is %v, expected zero", x.events) + } m.Save("timer", &x.timer) m.Save("val", &x.val) } diff --git a/pkg/sentry/fs/tty/tty_state_autogen.go b/pkg/sentry/fs/tty/tty_state_autogen.go index c54600104..28e75eb33 100755 --- a/pkg/sentry/fs/tty/tty_state_autogen.go +++ b/pkg/sentry/fs/tty/tty_state_autogen.go @@ -61,8 +61,12 @@ func (x *superOperations) load(m state.Map) { func (x *lineDiscipline) beforeSave() {} func (x *lineDiscipline) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.masterWaiter) { m.Failf("masterWaiter is %v, expected zero", x.masterWaiter) } - if !state.IsZeroValue(x.slaveWaiter) { m.Failf("slaveWaiter is %v, expected zero", x.slaveWaiter) } + if !state.IsZeroValue(x.masterWaiter) { + m.Failf("masterWaiter is %v, expected zero", x.masterWaiter) + } + if !state.IsZeroValue(x.slaveWaiter) { + m.Failf("slaveWaiter is %v, expected zero", x.slaveWaiter) + } m.Save("size", &x.size) m.Save("inQueue", &x.inQueue) m.Save("outQueue", &x.outQueue) diff --git a/pkg/sentry/hostcpu/hostcpu_state_autogen.go b/pkg/sentry/hostcpu/hostcpu_state_autogen.go index f04a56ec0..97d33d8bf 100755 --- a/pkg/sentry/hostcpu/hostcpu_state_autogen.go +++ b/pkg/sentry/hostcpu/hostcpu_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package hostcpu - diff --git a/pkg/sentry/hostmm/hostmm_state_autogen.go b/pkg/sentry/hostmm/hostmm_state_autogen.go index 730de5101..925c56e14 100755 --- a/pkg/sentry/hostmm/hostmm_state_autogen.go +++ b/pkg/sentry/hostmm/hostmm_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package hostmm - diff --git a/pkg/sentry/kernel/epoll/epoll_state_autogen.go b/pkg/sentry/kernel/epoll/epoll_state_autogen.go index c738a9355..68bc33f08 100755 --- a/pkg/sentry/kernel/epoll/epoll_state_autogen.go +++ b/pkg/sentry/kernel/epoll/epoll_state_autogen.go @@ -43,13 +43,27 @@ func (x *pollEntry) load(m state.Map) { func (x *EventPoll) beforeSave() {} func (x *EventPoll) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.FilePipeSeek) { m.Failf("FilePipeSeek is %v, expected zero", x.FilePipeSeek) } - if !state.IsZeroValue(x.FileNotDirReaddir) { m.Failf("FileNotDirReaddir is %v, expected zero", x.FileNotDirReaddir) } - if !state.IsZeroValue(x.FileNoFsync) { m.Failf("FileNoFsync is %v, expected zero", x.FileNoFsync) } - if !state.IsZeroValue(x.FileNoopFlush) { m.Failf("FileNoopFlush is %v, expected zero", x.FileNoopFlush) } - if !state.IsZeroValue(x.FileNoIoctl) { m.Failf("FileNoIoctl is %v, expected zero", x.FileNoIoctl) } - if !state.IsZeroValue(x.FileNoMMap) { m.Failf("FileNoMMap is %v, expected zero", x.FileNoMMap) } - if !state.IsZeroValue(x.Queue) { m.Failf("Queue is %v, expected zero", x.Queue) } + if !state.IsZeroValue(x.FilePipeSeek) { + m.Failf("FilePipeSeek is %v, expected zero", x.FilePipeSeek) + } + if !state.IsZeroValue(x.FileNotDirReaddir) { + m.Failf("FileNotDirReaddir is %v, expected zero", x.FileNotDirReaddir) + } + if !state.IsZeroValue(x.FileNoFsync) { + m.Failf("FileNoFsync is %v, expected zero", x.FileNoFsync) + } + if !state.IsZeroValue(x.FileNoopFlush) { + m.Failf("FileNoopFlush is %v, expected zero", x.FileNoopFlush) + } + if !state.IsZeroValue(x.FileNoIoctl) { + m.Failf("FileNoIoctl is %v, expected zero", x.FileNoIoctl) + } + if !state.IsZeroValue(x.FileNoMMap) { + m.Failf("FileNoMMap is %v, expected zero", x.FileNoMMap) + } + if !state.IsZeroValue(x.Queue) { + m.Failf("Queue is %v, expected zero", x.Queue) + } m.Save("files", &x.files) m.Save("readyList", &x.readyList) m.Save("waitingList", &x.waitingList) diff --git a/pkg/sentry/kernel/eventfd/eventfd_state_autogen.go b/pkg/sentry/kernel/eventfd/eventfd_state_autogen.go index f6e94b521..ced262ffc 100755 --- a/pkg/sentry/kernel/eventfd/eventfd_state_autogen.go +++ b/pkg/sentry/kernel/eventfd/eventfd_state_autogen.go @@ -9,7 +9,9 @@ import ( func (x *EventOperations) beforeSave() {} func (x *EventOperations) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.wq) { m.Failf("wq is %v, expected zero", x.wq) } + if !state.IsZeroValue(x.wq) { + m.Failf("wq is %v, expected zero", x.wq) + } m.Save("val", &x.val) m.Save("semMode", &x.semMode) m.Save("hostfd", &x.hostfd) diff --git a/pkg/sentry/kernel/futex/futex_state_autogen.go b/pkg/sentry/kernel/futex/futex_state_autogen.go index b2ff39f17..e96b86d1c 100755 --- a/pkg/sentry/kernel/futex/futex_state_autogen.go +++ b/pkg/sentry/kernel/futex/futex_state_autogen.go @@ -21,7 +21,9 @@ func (x *AtomicPtrBucket) load(m state.Map) { func (x *bucket) beforeSave() {} func (x *bucket) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.waiters) { m.Failf("waiters is %v, expected zero", x.waiters) } + if !state.IsZeroValue(x.waiters) { + m.Failf("waiters is %v, expected zero", x.waiters) + } } func (x *bucket) afterLoad() {} @@ -31,7 +33,9 @@ func (x *bucket) load(m state.Map) { func (x *Manager) beforeSave() {} func (x *Manager) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.privateBuckets) { m.Failf("privateBuckets is %v, expected zero", x.privateBuckets) } + if !state.IsZeroValue(x.privateBuckets) { + m.Failf("privateBuckets is %v, expected zero", x.privateBuckets) + } m.Save("sharedBucket", &x.sharedBucket) } diff --git a/pkg/sentry/kernel/kernel.go b/pkg/sentry/kernel/kernel.go index dcd6e91c4..3ee760ba2 100644 --- a/pkg/sentry/kernel/kernel.go +++ b/pkg/sentry/kernel/kernel.go @@ -235,6 +235,9 @@ type Kernel struct { // events. This is initialized lazily on the first unimplemented // syscall. unimplementedSyscallEmitter eventchannel.Emitter `state:"nosave"` + + // SpecialOpts contains special kernel options. + SpecialOpts } // InitKernelArgs holds arguments to Init. diff --git a/pkg/sentry/kernel/kernel_amd64_state_autogen.go b/pkg/sentry/kernel/kernel_amd64_state_autogen.go index 236e69666..12de47ad0 100755 --- a/pkg/sentry/kernel/kernel_amd64_state_autogen.go +++ b/pkg/sentry/kernel/kernel_amd64_state_autogen.go @@ -3,4 +3,3 @@ // +build amd64 package kernel - diff --git a/pkg/sentry/kernel/kernel_arm64_state_autogen.go b/pkg/sentry/kernel/kernel_arm64_state_autogen.go index 2900fe048..3c040d283 100755 --- a/pkg/sentry/kernel/kernel_arm64_state_autogen.go +++ b/pkg/sentry/kernel/kernel_arm64_state_autogen.go @@ -3,4 +3,3 @@ // +build arm64 package kernel - diff --git a/pkg/sentry/kernel/kernel_opts.go b/pkg/sentry/kernel/kernel_opts.go new file mode 100755 index 000000000..2e66ec587 --- /dev/null +++ b/pkg/sentry/kernel/kernel_opts.go @@ -0,0 +1,20 @@ +// Copyright 2020 The gVisor Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package kernel + +// SpecialOpts contains non-standard options for the kernel. +// +// +stateify savable +type SpecialOpts struct{} diff --git a/pkg/sentry/kernel/kernel_opts_state_autogen.go b/pkg/sentry/kernel/kernel_opts_state_autogen.go new file mode 100755 index 000000000..88a3f1072 --- /dev/null +++ b/pkg/sentry/kernel/kernel_opts_state_autogen.go @@ -0,0 +1,20 @@ +// automatically generated by stateify. + +package kernel + +import ( + "gvisor.dev/gvisor/pkg/state" +) + +func (x *SpecialOpts) beforeSave() {} +func (x *SpecialOpts) save(m state.Map) { + x.beforeSave() +} + +func (x *SpecialOpts) afterLoad() {} +func (x *SpecialOpts) load(m state.Map) { +} + +func init() { + state.Register("kernel.SpecialOpts", (*SpecialOpts)(nil), state.Fns{Save: (*SpecialOpts).save, Load: (*SpecialOpts).load}) +} diff --git a/pkg/sentry/kernel/kernel_state_autogen.go b/pkg/sentry/kernel/kernel_state_autogen.go index 0aa106128..ea97733a9 100755 --- a/pkg/sentry/kernel/kernel_state_autogen.go +++ b/pkg/sentry/kernel/kernel_state_autogen.go @@ -3,9 +3,9 @@ package kernel import ( - "gvisor.dev/gvisor/pkg/state" "gvisor.dev/gvisor/pkg/bpf" "gvisor.dev/gvisor/pkg/sentry/device" + "gvisor.dev/gvisor/pkg/state" "gvisor.dev/gvisor/pkg/tcpip" ) @@ -151,6 +151,7 @@ func (x *Kernel) save(m state.Map) { m.Save("sockets", &x.sockets) m.Save("nextSocketEntry", &x.nextSocketEntry) m.Save("DirentCacheLimiter", &x.DirentCacheLimiter) + m.Save("SpecialOpts", &x.SpecialOpts) } func (x *Kernel) afterLoad() {} @@ -182,6 +183,7 @@ func (x *Kernel) load(m state.Map) { m.Load("sockets", &x.sockets) m.Load("nextSocketEntry", &x.nextSocketEntry) m.Load("DirentCacheLimiter", &x.DirentCacheLimiter) + m.Load("SpecialOpts", &x.SpecialOpts) m.LoadValue("danglingEndpoints", new([]tcpip.Endpoint), func(y interface{}) { x.loadDanglingEndpoints(y.([]tcpip.Endpoint)) }) m.LoadValue("deviceRegistry", new(*device.Registry), func(y interface{}) { x.loadDeviceRegistry(y.(*device.Registry)) }) } @@ -522,7 +524,9 @@ func (x *syslog) load(m state.Map) { func (x *Task) beforeSave() {} func (x *Task) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.signalQueue) { m.Failf("signalQueue is %v, expected zero", x.signalQueue) } + if !state.IsZeroValue(x.signalQueue) { + m.Failf("signalQueue is %v, expected zero", x.signalQueue) + } var ptraceTracer *Task = x.savePtraceTracer() m.SaveValue("ptraceTracer", ptraceTracer) var syscallFilters []bpf.Program = x.saveSyscallFilters() diff --git a/pkg/sentry/kernel/memevent/memevent_state_autogen.go b/pkg/sentry/kernel/memevent/memevent_state_autogen.go index 8bfbba80f..4a1679fa9 100755 --- a/pkg/sentry/kernel/memevent/memevent_state_autogen.go +++ b/pkg/sentry/kernel/memevent/memevent_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package memevent - diff --git a/pkg/sentry/kernel/sched/sched_state_autogen.go b/pkg/sentry/kernel/sched/sched_state_autogen.go index 2a482732e..9705ca79d 100755 --- a/pkg/sentry/kernel/sched/sched_state_autogen.go +++ b/pkg/sentry/kernel/sched/sched_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package sched - diff --git a/pkg/sentry/kernel/semaphore/semaphore_state_autogen.go b/pkg/sentry/kernel/semaphore/semaphore_state_autogen.go index f225f6f75..d53d67f74 100755 --- a/pkg/sentry/kernel/semaphore/semaphore_state_autogen.go +++ b/pkg/sentry/kernel/semaphore/semaphore_state_autogen.go @@ -53,7 +53,9 @@ func (x *Set) load(m state.Map) { func (x *sem) beforeSave() {} func (x *sem) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.waiters) { m.Failf("waiters is %v, expected zero", x.waiters) } + if !state.IsZeroValue(x.waiters) { + m.Failf("waiters is %v, expected zero", x.waiters) + } m.Save("value", &x.value) m.Save("pid", &x.pid) } diff --git a/pkg/sentry/memmap/memmap_impl_state_autogen.go b/pkg/sentry/memmap/memmap_impl_state_autogen.go new file mode 100755 index 000000000..53cebac8c --- /dev/null +++ b/pkg/sentry/memmap/memmap_impl_state_autogen.go @@ -0,0 +1,63 @@ +// automatically generated by stateify. + +package memmap + +import ( + "gvisor.dev/gvisor/pkg/state" +) + +func (x *MappingSet) beforeSave() {} +func (x *MappingSet) save(m state.Map) { + x.beforeSave() + var root *MappingSegmentDataSlices = x.saveRoot() + m.SaveValue("root", root) +} + +func (x *MappingSet) afterLoad() {} +func (x *MappingSet) load(m state.Map) { + m.LoadValue("root", new(*MappingSegmentDataSlices), func(y interface{}) { x.loadRoot(y.(*MappingSegmentDataSlices)) }) +} + +func (x *Mappingnode) beforeSave() {} +func (x *Mappingnode) save(m state.Map) { + x.beforeSave() + m.Save("nrSegments", &x.nrSegments) + m.Save("parent", &x.parent) + m.Save("parentIndex", &x.parentIndex) + m.Save("hasChildren", &x.hasChildren) + m.Save("keys", &x.keys) + m.Save("values", &x.values) + m.Save("children", &x.children) +} + +func (x *Mappingnode) afterLoad() {} +func (x *Mappingnode) load(m state.Map) { + m.Load("nrSegments", &x.nrSegments) + m.Load("parent", &x.parent) + m.Load("parentIndex", &x.parentIndex) + m.Load("hasChildren", &x.hasChildren) + m.Load("keys", &x.keys) + m.Load("values", &x.values) + m.Load("children", &x.children) +} + +func (x *MappingSegmentDataSlices) beforeSave() {} +func (x *MappingSegmentDataSlices) save(m state.Map) { + x.beforeSave() + m.Save("Start", &x.Start) + m.Save("End", &x.End) + m.Save("Values", &x.Values) +} + +func (x *MappingSegmentDataSlices) afterLoad() {} +func (x *MappingSegmentDataSlices) load(m state.Map) { + m.Load("Start", &x.Start) + m.Load("End", &x.End) + m.Load("Values", &x.Values) +} + +func init() { + state.Register("memmap.MappingSet", (*MappingSet)(nil), state.Fns{Save: (*MappingSet).save, Load: (*MappingSet).load}) + state.Register("memmap.Mappingnode", (*Mappingnode)(nil), state.Fns{Save: (*Mappingnode).save, Load: (*Mappingnode).load}) + state.Register("memmap.MappingSegmentDataSlices", (*MappingSegmentDataSlices)(nil), state.Fns{Save: (*MappingSegmentDataSlices).save, Load: (*MappingSegmentDataSlices).load}) +} diff --git a/pkg/sentry/memmap/memmap_state_autogen.go b/pkg/sentry/memmap/memmap_state_autogen.go index 2d0814ab1..16107f949 100755 --- a/pkg/sentry/memmap/memmap_state_autogen.go +++ b/pkg/sentry/memmap/memmap_state_autogen.go @@ -34,60 +34,7 @@ func (x *MappingOfRange) load(m state.Map) { m.Load("Writable", &x.Writable) } -func (x *MappingSet) beforeSave() {} -func (x *MappingSet) save(m state.Map) { - x.beforeSave() - var root *MappingSegmentDataSlices = x.saveRoot() - m.SaveValue("root", root) -} - -func (x *MappingSet) afterLoad() {} -func (x *MappingSet) load(m state.Map) { - m.LoadValue("root", new(*MappingSegmentDataSlices), func(y interface{}) { x.loadRoot(y.(*MappingSegmentDataSlices)) }) -} - -func (x *Mappingnode) beforeSave() {} -func (x *Mappingnode) save(m state.Map) { - x.beforeSave() - m.Save("nrSegments", &x.nrSegments) - m.Save("parent", &x.parent) - m.Save("parentIndex", &x.parentIndex) - m.Save("hasChildren", &x.hasChildren) - m.Save("keys", &x.keys) - m.Save("values", &x.values) - m.Save("children", &x.children) -} - -func (x *Mappingnode) afterLoad() {} -func (x *Mappingnode) load(m state.Map) { - m.Load("nrSegments", &x.nrSegments) - m.Load("parent", &x.parent) - m.Load("parentIndex", &x.parentIndex) - m.Load("hasChildren", &x.hasChildren) - m.Load("keys", &x.keys) - m.Load("values", &x.values) - m.Load("children", &x.children) -} - -func (x *MappingSegmentDataSlices) beforeSave() {} -func (x *MappingSegmentDataSlices) save(m state.Map) { - x.beforeSave() - m.Save("Start", &x.Start) - m.Save("End", &x.End) - m.Save("Values", &x.Values) -} - -func (x *MappingSegmentDataSlices) afterLoad() {} -func (x *MappingSegmentDataSlices) load(m state.Map) { - m.Load("Start", &x.Start) - m.Load("End", &x.End) - m.Load("Values", &x.Values) -} - func init() { state.Register("memmap.MappableRange", (*MappableRange)(nil), state.Fns{Save: (*MappableRange).save, Load: (*MappableRange).load}) state.Register("memmap.MappingOfRange", (*MappingOfRange)(nil), state.Fns{Save: (*MappingOfRange).save, Load: (*MappingOfRange).load}) - state.Register("memmap.MappingSet", (*MappingSet)(nil), state.Fns{Save: (*MappingSet).save, Load: (*MappingSet).load}) - state.Register("memmap.Mappingnode", (*Mappingnode)(nil), state.Fns{Save: (*Mappingnode).save, Load: (*Mappingnode).load}) - state.Register("memmap.MappingSegmentDataSlices", (*MappingSegmentDataSlices)(nil), state.Fns{Save: (*MappingSegmentDataSlices).save, Load: (*MappingSegmentDataSlices).load}) } diff --git a/pkg/sentry/mm/mm_state_autogen.go b/pkg/sentry/mm/mm_state_autogen.go index 3b5af2401..9a9b4347d 100755 --- a/pkg/sentry/mm/mm_state_autogen.go +++ b/pkg/sentry/mm/mm_state_autogen.go @@ -33,7 +33,9 @@ func (x *ioResult) load(m state.Map) { func (x *AIOContext) beforeSave() {} func (x *AIOContext) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.dead) { m.Failf("dead is %v, expected zero", x.dead) } + if !state.IsZeroValue(x.dead) { + m.Failf("dead is %v, expected zero", x.dead) + } m.Save("results", &x.results) m.Save("maxOutstanding", &x.maxOutstanding) m.Save("outstanding", &x.outstanding) @@ -139,8 +141,12 @@ func (x *ioEntry) load(m state.Map) { func (x *MemoryManager) save(m state.Map) { x.beforeSave() - if !state.IsZeroValue(x.active) { m.Failf("active is %v, expected zero", x.active) } - if !state.IsZeroValue(x.captureInvalidations) { m.Failf("captureInvalidations is %v, expected zero", x.captureInvalidations) } + if !state.IsZeroValue(x.active) { + m.Failf("active is %v, expected zero", x.active) + } + if !state.IsZeroValue(x.captureInvalidations) { + m.Failf("captureInvalidations is %v, expected zero", x.captureInvalidations) + } m.Save("p", &x.p) m.Save("mfp", &x.mfp) m.Save("layout", &x.layout) diff --git a/pkg/sentry/platform/interrupt/interrupt_state_autogen.go b/pkg/sentry/platform/interrupt/interrupt_state_autogen.go index 15e8bacdf..1336e5f01 100755 --- a/pkg/sentry/platform/interrupt/interrupt_state_autogen.go +++ b/pkg/sentry/platform/interrupt/interrupt_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package interrupt - diff --git a/pkg/sentry/platform/kvm/kvm_amd64_state_autogen.go b/pkg/sentry/platform/kvm/kvm_amd64_state_autogen.go index 0c21ccdb4..a69cbee8b 100755 --- a/pkg/sentry/platform/kvm/kvm_amd64_state_autogen.go +++ b/pkg/sentry/platform/kvm/kvm_amd64_state_autogen.go @@ -5,4 +5,3 @@ // +build amd64 package kvm - diff --git a/pkg/sentry/platform/kvm/kvm_amd64_unsafe_state_autogen.go b/pkg/sentry/platform/kvm/kvm_amd64_unsafe_state_autogen.go index 0c21ccdb4..a69cbee8b 100755 --- a/pkg/sentry/platform/kvm/kvm_amd64_unsafe_state_autogen.go +++ b/pkg/sentry/platform/kvm/kvm_amd64_unsafe_state_autogen.go @@ -5,4 +5,3 @@ // +build amd64 package kvm - diff --git a/pkg/sentry/platform/kvm/kvm_arm64_state_autogen.go b/pkg/sentry/platform/kvm/kvm_arm64_state_autogen.go index 94b93bea5..90183b764 100755 --- a/pkg/sentry/platform/kvm/kvm_arm64_state_autogen.go +++ b/pkg/sentry/platform/kvm/kvm_arm64_state_autogen.go @@ -5,4 +5,3 @@ // +build arm64 package kvm - diff --git a/pkg/sentry/platform/kvm/kvm_arm64_unsafe_state_autogen.go b/pkg/sentry/platform/kvm/kvm_arm64_unsafe_state_autogen.go index 94b93bea5..90183b764 100755 --- a/pkg/sentry/platform/kvm/kvm_arm64_unsafe_state_autogen.go +++ b/pkg/sentry/platform/kvm/kvm_arm64_unsafe_state_autogen.go @@ -5,4 +5,3 @@ // +build arm64 package kvm - diff --git a/pkg/sentry/platform/kvm/kvm_state_autogen.go b/pkg/sentry/platform/kvm/kvm_state_autogen.go index f34ac0945..2325262dc 100755 --- a/pkg/sentry/platform/kvm/kvm_state_autogen.go +++ b/pkg/sentry/platform/kvm/kvm_state_autogen.go @@ -6,4 +6,3 @@ // +build !go1.15 package kvm - diff --git a/pkg/sentry/platform/ptrace/ptrace_amd64_state_autogen.go b/pkg/sentry/platform/ptrace/ptrace_amd64_state_autogen.go index 09e133aac..f730ab393 100755 --- a/pkg/sentry/platform/ptrace/ptrace_amd64_state_autogen.go +++ b/pkg/sentry/platform/ptrace/ptrace_amd64_state_autogen.go @@ -3,4 +3,3 @@ // +build amd64 package ptrace - diff --git a/pkg/sentry/platform/ptrace/ptrace_arm64_state_autogen.go b/pkg/sentry/platform/ptrace/ptrace_arm64_state_autogen.go index 78ce51a66..6239d1305 100755 --- a/pkg/sentry/platform/ptrace/ptrace_arm64_state_autogen.go +++ b/pkg/sentry/platform/ptrace/ptrace_arm64_state_autogen.go @@ -3,4 +3,3 @@ // +build arm64 package ptrace - diff --git a/pkg/sentry/platform/ptrace/ptrace_linux_state_autogen.go b/pkg/sentry/platform/ptrace/ptrace_linux_state_autogen.go index 67b04a65b..9f90aef93 100755 --- a/pkg/sentry/platform/ptrace/ptrace_linux_state_autogen.go +++ b/pkg/sentry/platform/ptrace/ptrace_linux_state_autogen.go @@ -3,4 +3,3 @@ // +build linux package ptrace - diff --git a/pkg/sentry/platform/ptrace/ptrace_linux_unsafe_state_autogen.go b/pkg/sentry/platform/ptrace/ptrace_linux_unsafe_state_autogen.go index bfea2ad67..45d94c547 100755 --- a/pkg/sentry/platform/ptrace/ptrace_linux_unsafe_state_autogen.go +++ b/pkg/sentry/platform/ptrace/ptrace_linux_unsafe_state_autogen.go @@ -4,4 +4,3 @@ // +build amd64 arm64 package ptrace - diff --git a/pkg/sentry/platform/ptrace/ptrace_state_autogen.go b/pkg/sentry/platform/ptrace/ptrace_state_autogen.go index 3a0b1ca8d..4526fc387 100755 --- a/pkg/sentry/platform/ptrace/ptrace_state_autogen.go +++ b/pkg/sentry/platform/ptrace/ptrace_state_autogen.go @@ -4,4 +4,3 @@ // +build !go1.15 package ptrace - diff --git a/pkg/sentry/platform/ring0/pagetables/pagetables_aarch64_state_autogen.go b/pkg/sentry/platform/ring0/pagetables/pagetables_aarch64_state_autogen.go index 31ec1653a..ae9d2b272 100755 --- a/pkg/sentry/platform/ring0/pagetables/pagetables_aarch64_state_autogen.go +++ b/pkg/sentry/platform/ring0/pagetables/pagetables_aarch64_state_autogen.go @@ -3,4 +3,3 @@ // +build arm64 package pagetables - diff --git a/pkg/sentry/platform/ring0/pagetables/pagetables_amd64_state_autogen.go b/pkg/sentry/platform/ring0/pagetables/pagetables_amd64_state_autogen.go index d1ad040cd..f48a8acd1 100755 --- a/pkg/sentry/platform/ring0/pagetables/pagetables_amd64_state_autogen.go +++ b/pkg/sentry/platform/ring0/pagetables/pagetables_amd64_state_autogen.go @@ -3,4 +3,3 @@ // +build amd64 package pagetables - diff --git a/pkg/sentry/platform/ring0/pagetables/pagetables_arm64_state_autogen.go b/pkg/sentry/platform/ring0/pagetables/pagetables_arm64_state_autogen.go index 31ec1653a..ae9d2b272 100755 --- a/pkg/sentry/platform/ring0/pagetables/pagetables_arm64_state_autogen.go +++ b/pkg/sentry/platform/ring0/pagetables/pagetables_arm64_state_autogen.go @@ -3,4 +3,3 @@ // +build arm64 package pagetables - diff --git a/pkg/sentry/platform/ring0/pagetables/pagetables_state_autogen.go b/pkg/sentry/platform/ring0/pagetables/pagetables_state_autogen.go index 2cebb95e4..c1148613d 100755 --- a/pkg/sentry/platform/ring0/pagetables/pagetables_state_autogen.go +++ b/pkg/sentry/platform/ring0/pagetables/pagetables_state_autogen.go @@ -4,4 +4,3 @@ // +build i386 amd64 package pagetables - diff --git a/pkg/sentry/platform/ring0/ring0_amd64_state_autogen.go b/pkg/sentry/platform/ring0/ring0_amd64_state_autogen.go index 6d8150b0e..96cf5d331 100755 --- a/pkg/sentry/platform/ring0/ring0_amd64_state_autogen.go +++ b/pkg/sentry/platform/ring0/ring0_amd64_state_autogen.go @@ -5,4 +5,3 @@ // +build amd64 package ring0 - diff --git a/pkg/sentry/platform/ring0/ring0_arm64_state_autogen.go b/pkg/sentry/platform/ring0/ring0_arm64_state_autogen.go index 392e48d4b..7f2ab3537 100755 --- a/pkg/sentry/platform/ring0/ring0_arm64_state_autogen.go +++ b/pkg/sentry/platform/ring0/ring0_arm64_state_autogen.go @@ -5,4 +5,3 @@ // +build arm64 package ring0 - diff --git a/pkg/sentry/platform/ring0/ring0_state_autogen.go b/pkg/sentry/platform/ring0/ring0_state_autogen.go index 462f9a446..327aba163 100755 --- a/pkg/sentry/platform/ring0/ring0_state_autogen.go +++ b/pkg/sentry/platform/ring0/ring0_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package ring0 - diff --git a/pkg/sentry/sighandling/sighandling_state_autogen.go b/pkg/sentry/sighandling/sighandling_state_autogen.go index dad4bdda2..da9d96382 100755 --- a/pkg/sentry/sighandling/sighandling_state_autogen.go +++ b/pkg/sentry/sighandling/sighandling_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package sighandling - diff --git a/pkg/sentry/socket/control/control_state_autogen.go b/pkg/sentry/socket/control/control_state_autogen.go index c5ecfe700..6271abd8c 100755 --- a/pkg/sentry/socket/control/control_state_autogen.go +++ b/pkg/sentry/socket/control/control_state_autogen.go @@ -3,8 +3,8 @@ package control import ( - "gvisor.dev/gvisor/pkg/state" "gvisor.dev/gvisor/pkg/sentry/fs" + "gvisor.dev/gvisor/pkg/state" ) func (x *RightsFiles) save(m state.Map) { diff --git a/pkg/sentry/socket/hostinet/hostinet_impl_state_autogen.go b/pkg/sentry/socket/hostinet/hostinet_impl_state_autogen.go new file mode 100755 index 000000000..b0a59ba93 --- /dev/null +++ b/pkg/sentry/socket/hostinet/hostinet_impl_state_autogen.go @@ -0,0 +1,3 @@ +// automatically generated by stateify. + +package hostinet diff --git a/pkg/sentry/socket/hostinet/hostinet_state_autogen.go b/pkg/sentry/socket/hostinet/hostinet_state_autogen.go index 0a5c7cdf3..b0a59ba93 100755 --- a/pkg/sentry/socket/hostinet/hostinet_state_autogen.go +++ b/pkg/sentry/socket/hostinet/hostinet_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package hostinet - diff --git a/pkg/sentry/socket/hostinet/socket.go b/pkg/sentry/socket/hostinet/socket.go index 34f63986f..de76388ac 100644 --- a/pkg/sentry/socket/hostinet/socket.go +++ b/pkg/sentry/socket/hostinet/socket.go @@ -285,7 +285,7 @@ func (s *socketOperations) GetSockOpt(t *kernel.Task, level int, name int, outPt } // Whitelist options and constrain option length. - var optlen int + optlen := getSockOptLen(t, level, name) switch level { case linux.SOL_IP: switch name { @@ -330,7 +330,7 @@ func (s *socketOperations) GetSockOpt(t *kernel.Task, level int, name int, outPt // SetSockOpt implements socket.Socket.SetSockOpt. func (s *socketOperations) SetSockOpt(t *kernel.Task, level int, name int, opt []byte) *syserr.Error { // Whitelist options and constrain option length. - var optlen int + optlen := setSockOptLen(t, level, name) switch level { case linux.SOL_IP: switch name { @@ -353,6 +353,7 @@ func (s *socketOperations) SetSockOpt(t *kernel.Task, level int, name int, opt [ optlen = sizeofInt32 } } + if optlen == 0 { // Pretend to accept socket options we don't understand. This seems // dangerous, but it's what netstack does... diff --git a/pkg/sentry/socket/hostinet/sockopt_impl.go b/pkg/sentry/socket/hostinet/sockopt_impl.go new file mode 100755 index 000000000..8a783712e --- /dev/null +++ b/pkg/sentry/socket/hostinet/sockopt_impl.go @@ -0,0 +1,27 @@ +// Copyright 2020 The gVisor Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package hostinet + +import ( + "gvisor.dev/gvisor/pkg/sentry/kernel" +) + +func getSockOptLen(t *kernel.Task, level, name int) int { + return 0 // No custom options. +} + +func setSockOptLen(t *kernel.Task, level, name int) int { + return 0 // No custom options. +} diff --git a/pkg/sentry/socket/netfilter/netfilter_state_autogen.go b/pkg/sentry/socket/netfilter/netfilter_state_autogen.go index f3d68dd64..6e95d89a4 100755 --- a/pkg/sentry/socket/netfilter/netfilter_state_autogen.go +++ b/pkg/sentry/socket/netfilter/netfilter_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package netfilter - diff --git a/pkg/sentry/state/state_state_autogen.go b/pkg/sentry/state/state_state_autogen.go index 6c0d9b7a7..6c2b29632 100755 --- a/pkg/sentry/state/state_state_autogen.go +++ b/pkg/sentry/state/state_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package state - diff --git a/pkg/sentry/strace/strace_amd64_state_autogen.go b/pkg/sentry/strace/strace_amd64_state_autogen.go index 844e83b55..c7d4b3eb4 100755 --- a/pkg/sentry/strace/strace_amd64_state_autogen.go +++ b/pkg/sentry/strace/strace_amd64_state_autogen.go @@ -3,4 +3,3 @@ // +build amd64 package strace - diff --git a/pkg/sentry/strace/strace_arm64_state_autogen.go b/pkg/sentry/strace/strace_arm64_state_autogen.go index 6f61e1610..9b8f66dc9 100755 --- a/pkg/sentry/strace/strace_arm64_state_autogen.go +++ b/pkg/sentry/strace/strace_arm64_state_autogen.go @@ -3,4 +3,3 @@ // +build arm64 package strace - diff --git a/pkg/sentry/strace/strace_state_autogen.go b/pkg/sentry/strace/strace_state_autogen.go index 9dc697ed6..33f6a7a54 100755 --- a/pkg/sentry/strace/strace_state_autogen.go +++ b/pkg/sentry/strace/strace_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package strace - diff --git a/pkg/sentry/syscalls/linux/linux_amd64_state_autogen.go b/pkg/sentry/syscalls/linux/linux_amd64_state_autogen.go index db9570e4e..a98193a5b 100755 --- a/pkg/sentry/syscalls/linux/linux_amd64_state_autogen.go +++ b/pkg/sentry/syscalls/linux/linux_amd64_state_autogen.go @@ -4,4 +4,3 @@ // +build amd64 package linux - diff --git a/pkg/sentry/syscalls/linux/linux_arm64_state_autogen.go b/pkg/sentry/syscalls/linux/linux_arm64_state_autogen.go index d3a92b86f..b144adbda 100755 --- a/pkg/sentry/syscalls/linux/linux_arm64_state_autogen.go +++ b/pkg/sentry/syscalls/linux/linux_arm64_state_autogen.go @@ -4,4 +4,3 @@ // +build arm64 package linux - diff --git a/pkg/sentry/syscalls/linux/vfs2/vfs2_amd64_state_autogen.go b/pkg/sentry/syscalls/linux/vfs2/vfs2_amd64_state_autogen.go index b049dbca1..1ca38ac2e 100755 --- a/pkg/sentry/syscalls/linux/vfs2/vfs2_amd64_state_autogen.go +++ b/pkg/sentry/syscalls/linux/vfs2/vfs2_amd64_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package vfs2 - diff --git a/pkg/sentry/syscalls/linux/vfs2/vfs2_arm64_state_autogen.go b/pkg/sentry/syscalls/linux/vfs2/vfs2_arm64_state_autogen.go index b049dbca1..1ca38ac2e 100755 --- a/pkg/sentry/syscalls/linux/vfs2/vfs2_arm64_state_autogen.go +++ b/pkg/sentry/syscalls/linux/vfs2/vfs2_arm64_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package vfs2 - diff --git a/pkg/sentry/syscalls/linux/vfs2/vfs2_state_autogen.go b/pkg/sentry/syscalls/linux/vfs2/vfs2_state_autogen.go index b049dbca1..1ca38ac2e 100755 --- a/pkg/sentry/syscalls/linux/vfs2/vfs2_state_autogen.go +++ b/pkg/sentry/syscalls/linux/vfs2/vfs2_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package vfs2 - diff --git a/pkg/sentry/syscalls/syscalls_state_autogen.go b/pkg/sentry/syscalls/syscalls_state_autogen.go index c114e7989..b577e39a3 100755 --- a/pkg/sentry/syscalls/syscalls_state_autogen.go +++ b/pkg/sentry/syscalls/syscalls_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package syscalls - diff --git a/pkg/sentry/time/time_arm64_state_autogen.go b/pkg/sentry/time/time_arm64_state_autogen.go index ea614b056..2adc9c9e0 100755 --- a/pkg/sentry/time/time_arm64_state_autogen.go +++ b/pkg/sentry/time/time_arm64_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package time - diff --git a/pkg/sentry/time/time_state_autogen.go b/pkg/sentry/time/time_state_autogen.go index ea614b056..2adc9c9e0 100755 --- a/pkg/sentry/time/time_state_autogen.go +++ b/pkg/sentry/time/time_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package time - diff --git a/pkg/sentry/unimpl/unimpl_state_autogen.go b/pkg/sentry/unimpl/unimpl_state_autogen.go index b9d1116f3..b37d16f87 100755 --- a/pkg/sentry/unimpl/unimpl_state_autogen.go +++ b/pkg/sentry/unimpl/unimpl_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package unimpl - diff --git a/pkg/sentry/uniqueid/uniqueid_state_autogen.go b/pkg/sentry/uniqueid/uniqueid_state_autogen.go index 09e4327e4..1890fdf46 100755 --- a/pkg/sentry/uniqueid/uniqueid_state_autogen.go +++ b/pkg/sentry/uniqueid/uniqueid_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package uniqueid - diff --git a/pkg/sentry/watchdog/watchdog_state_autogen.go b/pkg/sentry/watchdog/watchdog_state_autogen.go index 530ac6a07..bce0200e7 100755 --- a/pkg/sentry/watchdog/watchdog_state_autogen.go +++ b/pkg/sentry/watchdog/watchdog_state_autogen.go @@ -1,4 +1,3 @@ // automatically generated by stateify. package watchdog - |