summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/proc/exec_args.go
diff options
context:
space:
mode:
authorJamie Liu <jamieliu@google.com>2020-11-12 18:20:30 -0800
committergVisor bot <gvisor-bot@google.com>2020-11-12 18:22:40 -0800
commit62db1fad2cb7d2249720e157aa79c84b7531a2e9 (patch)
tree2485dc460f965096836f9ccfe128e81f5c82f576 /pkg/sentry/fs/proc/exec_args.go
parentf01f623879e87412e4d2340d37ff4d0fccdb6c2b (diff)
Fix misuses of kernel.Task as context.Context.
kernel.Task can only be used as context.Context by that Task's task goroutine. This is violated in at least two places: - In any case where one thread accesses the /proc/[tid] of any other thread, passing the kernel.Task for [tid] as the context.Context is incorrect. - Task.rebuildTraceContext() may be called by Kernel.RebuildTraceContexts() outside the scope of any task goroutine. Fix these (as well as a data race on Task.traceContext discovered during the course of finding the latter). PiperOrigin-RevId: 342174404
Diffstat (limited to 'pkg/sentry/fs/proc/exec_args.go')
-rw-r--r--pkg/sentry/fs/proc/exec_args.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/pkg/sentry/fs/proc/exec_args.go b/pkg/sentry/fs/proc/exec_args.go
index 8fe626e1c..e6171dd1d 100644
--- a/pkg/sentry/fs/proc/exec_args.go
+++ b/pkg/sentry/fs/proc/exec_args.go
@@ -57,16 +57,16 @@ type execArgInode struct {
var _ fs.InodeOperations = (*execArgInode)(nil)
// newExecArgFile creates a file containing the exec args of the given type.
-func newExecArgInode(t *kernel.Task, msrc *fs.MountSource, arg execArgType) *fs.Inode {
+func newExecArgInode(ctx context.Context, t *kernel.Task, msrc *fs.MountSource, arg execArgType) *fs.Inode {
if arg != cmdlineExecArg && arg != environExecArg {
panic(fmt.Sprintf("unknown exec arg type %v", arg))
}
f := &execArgInode{
- SimpleFileInode: *fsutil.NewSimpleFileInode(t, fs.RootOwner, fs.FilePermsFromMode(0444), linux.PROC_SUPER_MAGIC),
+ SimpleFileInode: *fsutil.NewSimpleFileInode(ctx, fs.RootOwner, fs.FilePermsFromMode(0444), linux.PROC_SUPER_MAGIC),
arg: arg,
t: t,
}
- return newProcInode(t, f, msrc, fs.SpecialFile, t)
+ return newProcInode(ctx, f, msrc, fs.SpecialFile, t)
}
// GetFile implements fs.InodeOperations.GetFile.