summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/devices/tundev
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-08-28 02:30:20 +0000
committergVisor bot <gvisor-bot@google.com>2020-08-28 02:30:20 +0000
commitaed22b4e8aefe49593475db79c1b12d085d839f8 (patch)
tree85799ccbf584a2e7f9f9dc85f03e123517981d06 /pkg/sentry/devices/tundev
parent5df75d5fa6e9ded2ab19b56473f4baebef48edbd (diff)
parent421e35020bbca240d8f1cb5a2a3efd39750c4589 (diff)
Merge release-20200818.0-78-g421e35020 (automated)
Diffstat (limited to 'pkg/sentry/devices/tundev')
-rw-r--r--pkg/sentry/devices/tundev/tundev.go17
1 files changed, 7 insertions, 10 deletions
diff --git a/pkg/sentry/devices/tundev/tundev.go b/pkg/sentry/devices/tundev/tundev.go
index a40625e19..0b701a289 100644
--- a/pkg/sentry/devices/tundev/tundev.go
+++ b/pkg/sentry/devices/tundev/tundev.go
@@ -64,12 +64,13 @@ func (fd *tunFD) Ioctl(ctx context.Context, uio usermem.IO, args arch.SyscallArg
request := args[1].Uint()
data := args[2].Pointer()
+ t := kernel.TaskFromContext(ctx)
+ if t == nil {
+ panic("Ioctl should be called from a task context")
+ }
+
switch request {
case linux.TUNSETIFF:
- t := kernel.TaskFromContext(ctx)
- if t == nil {
- panic("Ioctl should be called from a task context")
- }
if !t.HasCapability(linux.CAP_NET_ADMIN) {
return 0, syserror.EPERM
}
@@ -79,9 +80,7 @@ func (fd *tunFD) Ioctl(ctx context.Context, uio usermem.IO, args arch.SyscallArg
}
var req linux.IFReq
- if _, err := usermem.CopyObjectIn(ctx, uio, data, &req, usermem.IOOpts{
- AddressSpaceActive: true,
- }); err != nil {
+ if _, err := req.CopyIn(t, data); err != nil {
return 0, err
}
flags := usermem.ByteOrder.Uint16(req.Data[:])
@@ -97,9 +96,7 @@ func (fd *tunFD) Ioctl(ctx context.Context, uio usermem.IO, args arch.SyscallArg
flags := fd.device.Flags() | linux.IFF_NOFILTER
usermem.ByteOrder.PutUint16(req.Data[:], flags)
- _, err := usermem.CopyObjectOut(ctx, uio, data, &req, usermem.IOOpts{
- AddressSpaceActive: true,
- })
+ _, err := req.CopyOut(t, data)
return 0, err
default: