summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/sentry')
-rw-r--r--pkg/sentry/strace/BUILD1
-rw-r--r--pkg/sentry/strace/linux64.go152
-rw-r--r--pkg/sentry/strace/strace.go32
-rw-r--r--pkg/sentry/strace/syscalls.go3
4 files changed, 112 insertions, 76 deletions
diff --git a/pkg/sentry/strace/BUILD b/pkg/sentry/strace/BUILD
index 73f1e9814..bcd94b42e 100644
--- a/pkg/sentry/strace/BUILD
+++ b/pkg/sentry/strace/BUILD
@@ -29,6 +29,7 @@ go_library(
"//pkg/seccomp",
"//pkg/sentry/arch",
"//pkg/sentry/kernel",
+ "//pkg/sentry/kernel/kdefs",
"//pkg/sentry/socket/control",
"//pkg/sentry/socket/epsocket",
"//pkg/sentry/socket/netlink",
diff --git a/pkg/sentry/strace/linux64.go b/pkg/sentry/strace/linux64.go
index ca695e80f..22b76449c 100644
--- a/pkg/sentry/strace/linux64.go
+++ b/pkg/sentry/strace/linux64.go
@@ -17,27 +17,27 @@ package strace
// linuxAMD64 provides a mapping of the Linux amd64 syscalls and their argument
// types for display / formatting.
var linuxAMD64 = SyscallMap{
- 0: makeSyscallInfo("read", Hex, ReadBuffer, Hex),
- 1: makeSyscallInfo("write", Hex, WriteBuffer, Hex),
+ 0: makeSyscallInfo("read", FD, ReadBuffer, Hex),
+ 1: makeSyscallInfo("write", FD, WriteBuffer, Hex),
2: makeSyscallInfo("open", Path, OpenFlags, Mode),
- 3: makeSyscallInfo("close", Hex),
+ 3: makeSyscallInfo("close", FD),
4: makeSyscallInfo("stat", Path, Stat),
- 5: makeSyscallInfo("fstat", Hex, Stat),
+ 5: makeSyscallInfo("fstat", FD, Stat),
6: makeSyscallInfo("lstat", Path, Stat),
7: makeSyscallInfo("poll", Hex, Hex, Hex),
8: makeSyscallInfo("lseek", Hex, Hex, Hex),
- 9: makeSyscallInfo("mmap", Hex, Hex, Hex, Hex, Hex, Hex),
+ 9: makeSyscallInfo("mmap", Hex, Hex, Hex, Hex, FD, Hex),
10: makeSyscallInfo("mprotect", Hex, Hex, Hex),
11: makeSyscallInfo("munmap", Hex, Hex),
12: makeSyscallInfo("brk", Hex),
13: makeSyscallInfo("rt_sigaction", Signal, SigAction, PostSigAction),
14: makeSyscallInfo("rt_sigprocmask", SignalMaskAction, SigSet, PostSigSet, Hex),
15: makeSyscallInfo("rt_sigreturn"),
- 16: makeSyscallInfo("ioctl", Hex, Hex, Hex),
- 17: makeSyscallInfo("pread64", Hex, ReadBuffer, Hex, Hex),
- 18: makeSyscallInfo("pwrite64", Hex, WriteBuffer, Hex, Hex),
- 19: makeSyscallInfo("readv", Hex, ReadIOVec, Hex),
- 20: makeSyscallInfo("writev", Hex, WriteIOVec, Hex),
+ 16: makeSyscallInfo("ioctl", FD, Hex, Hex),
+ 17: makeSyscallInfo("pread64", FD, ReadBuffer, Hex, Hex),
+ 18: makeSyscallInfo("pwrite64", FD, WriteBuffer, Hex, Hex),
+ 19: makeSyscallInfo("readv", FD, ReadIOVec, Hex),
+ 20: makeSyscallInfo("writev", FD, WriteIOVec, Hex),
21: makeSyscallInfo("access", Path, Oct),
22: makeSyscallInfo("pipe", PipeFDs),
23: makeSyscallInfo("select", Hex, Hex, Hex, Hex, Timeval),
@@ -49,30 +49,30 @@ var linuxAMD64 = SyscallMap{
29: makeSyscallInfo("shmget", Hex, Hex, Hex),
30: makeSyscallInfo("shmat", Hex, Hex, Hex),
31: makeSyscallInfo("shmctl", Hex, Hex, Hex),
- 32: makeSyscallInfo("dup", Hex),
- 33: makeSyscallInfo("dup2", Hex, Hex),
+ 32: makeSyscallInfo("dup", FD),
+ 33: makeSyscallInfo("dup2", FD, FD),
34: makeSyscallInfo("pause"),
35: makeSyscallInfo("nanosleep", Timespec, PostTimespec),
36: makeSyscallInfo("getitimer", ItimerType, PostItimerVal),
37: makeSyscallInfo("alarm", Hex),
38: makeSyscallInfo("setitimer", ItimerType, ItimerVal, PostItimerVal),
39: makeSyscallInfo("getpid"),
- 40: makeSyscallInfo("sendfile", Hex, Hex, Hex, Hex),
+ 40: makeSyscallInfo("sendfile", FD, FD, Hex, Hex),
41: makeSyscallInfo("socket", SockFamily, SockType, SockProtocol),
- 42: makeSyscallInfo("connect", Hex, SockAddr, Hex),
- 43: makeSyscallInfo("accept", Hex, PostSockAddr, SockLen),
- 44: makeSyscallInfo("sendto", Hex, Hex, Hex, Hex, SockAddr, Hex),
- 45: makeSyscallInfo("recvfrom", Hex, Hex, Hex, Hex, PostSockAddr, SockLen),
- 46: makeSyscallInfo("sendmsg", Hex, SendMsgHdr, Hex),
- 47: makeSyscallInfo("recvmsg", Hex, RecvMsgHdr, Hex),
- 48: makeSyscallInfo("shutdown", Hex, Hex),
- 49: makeSyscallInfo("bind", Hex, SockAddr, Hex),
- 50: makeSyscallInfo("listen", Hex, Hex),
- 51: makeSyscallInfo("getsockname", Hex, PostSockAddr, SockLen),
- 52: makeSyscallInfo("getpeername", Hex, PostSockAddr, SockLen),
+ 42: makeSyscallInfo("connect", FD, SockAddr, Hex),
+ 43: makeSyscallInfo("accept", FD, PostSockAddr, SockLen),
+ 44: makeSyscallInfo("sendto", FD, Hex, Hex, Hex, SockAddr, Hex),
+ 45: makeSyscallInfo("recvfrom", FD, Hex, Hex, Hex, PostSockAddr, SockLen),
+ 46: makeSyscallInfo("sendmsg", FD, SendMsgHdr, Hex),
+ 47: makeSyscallInfo("recvmsg", FD, RecvMsgHdr, Hex),
+ 48: makeSyscallInfo("shutdown", FD, Hex),
+ 49: makeSyscallInfo("bind", FD, SockAddr, Hex),
+ 50: makeSyscallInfo("listen", FD, Hex),
+ 51: makeSyscallInfo("getsockname", FD, PostSockAddr, SockLen),
+ 52: makeSyscallInfo("getpeername", FD, PostSockAddr, SockLen),
53: makeSyscallInfo("socketpair", SockFamily, SockType, SockProtocol, Hex),
- 54: makeSyscallInfo("setsockopt", Hex, Hex, Hex, Hex, Hex),
- 55: makeSyscallInfo("getsockopt", Hex, Hex, Hex, Hex, Hex),
+ 54: makeSyscallInfo("setsockopt", FD, Hex, Hex, Hex, Hex),
+ 55: makeSyscallInfo("getsockopt", FD, Hex, Hex, Hex, Hex),
56: makeSyscallInfo("clone", CloneFlags, Hex, Hex, Hex, Hex),
57: makeSyscallInfo("fork"),
58: makeSyscallInfo("vfork"),
@@ -89,16 +89,16 @@ var linuxAMD64 = SyscallMap{
69: makeSyscallInfo("msgsnd", Hex, Hex, Hex, Hex),
70: makeSyscallInfo("msgrcv", Hex, Hex, Hex, Hex, Hex),
71: makeSyscallInfo("msgctl", Hex, Hex, Hex),
- 72: makeSyscallInfo("fcntl", Hex, Hex, Hex),
- 73: makeSyscallInfo("flock", Hex, Hex),
- 74: makeSyscallInfo("fsync", Hex),
- 75: makeSyscallInfo("fdatasync", Hex),
+ 72: makeSyscallInfo("fcntl", FD, Hex, Hex),
+ 73: makeSyscallInfo("flock", FD, Hex),
+ 74: makeSyscallInfo("fsync", FD),
+ 75: makeSyscallInfo("fdatasync", FD),
76: makeSyscallInfo("truncate", Path, Hex),
- 77: makeSyscallInfo("ftruncate", Hex, Hex),
- 78: makeSyscallInfo("getdents", Hex, Hex, Hex),
+ 77: makeSyscallInfo("ftruncate", FD, Hex),
+ 78: makeSyscallInfo("getdents", FD, Hex, Hex),
79: makeSyscallInfo("getcwd", PostPath, Hex),
80: makeSyscallInfo("chdir", Path),
- 81: makeSyscallInfo("fchdir", Hex),
+ 81: makeSyscallInfo("fchdir", FD),
82: makeSyscallInfo("rename", Path, Path),
83: makeSyscallInfo("mkdir", Path, Oct),
84: makeSyscallInfo("rmdir", Path),
@@ -108,10 +108,10 @@ var linuxAMD64 = SyscallMap{
88: makeSyscallInfo("symlink", Path, Path),
89: makeSyscallInfo("readlink", Path, ReadBuffer, Hex),
90: makeSyscallInfo("chmod", Path, Mode),
- 91: makeSyscallInfo("fchmod", Hex, Mode),
+ 91: makeSyscallInfo("fchmod", FD, Mode),
92: makeSyscallInfo("chown", Path, Hex, Hex),
- 93: makeSyscallInfo("fchown", Hex, Hex, Hex),
- 94: makeSyscallInfo("lchown", Hex, Hex, Hex),
+ 93: makeSyscallInfo("fchown", FD, Hex, Hex),
+ 94: makeSyscallInfo("lchown", Path, Hex, Hex),
95: makeSyscallInfo("umask", Hex),
96: makeSyscallInfo("gettimeofday", Timeval, Hex),
97: makeSyscallInfo("getrlimit", Hex, Hex),
@@ -155,7 +155,7 @@ var linuxAMD64 = SyscallMap{
135: makeSyscallInfo("personality", Hex),
136: makeSyscallInfo("ustat", Hex, Hex),
137: makeSyscallInfo("statfs", Path, Hex),
- 138: makeSyscallInfo("fstatfs", Hex, Hex),
+ 138: makeSyscallInfo("fstatfs", FD, Hex),
139: makeSyscallInfo("sysfs", Hex, Hex, Hex),
140: makeSyscallInfo("getpriority", Hex, Hex),
141: makeSyscallInfo("setpriority", Hex, Hex, Hex),
@@ -172,7 +172,7 @@ var linuxAMD64 = SyscallMap{
152: makeSyscallInfo("munlockall"),
153: makeSyscallInfo("vhangup"),
154: makeSyscallInfo("modify_ldt", Hex, Hex, Hex),
- 155: makeSyscallInfo("pivot_root", Hex, Hex),
+ 155: makeSyscallInfo("pivot_root", Path, Path),
156: makeSyscallInfo("_sysctl", Hex),
157: makeSyscallInfo("prctl", Hex, Hex, Hex, Hex, Hex),
158: makeSyscallInfo("arch_prctl", Hex, Hex),
@@ -207,16 +207,16 @@ var linuxAMD64 = SyscallMap{
187: makeSyscallInfo("readahead", Hex, Hex, Hex),
188: makeSyscallInfo("setxattr", Path, Path, Hex, Hex, Hex),
189: makeSyscallInfo("lsetxattr", Path, Path, Hex, Hex, Hex),
- 190: makeSyscallInfo("fsetxattr", Hex, Path, Hex, Hex, Hex),
+ 190: makeSyscallInfo("fsetxattr", FD, Path, Hex, Hex, Hex),
191: makeSyscallInfo("getxattr", Path, Path, Hex, Hex),
192: makeSyscallInfo("lgetxattr", Path, Path, Hex, Hex),
- 193: makeSyscallInfo("fgetxattr", Hex, Path, Hex, Hex),
+ 193: makeSyscallInfo("fgetxattr", FD, Path, Hex, Hex),
194: makeSyscallInfo("listxattr", Path, Path, Hex),
195: makeSyscallInfo("llistxattr", Path, Path, Hex),
- 196: makeSyscallInfo("flistxattr", Hex, Path, Hex),
+ 196: makeSyscallInfo("flistxattr", FD, Path, Hex),
197: makeSyscallInfo("removexattr", Path, Path),
198: makeSyscallInfo("lremovexattr", Path, Path),
- 199: makeSyscallInfo("fremovexattr", Hex, Path),
+ 199: makeSyscallInfo("fremovexattr", FD, Path),
200: makeSyscallInfo("tkill", Hex, Signal),
201: makeSyscallInfo("time", Hex),
202: makeSyscallInfo("futex", Hex, FutexOp, Hex, Timespec, Hex, Hex),
@@ -234,11 +234,11 @@ var linuxAMD64 = SyscallMap{
// 214: epoll_ctl_old (not implemented in the Linux kernel)
// 215: epoll_wait_old (not implemented in the Linux kernel)
216: makeSyscallInfo("remap_file_pages", Hex, Hex, Hex, Hex, Hex),
- 217: makeSyscallInfo("getdents64", Hex, Hex, Hex),
+ 217: makeSyscallInfo("getdents64", FD, Hex, Hex),
218: makeSyscallInfo("set_tid_address", Hex),
219: makeSyscallInfo("restart_syscall"),
220: makeSyscallInfo("semtimedop", Hex, Hex, Hex, Hex),
- 221: makeSyscallInfo("fadvise64", Hex, Hex, Hex, Hex),
+ 221: makeSyscallInfo("fadvise64", FD, Hex, Hex, Hex),
222: makeSyscallInfo("timer_create", Hex, Hex, Hex),
223: makeSyscallInfo("timer_settime", Hex, Hex, ItimerSpec, PostItimerSpec),
224: makeSyscallInfo("timer_gettime", Hex, PostItimerSpec),
@@ -250,7 +250,7 @@ var linuxAMD64 = SyscallMap{
230: makeSyscallInfo("clock_nanosleep", Hex, Hex, Timespec, PostTimespec),
231: makeSyscallInfo("exit_group", Hex),
232: makeSyscallInfo("epoll_wait", Hex, Hex, Hex, Hex),
- 233: makeSyscallInfo("epoll_ctl", Hex, Hex, Hex, Hex),
+ 233: makeSyscallInfo("epoll_ctl", Hex, Hex, FD, Hex),
234: makeSyscallInfo("tgkill", Hex, Hex, Signal),
235: makeSyscallInfo("utimes", Path, Timeval),
// 236: vserver (not implemented in the Linux kernel)
@@ -274,58 +274,58 @@ var linuxAMD64 = SyscallMap{
254: makeSyscallInfo("inotify_add_watch", Hex, Path, Hex),
255: makeSyscallInfo("inotify_rm_watch", Hex, Hex),
256: makeSyscallInfo("migrate_pages", Hex, Hex, Hex, Hex),
- 257: makeSyscallInfo("openat", Hex, Path, OpenFlags, Mode),
- 258: makeSyscallInfo("mkdirat", Hex, Path, Hex),
- 259: makeSyscallInfo("mknodat", Hex, Path, Mode, Hex),
- 260: makeSyscallInfo("fchownat", Hex, Path, Hex, Hex, Hex),
- 261: makeSyscallInfo("futimesat", Hex, Path, Hex),
- 262: makeSyscallInfo("newfstatat", Hex, Path, Stat, Hex),
- 263: makeSyscallInfo("unlinkat", Hex, Path, Hex),
- 264: makeSyscallInfo("renameat", Hex, Path, Hex, Path),
- 265: makeSyscallInfo("linkat", Hex, Path, Hex, Path, Hex),
+ 257: makeSyscallInfo("openat", FD, Path, OpenFlags, Mode),
+ 258: makeSyscallInfo("mkdirat", FD, Path, Hex),
+ 259: makeSyscallInfo("mknodat", FD, Path, Mode, Hex),
+ 260: makeSyscallInfo("fchownat", FD, Path, Hex, Hex, Hex),
+ 261: makeSyscallInfo("futimesat", FD, Path, Hex),
+ 262: makeSyscallInfo("newfstatat", FD, Path, Stat, Hex),
+ 263: makeSyscallInfo("unlinkat", FD, Path, Hex),
+ 264: makeSyscallInfo("renameat", FD, Path, Hex, Path),
+ 265: makeSyscallInfo("linkat", FD, Path, Hex, Path, Hex),
266: makeSyscallInfo("symlinkat", Path, Hex, Path),
- 267: makeSyscallInfo("readlinkat", Hex, Path, ReadBuffer, Hex),
- 268: makeSyscallInfo("fchmodat", Hex, Path, Mode),
- 269: makeSyscallInfo("faccessat", Hex, Path, Oct, Hex),
+ 267: makeSyscallInfo("readlinkat", FD, Path, ReadBuffer, Hex),
+ 268: makeSyscallInfo("fchmodat", FD, Path, Mode),
+ 269: makeSyscallInfo("faccessat", FD, Path, Oct, Hex),
270: makeSyscallInfo("pselect6", Hex, Hex, Hex, Hex, Hex, Hex),
271: makeSyscallInfo("ppoll", Hex, Hex, Timespec, SigSet, Hex),
272: makeSyscallInfo("unshare", CloneFlags),
273: makeSyscallInfo("set_robust_list", Hex, Hex),
274: makeSyscallInfo("get_robust_list", Hex, Hex, Hex),
- 275: makeSyscallInfo("splice", Hex, Hex, Hex, Hex, Hex, Hex),
- 276: makeSyscallInfo("tee", Hex, Hex, Hex, Hex),
- 277: makeSyscallInfo("sync_file_range", Hex, Hex, Hex, Hex),
- 278: makeSyscallInfo("vmsplice", Hex, Hex, Hex, Hex),
+ 275: makeSyscallInfo("splice", FD, Hex, FD, Hex, Hex, Hex),
+ 276: makeSyscallInfo("tee", FD, FD, Hex, Hex),
+ 277: makeSyscallInfo("sync_file_range", FD, Hex, Hex, Hex),
+ 278: makeSyscallInfo("vmsplice", FD, Hex, Hex, Hex),
279: makeSyscallInfo("move_pages", Hex, Hex, Hex, Hex, Hex, Hex),
- 280: makeSyscallInfo("utimensat", Hex, Path, UTimeTimespec, Hex),
+ 280: makeSyscallInfo("utimensat", FD, Path, UTimeTimespec, Hex),
281: makeSyscallInfo("epoll_pwait", Hex, Hex, Hex, Hex, SigSet, Hex),
282: makeSyscallInfo("signalfd", Hex, Hex, Hex),
283: makeSyscallInfo("timerfd_create", Hex, Hex),
284: makeSyscallInfo("eventfd", Hex),
- 285: makeSyscallInfo("fallocate", Hex, Hex, Hex, Hex),
- 286: makeSyscallInfo("timerfd_settime", Hex, Hex, ItimerSpec, PostItimerSpec),
- 287: makeSyscallInfo("timerfd_gettime", Hex, PostItimerSpec),
- 288: makeSyscallInfo("accept4", Hex, PostSockAddr, SockLen, SockFlags),
+ 285: makeSyscallInfo("fallocate", FD, Hex, Hex, Hex),
+ 286: makeSyscallInfo("timerfd_settime", FD, Hex, ItimerSpec, PostItimerSpec),
+ 287: makeSyscallInfo("timerfd_gettime", FD, PostItimerSpec),
+ 288: makeSyscallInfo("accept4", FD, PostSockAddr, SockLen, SockFlags),
289: makeSyscallInfo("signalfd4", Hex, Hex, Hex, Hex),
290: makeSyscallInfo("eventfd2", Hex, Hex),
291: makeSyscallInfo("epoll_create1", Hex),
- 292: makeSyscallInfo("dup3", Hex, Hex, Hex),
+ 292: makeSyscallInfo("dup3", FD, FD, Hex),
293: makeSyscallInfo("pipe2", PipeFDs, Hex),
294: makeSyscallInfo("inotify_init1", Hex),
- 295: makeSyscallInfo("preadv", Hex, ReadIOVec, Hex, Hex),
- 296: makeSyscallInfo("pwritev", Hex, WriteIOVec, Hex, Hex),
+ 295: makeSyscallInfo("preadv", FD, ReadIOVec, Hex, Hex),
+ 296: makeSyscallInfo("pwritev", FD, WriteIOVec, Hex, Hex),
297: makeSyscallInfo("rt_tgsigqueueinfo", Hex, Hex, Signal, Hex),
298: makeSyscallInfo("perf_event_open", Hex, Hex, Hex, Hex, Hex),
- 299: makeSyscallInfo("recvmmsg", Hex, Hex, Hex, Hex, Hex),
+ 299: makeSyscallInfo("recvmmsg", FD, Hex, Hex, Hex, Hex),
300: makeSyscallInfo("fanotify_init", Hex, Hex),
301: makeSyscallInfo("fanotify_mark", Hex, Hex, Hex, Hex, Hex),
302: makeSyscallInfo("prlimit64", Hex, Hex, Hex, Hex),
- 303: makeSyscallInfo("name_to_handle_at", Hex, Hex, Hex, Hex, Hex),
- 304: makeSyscallInfo("open_by_handle_at", Hex, Hex, Hex),
+ 303: makeSyscallInfo("name_to_handle_at", FD, Hex, Hex, Hex, Hex),
+ 304: makeSyscallInfo("open_by_handle_at", FD, Hex, Hex),
305: makeSyscallInfo("clock_adjtime", Hex, Hex),
- 306: makeSyscallInfo("syncfs", Hex),
- 307: makeSyscallInfo("sendmmsg", Hex, Hex, Hex, Hex),
- 308: makeSyscallInfo("setns", Hex, Hex),
+ 306: makeSyscallInfo("syncfs", FD),
+ 307: makeSyscallInfo("sendmmsg", FD, Hex, Hex, Hex),
+ 308: makeSyscallInfo("setns", FD, Hex),
309: makeSyscallInfo("getcpu", Hex, Hex, Hex),
310: makeSyscallInfo("process_vm_readv", Hex, ReadIOVec, Hex, IOVec, Hex, Hex),
311: makeSyscallInfo("process_vm_writev", Hex, IOVec, Hex, WriteIOVec, Hex, Hex),
@@ -333,6 +333,6 @@ var linuxAMD64 = SyscallMap{
313: makeSyscallInfo("finit_module", Hex, Hex, Hex),
314: makeSyscallInfo("sched_setattr", Hex, Hex, Hex),
315: makeSyscallInfo("sched_getattr", Hex, Hex, Hex),
- 316: makeSyscallInfo("renameat2", Hex, Path, Hex, Path, Hex),
+ 316: makeSyscallInfo("renameat2", FD, Path, Hex, Path, Hex),
317: makeSyscallInfo("seccomp", Hex, Hex, Hex),
}
diff --git a/pkg/sentry/strace/strace.go b/pkg/sentry/strace/strace.go
index a7e9df268..398035b65 100644
--- a/pkg/sentry/strace/strace.go
+++ b/pkg/sentry/strace/strace.go
@@ -31,6 +31,7 @@ import (
"gvisor.googlesource.com/gvisor/pkg/seccomp"
"gvisor.googlesource.com/gvisor/pkg/sentry/arch"
"gvisor.googlesource.com/gvisor/pkg/sentry/kernel"
+ "gvisor.googlesource.com/gvisor/pkg/sentry/kernel/kdefs"
pb "gvisor.googlesource.com/gvisor/pkg/sentry/strace/strace_go_proto"
slinux "gvisor.googlesource.com/gvisor/pkg/sentry/syscalls/linux"
"gvisor.googlesource.com/gvisor/pkg/sentry/usermem"
@@ -132,6 +133,35 @@ func path(t *kernel.Task, addr usermem.Addr) string {
return fmt.Sprintf("%#x %s", addr, path)
}
+func fd(t *kernel.Task, fd kdefs.FD) string {
+ root := t.FSContext().RootDirectory()
+ if root != nil {
+ defer root.DecRef()
+ }
+
+ if fd == linux.AT_FDCWD {
+ wd := t.FSContext().WorkingDirectory()
+ var name string
+ if wd != nil {
+ defer wd.DecRef()
+ name, _ = wd.FullName(root)
+ } else {
+ name = "(unknown cwd)"
+ }
+ return fmt.Sprintf("AT_FDCWD %s", name)
+ }
+
+ file := t.FDMap().GetFile(fd)
+ if file == nil {
+ // Cast FD to uint64 to avoid printing negative hex.
+ return fmt.Sprintf("%#x (bad FD)", uint64(fd))
+ }
+ defer file.DecRef()
+
+ name, _ := file.Dirent.FullName(root)
+ return fmt.Sprintf("%#x %s", fd, name)
+}
+
func fdpair(t *kernel.Task, addr usermem.Addr) string {
var fds [2]int32
_, err := t.CopyIn(addr, &fds)
@@ -344,6 +374,8 @@ func (i *SyscallInfo) pre(t *kernel.Task, args arch.SyscallArguments, maximumBlo
break
}
switch i.format[arg] {
+ case FD:
+ output = append(output, fd(t, kdefs.FD(args[arg].Int())))
case WriteBuffer:
output = append(output, dump(t, args[arg].Pointer(), args[arg+1].SizeT(), maximumBlobSize))
case WriteIOVec:
diff --git a/pkg/sentry/strace/syscalls.go b/pkg/sentry/strace/syscalls.go
index b2715856e..1f255c717 100644
--- a/pkg/sentry/strace/syscalls.go
+++ b/pkg/sentry/strace/syscalls.go
@@ -35,6 +35,9 @@ const (
// Oct is just an octal number.
Oct
+ // FD is a file descriptor.
+ FD
+
// ReadBuffer is a buffer for a read-style call. The syscall return
// value is used for the length.
//