summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTing-Yu Wang <anivia@google.com>2020-04-09 17:59:30 -0700
committergVisor bot <gvisor-bot@google.com>2020-04-09 18:00:33 -0700
commitc9195349c9ac24ccb538e92b308225dfa4184c42 (patch)
treeb69529b85d8061313768929adb5c10787151ad1c
parent257225c34b81ff0d0b5ce8ae333f5905f9e86cce (diff)
Replace type assertion with TaskFromContext.
This should fix panic at aio callback. PiperOrigin-RevId: 305798549
-rw-r--r--pkg/sentry/socket/netstack/netstack.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/pkg/sentry/socket/netstack/netstack.go b/pkg/sentry/socket/netstack/netstack.go
index 20e3fa0d2..7ac38764d 100644
--- a/pkg/sentry/socket/netstack/netstack.go
+++ b/pkg/sentry/socket/netstack/netstack.go
@@ -535,7 +535,7 @@ func (s *SocketOperations) Write(ctx context.Context, _ *fs.File, src usermem.IO
}
if resCh != nil {
- t := ctx.(*kernel.Task)
+ t := kernel.TaskFromContext(ctx)
if err := t.Block(resCh); err != nil {
return 0, syserr.FromError(err).ToError()
}
@@ -608,7 +608,7 @@ func (s *SocketOperations) ReadFrom(ctx context.Context, _ *fs.File, r io.Reader
}
if resCh != nil {
- t := ctx.(*kernel.Task)
+ t := kernel.TaskFromContext(ctx)
if err := t.Block(resCh); err != nil {
return 0, syserr.FromError(err).ToError()
}