summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--pkg/abi/linux/BUILD1
-rw-r--r--pkg/abi/linux/timer.go23
-rw-r--r--pkg/sentry/strace/linux64.go4
-rw-r--r--pkg/sentry/strace/strace.go19
-rw-r--r--pkg/sentry/strace/syscalls.go7
-rw-r--r--pkg/sentry/syscalls/linux/sys_timer.go27
6 files changed, 57 insertions, 24 deletions
diff --git a/pkg/abi/linux/BUILD b/pkg/abi/linux/BUILD
index ac4ceefbc..f8f82c0da 100644
--- a/pkg/abi/linux/BUILD
+++ b/pkg/abi/linux/BUILD
@@ -44,6 +44,7 @@ go_library(
"signal.go",
"socket.go",
"time.go",
+ "timer.go",
"tty.go",
"uio.go",
"utsname.go",
diff --git a/pkg/abi/linux/timer.go b/pkg/abi/linux/timer.go
new file mode 100644
index 000000000..6c4675c35
--- /dev/null
+++ b/pkg/abi/linux/timer.go
@@ -0,0 +1,23 @@
+// Copyright 2018 Google Inc.
+//
+// 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 linux
+
+// itimer types for getitimer(2) and setitimer(2), from
+// include/uapi/linux/time.h.
+const (
+ ITIMER_REAL = 0
+ ITIMER_VIRTUAL = 1
+ ITIMER_PROF = 2
+)
diff --git a/pkg/sentry/strace/linux64.go b/pkg/sentry/strace/linux64.go
index 63851246c..1df148e7d 100644
--- a/pkg/sentry/strace/linux64.go
+++ b/pkg/sentry/strace/linux64.go
@@ -53,9 +53,9 @@ var linuxAMD64 = SyscallMap{
33: makeSyscallInfo("dup2", Hex, Hex),
34: makeSyscallInfo("pause"),
35: makeSyscallInfo("nanosleep", Timespec, PostTimespec),
- 36: makeSyscallInfo("getitimer", Hex, PostItimerVal),
+ 36: makeSyscallInfo("getitimer", ItimerType, PostItimerVal),
37: makeSyscallInfo("alarm", Hex),
- 38: makeSyscallInfo("setitimer", Hex, ItimerVal, PostItimerVal),
+ 38: makeSyscallInfo("setitimer", ItimerType, ItimerVal, PostItimerVal),
39: makeSyscallInfo("getpid"),
40: makeSyscallInfo("sendfile", Hex, Hex, Hex, Hex),
41: makeSyscallInfo("socket", SockFamily, SockType, SockProtocol),
diff --git a/pkg/sentry/strace/strace.go b/pkg/sentry/strace/strace.go
index 539e665d2..c99c33c33 100644
--- a/pkg/sentry/strace/strace.go
+++ b/pkg/sentry/strace/strace.go
@@ -24,6 +24,7 @@ import (
"syscall"
"time"
+ "gvisor.googlesource.com/gvisor/pkg/abi"
"gvisor.googlesource.com/gvisor/pkg/abi/linux"
"gvisor.googlesource.com/gvisor/pkg/bits"
"gvisor.googlesource.com/gvisor/pkg/eventchannel"
@@ -46,6 +47,22 @@ var LogMaximumSize uint = DefaultLogMaximumSize
// do anything useful with binary text dump of byte array arguments.
var EventMaximumSize uint
+// ItimerTypes are the possible itimer types.
+var ItimerTypes = abi.ValueSet{
+ {
+ Value: linux.ITIMER_REAL,
+ Name: "ITIMER_REAL",
+ },
+ {
+ Value: linux.ITIMER_VIRTUAL,
+ Name: "ITIMER_VIRTUAL",
+ },
+ {
+ Value: linux.ITIMER_PROF,
+ Name: "ITIMER_PROF",
+ },
+}
+
func iovecs(t *kernel.Task, addr usermem.Addr, iovcnt int, printContent bool, maxBytes uint64) string {
if iovcnt < 0 || iovcnt > linux.UIO_MAXIOV {
return fmt.Sprintf("%#x (error decoding iovecs: invalid iovcnt)", addr)
@@ -322,6 +339,8 @@ func (i *SyscallInfo) pre(t *kernel.Task, args arch.SyscallArguments, maximumBlo
output = append(output, futex(uint64(args[arg].Uint())))
case PtraceRequest:
output = append(output, PtraceRequestSet.Parse(args[arg].Uint64()))
+ case ItimerType:
+ output = append(output, ItimerTypes.Parse(uint64(args[arg].Int())))
case Oct:
output = append(output, "0o"+strconv.FormatUint(args[arg].Uint64(), 8))
case Hex:
diff --git a/pkg/sentry/strace/syscalls.go b/pkg/sentry/strace/syscalls.go
index 770a0d2b9..8be4fa318 100644
--- a/pkg/sentry/strace/syscalls.go
+++ b/pkg/sentry/strace/syscalls.go
@@ -150,6 +150,9 @@ const (
// Utimbuf is a pointer to a struct utimbuf.
Utimbuf
+ // Rusage is a struct rusage, formatted after syscall execution.
+ Rusage
+
// CloneFlags are clone(2) flags.
CloneFlags
@@ -165,8 +168,8 @@ const (
// PtraceRequest is the ptrace(2) request.
PtraceRequest
- // Rusage is a struct rusage, formatted after syscall execution.
- Rusage
+ // ItimerType is an itimer type (ITIMER_REAL, etc).
+ ItimerType
)
// defaultFormat is the syscall argument format to use if the actual format is
diff --git a/pkg/sentry/syscalls/linux/sys_timer.go b/pkg/sentry/syscalls/linux/sys_timer.go
index aaed75c81..a12d12d9d 100644
--- a/pkg/sentry/syscalls/linux/sys_timer.go
+++ b/pkg/sentry/syscalls/linux/sys_timer.go
@@ -25,19 +25,6 @@ import (
"gvisor.googlesource.com/gvisor/pkg/sentry/usermem"
)
-// ItimerType denotes the type of interval timer.
-type ItimerType int
-
-// Interval timer types from <sys/time.h>.
-const (
- // ItimerReal equals to ITIMER_REAL.
- ItimerReal ItimerType = iota
- // ItimerVirtual equals to ITIMER_VIRTUAL.
- ItimerVirtual
- // ItimerProf equals to ITIMER_PROF.
- ItimerProf
-)
-
const nsecPerSec = int64(time.Second)
// copyItimerValIn copies an ItimerVal from the untrusted app range to the
@@ -83,13 +70,13 @@ func copyItimerValOut(t *kernel.Task, addr usermem.Addr, itv *linux.ItimerVal) e
}
}
-func findTimer(t *kernel.Task, w ItimerType) (*ktime.Timer, error) {
- switch w {
- case ItimerReal:
+func findTimer(t *kernel.Task, which int32) (*ktime.Timer, error) {
+ switch which {
+ case linux.ITIMER_REAL:
return t.ThreadGroup().Timer().RealTimer, nil
- case ItimerVirtual:
+ case linux.ITIMER_VIRTUAL:
return t.ThreadGroup().Timer().VirtualTimer, nil
- case ItimerProf:
+ case linux.ITIMER_PROF:
return t.ThreadGroup().Timer().ProfTimer, nil
default:
return nil, syscall.EINVAL
@@ -98,7 +85,7 @@ func findTimer(t *kernel.Task, w ItimerType) (*ktime.Timer, error) {
// Getitimer implements linux syscall getitimer(2).
func Getitimer(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) {
- timerID := ItimerType(args[0].Int())
+ timerID := args[0].Int()
val := args[1].Pointer()
timer, err := findTimer(t, timerID)
@@ -116,7 +103,7 @@ func Getitimer(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.Sys
// Setitimer implements linux syscall setitimer(2).
func Setitimer(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.SyscallControl, error) {
- timerID := ItimerType(args[0].Int())
+ timerID := args[0].Int()
newVal := args[1].Pointer()
oldVal := args[2].Pointer()