summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/proc
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2018-08-01 19:56:12 -0700
committerShentubot <shentubot@google.com>2018-08-01 19:57:32 -0700
commit60add78980737a7330100d98bf6a214892dee3c0 (patch)
tree14433da4615d2010a5d34ade91ff94b938c5a9b5 /pkg/sentry/fs/proc
parentb9e1cf8404ce1263176643dee1a1cc835c9d1448 (diff)
Automated rollback of changelist 207007153
PiperOrigin-RevId: 207037226 Change-Id: I8b5f1a056d4f3eab17846f2e0193bb737ecb5428
Diffstat (limited to 'pkg/sentry/fs/proc')
-rw-r--r--pkg/sentry/fs/proc/BUILD34
-rw-r--r--pkg/sentry/fs/proc/cpuinfo.go2
-rw-r--r--pkg/sentry/fs/proc/exec_args.go2
-rw-r--r--pkg/sentry/fs/proc/fds.go6
-rw-r--r--pkg/sentry/fs/proc/file.go1
-rw-r--r--pkg/sentry/fs/proc/filesystems.go2
-rw-r--r--pkg/sentry/fs/proc/fs.go2
-rw-r--r--pkg/sentry/fs/proc/loadavg.go2
-rw-r--r--pkg/sentry/fs/proc/meminfo.go2
-rw-r--r--pkg/sentry/fs/proc/mounts.go4
-rw-r--r--pkg/sentry/fs/proc/proc.go4
-rw-r--r--pkg/sentry/fs/proc/seqfile/BUILD30
-rw-r--r--pkg/sentry/fs/proc/seqfile/seqfile.go4
-rw-r--r--pkg/sentry/fs/proc/stat.go2
-rw-r--r--pkg/sentry/fs/proc/sys.go5
-rw-r--r--pkg/sentry/fs/proc/sys_net.go2
-rw-r--r--pkg/sentry/fs/proc/task.go20
-rw-r--r--pkg/sentry/fs/proc/uid_gid_map.go3
-rw-r--r--pkg/sentry/fs/proc/uptime.go2
-rw-r--r--pkg/sentry/fs/proc/version.go2
20 files changed, 59 insertions, 72 deletions
diff --git a/pkg/sentry/fs/proc/BUILD b/pkg/sentry/fs/proc/BUILD
index 2d9f07f2f..870df47b2 100644
--- a/pkg/sentry/fs/proc/BUILD
+++ b/pkg/sentry/fs/proc/BUILD
@@ -1,6 +1,32 @@
package(licenses = ["notice"]) # Apache 2.0
-load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
+
+go_stateify(
+ name = "proc_state",
+ srcs = [
+ "cpuinfo.go",
+ "exec_args.go",
+ "fds.go",
+ "file.go",
+ "filesystems.go",
+ "fs.go",
+ "loadavg.go",
+ "meminfo.go",
+ "mounts.go",
+ "net.go",
+ "proc.go",
+ "stat.go",
+ "sys.go",
+ "sys_net.go",
+ "task.go",
+ "uid_gid_map.go",
+ "uptime.go",
+ "version.go",
+ ],
+ out = "proc_state.go",
+ package = "proc",
+)
go_library(
name = "proc",
@@ -16,6 +42,7 @@ go_library(
"mounts.go",
"net.go",
"proc.go",
+ "proc_state.go",
"rpcinet_proc.go",
"stat.go",
"sys.go",
@@ -29,6 +56,9 @@ go_library(
visibility = ["//pkg/sentry:internal"],
deps = [
"//pkg/abi/linux",
+ "//pkg/amutex",
+ "//pkg/log",
+ "//pkg/sentry/arch",
"//pkg/sentry/context",
"//pkg/sentry/fs",
"//pkg/sentry/fs/proc/device",
@@ -43,6 +73,8 @@ go_library(
"//pkg/sentry/socket/rpcinet",
"//pkg/sentry/usage",
"//pkg/sentry/usermem",
+ "//pkg/state",
+ "//pkg/syserr",
"//pkg/syserror",
],
)
diff --git a/pkg/sentry/fs/proc/cpuinfo.go b/pkg/sentry/fs/proc/cpuinfo.go
index 4dfec03a4..f80aaa5b1 100644
--- a/pkg/sentry/fs/proc/cpuinfo.go
+++ b/pkg/sentry/fs/proc/cpuinfo.go
@@ -27,8 +27,6 @@ import (
// cpuinfo is a file describing the CPU capabilities.
//
// Presently cpuinfo never changes, so it doesn't need to be a SeqFile.
-//
-// +stateify savable
type cpuinfo struct {
ramfs.Entry
diff --git a/pkg/sentry/fs/proc/exec_args.go b/pkg/sentry/fs/proc/exec_args.go
index a69cbaa0e..0e1523bf1 100644
--- a/pkg/sentry/fs/proc/exec_args.go
+++ b/pkg/sentry/fs/proc/exec_args.go
@@ -37,8 +37,6 @@ const (
// execArgFile is a file containing the exec args (either cmdline or environ)
// for a given task.
-//
-// +stateify savable
type execArgFile struct {
ramfs.Entry
diff --git a/pkg/sentry/fs/proc/fds.go b/pkg/sentry/fs/proc/fds.go
index cca8f874c..194a9c12a 100644
--- a/pkg/sentry/fs/proc/fds.go
+++ b/pkg/sentry/fs/proc/fds.go
@@ -138,8 +138,6 @@ func (f *fd) Close() error {
}
// fdDir implements /proc/TID/fd.
-//
-// +stateify savable
type fdDir struct {
ramfs.Dir
@@ -199,8 +197,6 @@ func (f *fdDir) DeprecatedReaddir(ctx context.Context, dirCtx *fs.DirCtx, offset
}
// fdInfo is a single file in /proc/TID/fdinfo/.
-//
-// +stateify savable
type fdInfo struct {
ramfs.File
@@ -233,8 +229,6 @@ func (*fdInfo) Truncate(ctx context.Context, inode *fs.Inode, size int64) error
// fdInfoDir implements /proc/TID/fdinfo. It embeds an fdDir, but overrides
// Lookup and Readdir.
-//
-// +stateify savable
type fdInfoDir struct {
ramfs.Dir
diff --git a/pkg/sentry/fs/proc/file.go b/pkg/sentry/fs/proc/file.go
index 4b2d08e75..9a433cdf8 100644
--- a/pkg/sentry/fs/proc/file.go
+++ b/pkg/sentry/fs/proc/file.go
@@ -22,7 +22,6 @@ import (
"gvisor.googlesource.com/gvisor/pkg/sentry/usermem"
)
-// +stateify savable
type file struct {
fs.InodeOperations
diff --git a/pkg/sentry/fs/proc/filesystems.go b/pkg/sentry/fs/proc/filesystems.go
index 49b92fd8a..37db9cf9c 100644
--- a/pkg/sentry/fs/proc/filesystems.go
+++ b/pkg/sentry/fs/proc/filesystems.go
@@ -24,8 +24,6 @@ import (
)
// filesystemsData backs /proc/filesystems.
-//
-// +stateify savable
type filesystemsData struct{}
// NeedsUpdate returns true on the first generation. The set of registered file
diff --git a/pkg/sentry/fs/proc/fs.go b/pkg/sentry/fs/proc/fs.go
index 061824b8c..3aadd6ac4 100644
--- a/pkg/sentry/fs/proc/fs.go
+++ b/pkg/sentry/fs/proc/fs.go
@@ -22,8 +22,6 @@ import (
)
// filesystem is a procfs.
-//
-// +stateify savable
type filesystem struct{}
func init() {
diff --git a/pkg/sentry/fs/proc/loadavg.go b/pkg/sentry/fs/proc/loadavg.go
index 6fac251d2..7583b6ccd 100644
--- a/pkg/sentry/fs/proc/loadavg.go
+++ b/pkg/sentry/fs/proc/loadavg.go
@@ -23,8 +23,6 @@ import (
)
// loadavgData backs /proc/loadavg.
-//
-// +stateify savable
type loadavgData struct{}
// NeedsUpdate implements seqfile.SeqSource.NeedsUpdate.
diff --git a/pkg/sentry/fs/proc/meminfo.go b/pkg/sentry/fs/proc/meminfo.go
index 53dfd59ef..49cb0faed 100644
--- a/pkg/sentry/fs/proc/meminfo.go
+++ b/pkg/sentry/fs/proc/meminfo.go
@@ -26,8 +26,6 @@ import (
)
// meminfoData backs /proc/meminfo.
-//
-// +stateify savable
type meminfoData struct {
// k is the owning Kernel.
k *kernel.Kernel
diff --git a/pkg/sentry/fs/proc/mounts.go b/pkg/sentry/fs/proc/mounts.go
index 2b8167c28..108432f4e 100644
--- a/pkg/sentry/fs/proc/mounts.go
+++ b/pkg/sentry/fs/proc/mounts.go
@@ -71,8 +71,6 @@ func forEachMountSource(t *kernel.Task, fn func(string, *fs.MountSource)) {
}
// mountInfoFile is used to implement /proc/[pid]/mountinfo.
-//
-// +stateify savable
type mountInfoFile struct {
t *kernel.Task
}
@@ -154,8 +152,6 @@ func (mif *mountInfoFile) ReadSeqFileData(ctx context.Context, handle seqfile.Se
}
// mountsFile is used to implement /proc/[pid]/mountinfo.
-//
-// +stateify savable
type mountsFile struct {
t *kernel.Task
}
diff --git a/pkg/sentry/fs/proc/proc.go b/pkg/sentry/fs/proc/proc.go
index 07029a7bb..b2a8d639c 100644
--- a/pkg/sentry/fs/proc/proc.go
+++ b/pkg/sentry/fs/proc/proc.go
@@ -33,8 +33,6 @@ import (
)
// proc is a root proc node.
-//
-// +stateify savable
type proc struct {
ramfs.Dir
@@ -49,8 +47,6 @@ type proc struct {
// stubProcFSFile is a file type that can be used to return file contents
// which are constant. This file is not writable and will always have mode
// 0444.
-//
-// +stateify savable
type stubProcFSFile struct {
ramfs.Entry
diff --git a/pkg/sentry/fs/proc/seqfile/BUILD b/pkg/sentry/fs/proc/seqfile/BUILD
index 53c475652..c84f7e20d 100644
--- a/pkg/sentry/fs/proc/seqfile/BUILD
+++ b/pkg/sentry/fs/proc/seqfile/BUILD
@@ -1,10 +1,22 @@
package(licenses = ["notice"]) # Apache 2.0
-load("//tools/go_stateify:defs.bzl", "go_library", "go_test")
+load("//tools/go_stateify:defs.bzl", "go_library", "go_stateify", "go_test")
+
+go_stateify(
+ name = "seqfile_state",
+ srcs = [
+ "seqfile.go",
+ ],
+ out = "seqfile_state.go",
+ package = "seqfile",
+)
go_library(
name = "seqfile",
- srcs = ["seqfile.go"],
+ srcs = [
+ "seqfile.go",
+ "seqfile_state.go",
+ ],
importpath = "gvisor.googlesource.com/gvisor/pkg/sentry/fs/proc/seqfile",
visibility = ["//pkg/sentry:internal"],
deps = [
@@ -14,16 +26,26 @@ go_library(
"//pkg/sentry/fs/ramfs",
"//pkg/sentry/kernel/time",
"//pkg/sentry/usermem",
+ "//pkg/state",
],
)
+go_stateify(
+ name = "seqfile_test_state",
+ srcs = ["seqfile_test.go"],
+ out = "seqfile_test_state.go",
+ package = "seqfile",
+)
+
go_test(
name = "seqfile_test",
size = "small",
- srcs = ["seqfile_test.go"],
+ srcs = [
+ "seqfile_test.go",
+ "seqfile_test_state.go",
+ ],
embed = [":seqfile"],
deps = [
- "//pkg/sentry/context",
"//pkg/sentry/context/contexttest",
"//pkg/sentry/fs",
"//pkg/sentry/fs/ramfs/test",
diff --git a/pkg/sentry/fs/proc/seqfile/seqfile.go b/pkg/sentry/fs/proc/seqfile/seqfile.go
index 51cae5e37..c08565f8a 100644
--- a/pkg/sentry/fs/proc/seqfile/seqfile.go
+++ b/pkg/sentry/fs/proc/seqfile/seqfile.go
@@ -30,8 +30,6 @@ import (
type SeqHandle interface{}
// SeqData holds the data for one unit in the file.
-//
-// +stateify savable
type SeqData struct {
// The data to be returned to the user.
Buf []byte
@@ -84,8 +82,6 @@ func (s *SeqGenerationCounter) IsCurrent(generation int64) bool {
}
// SeqFile is used to provide dynamic files that can be ordered by record.
-//
-// +stateify savable
type SeqFile struct {
ramfs.Entry
diff --git a/pkg/sentry/fs/proc/stat.go b/pkg/sentry/fs/proc/stat.go
index bf7650211..284f3e52b 100644
--- a/pkg/sentry/fs/proc/stat.go
+++ b/pkg/sentry/fs/proc/stat.go
@@ -25,8 +25,6 @@ import (
)
// statData backs /proc/stat.
-//
-// +stateify savable
type statData struct {
// k is the owning Kernel.
k *kernel.Kernel
diff --git a/pkg/sentry/fs/proc/sys.go b/pkg/sentry/fs/proc/sys.go
index a2d36ca23..aab891c53 100644
--- a/pkg/sentry/fs/proc/sys.go
+++ b/pkg/sentry/fs/proc/sys.go
@@ -28,8 +28,6 @@ import (
)
// hostname is a file containing the system hostname.
-//
-// +stateify savable
type hostname struct {
ramfs.Entry
}
@@ -54,8 +52,6 @@ func (p *proc) newHostname(ctx context.Context, msrc *fs.MountSource) *fs.Inode
}
// mmapMinAddrData backs /proc/sys/vm/mmap_min_addr.
-//
-// +stateify savable
type mmapMinAddrData struct {
k *kernel.Kernel
}
@@ -78,7 +74,6 @@ func (d *mmapMinAddrData) ReadSeqFileData(ctx context.Context, h seqfile.SeqHand
}, 0
}
-// +stateify savable
type overcommitMemory struct{}
func (*overcommitMemory) NeedsUpdate(generation int64) bool {
diff --git a/pkg/sentry/fs/proc/sys_net.go b/pkg/sentry/fs/proc/sys_net.go
index beb25be20..f3a5043f8 100644
--- a/pkg/sentry/fs/proc/sys_net.go
+++ b/pkg/sentry/fs/proc/sys_net.go
@@ -33,7 +33,6 @@ const (
tcpWMem
)
-// +stateify savable
type tcpMem struct {
ramfs.Entry
s inet.Stack
@@ -101,7 +100,6 @@ func (m *tcpMem) DeprecatedPwritev(ctx context.Context, src usermem.IOSequence,
return n, cperr
}
-// +stateify savable
type tcpSack struct {
ramfs.Entry
s inet.Stack
diff --git a/pkg/sentry/fs/proc/task.go b/pkg/sentry/fs/proc/task.go
index 748ca4320..efc635946 100644
--- a/pkg/sentry/fs/proc/task.go
+++ b/pkg/sentry/fs/proc/task.go
@@ -52,8 +52,6 @@ func getTaskMM(t *kernel.Task) (*mm.MemoryManager, error) {
}
// taskDir represents a task-level directory.
-//
-// +stateify savable
type taskDir struct {
ramfs.Dir
@@ -94,8 +92,6 @@ func newTaskDir(t *kernel.Task, msrc *fs.MountSource, pidns *kernel.PIDNamespace
}
// subtasks represents a /proc/TID/task directory.
-//
-// +stateify savable
type subtasks struct {
ramfs.Dir
@@ -171,8 +167,6 @@ func (s *subtasks) DeprecatedReaddir(ctx context.Context, dirCtx *fs.DirCtx, off
}
// exe is an fs.InodeOperations symlink for the /proc/PID/exe file.
-//
-// +stateify savable
type exe struct {
ramfs.Symlink
@@ -232,8 +226,6 @@ func (e *exe) Readlink(ctx context.Context, inode *fs.Inode) (string, error) {
// namespaceFile represents a file in the namespacefs, such as the files in
// /proc/<pid>/ns.
-//
-// +stateify savable
type namespaceFile struct {
ramfs.Symlink
@@ -282,8 +274,6 @@ func newNamespaceDir(t *kernel.Task, msrc *fs.MountSource) *fs.Inode {
}
// mapsData implements seqfile.SeqSource for /proc/[pid]/maps.
-//
-// +stateify savable
type mapsData struct {
t *kernel.Task
}
@@ -321,7 +311,6 @@ func (md *mapsData) ReadSeqFileData(ctx context.Context, h seqfile.SeqHandle) ([
return []seqfile.SeqData{}, 0
}
-// +stateify savable
type taskStatData struct {
t *kernel.Task
@@ -402,8 +391,6 @@ func (s *taskStatData) ReadSeqFileData(ctx context.Context, h seqfile.SeqHandle)
}
// statmData implements seqfile.SeqSource for /proc/[pid]/statm.
-//
-// +stateify savable
type statmData struct {
t *kernel.Task
}
@@ -438,8 +425,6 @@ func (s *statmData) ReadSeqFileData(ctx context.Context, h seqfile.SeqHandle) ([
}
// statusData implements seqfile.SeqSource for /proc/[pid]/status.
-//
-// +stateify savable
type statusData struct {
t *kernel.Task
pidns *kernel.PIDNamespace
@@ -505,7 +490,6 @@ type ioUsage interface {
IOUsage() *usage.IO
}
-// +stateify savable
type ioData struct {
ioUsage
}
@@ -546,8 +530,6 @@ func (i *ioData) ReadSeqFileData(ctx context.Context, h seqfile.SeqHandle) ([]se
// On Linux, /proc/[pid]/comm is writable, and writing to the comm file changes
// the thread name. We don't implement this yet as there are no known users of
// this feature.
-//
-// +stateify savable
type comm struct {
ramfs.Entry
@@ -577,8 +559,6 @@ func (c *comm) DeprecatedPreadv(ctx context.Context, dst usermem.IOSequence, off
}
// auxvec is a file containing the auxiliary vector for a task.
-//
-// +stateify savable
type auxvec struct {
ramfs.Entry
diff --git a/pkg/sentry/fs/proc/uid_gid_map.go b/pkg/sentry/fs/proc/uid_gid_map.go
index 9811d9c9d..85acb5163 100644
--- a/pkg/sentry/fs/proc/uid_gid_map.go
+++ b/pkg/sentry/fs/proc/uid_gid_map.go
@@ -29,8 +29,6 @@ import (
// An idMapSeqSource is a seqfile.SeqSource that returns UID or GID mappings
// from a task's user namespace.
-//
-// +stateify savable
type idMapSeqSource struct {
t *kernel.Task
gids bool
@@ -72,7 +70,6 @@ type idMapSeqHandle struct {
value int
}
-// +stateify savable
type idMapSeqFile struct {
seqfile.SeqFile
}
diff --git a/pkg/sentry/fs/proc/uptime.go b/pkg/sentry/fs/proc/uptime.go
index f3a9b81df..4679d5821 100644
--- a/pkg/sentry/fs/proc/uptime.go
+++ b/pkg/sentry/fs/proc/uptime.go
@@ -27,8 +27,6 @@ import (
)
// uptime is a file containing the system uptime.
-//
-// +stateify savable
type uptime struct {
ramfs.Entry
diff --git a/pkg/sentry/fs/proc/version.go b/pkg/sentry/fs/proc/version.go
index 00f6a2afd..c0f2e87e3 100644
--- a/pkg/sentry/fs/proc/version.go
+++ b/pkg/sentry/fs/proc/version.go
@@ -23,8 +23,6 @@ import (
)
// versionData backs /proc/version.
-//
-// +stateify savable
type versionData struct {
// k is the owning Kernel.
k *kernel.Kernel