summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/syscalls/linux/vfs2
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2020-01-28 16:42:05 -0800
committergVisor bot <gvisor-bot@google.com>2020-01-28 16:53:55 -0800
commit3d046fef06ece6ba20770fa62e0a21569226adaa (patch)
treede0d4ad6b0c25d3c423dc2e57df8b78c04666082 /pkg/sentry/syscalls/linux/vfs2
parent431ff52768c2300e15cba609c2be4f507fd30d5b (diff)
Changes missing in last submit
Updates #1487 Updates #1623 PiperOrigin-RevId: 292040835
Diffstat (limited to 'pkg/sentry/syscalls/linux/vfs2')
-rw-r--r--pkg/sentry/syscalls/linux/vfs2/sys_read.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/pkg/sentry/syscalls/linux/vfs2/sys_read.go b/pkg/sentry/syscalls/linux/vfs2/sys_read.go
index b9fb58464..7667524c7 100644
--- a/pkg/sentry/syscalls/linux/vfs2/sys_read.go
+++ b/pkg/sentry/syscalls/linux/vfs2/sys_read.go
@@ -24,6 +24,11 @@ import (
"gvisor.dev/gvisor/pkg/waiter"
)
+const (
+ // EventMaskRead contains events that can be triggered on reads.
+ EventMaskRead = waiter.EventIn | waiter.EventHUp | waiter.EventErr
+)
+
// Read implements linux syscall read(2). Note that we try to get a buffer that
// is exactly the size requested because some applications like qemu expect
// they can do large reads all at once. Bug for bug. Same for other read
@@ -39,11 +44,6 @@ func Read(t *kernel.Task, args arch.SyscallArguments) (uintptr, *kernel.SyscallC
}
defer file.DecRef()
- // Check that the file is readable.
- if !file.IsReadable() {
- return 0, nil, syserror.EBADF
- }
-
// Check that the size is legitimate.
si := int(size)
if si < 0 {
@@ -70,8 +70,8 @@ func read(t *kernel.Task, file *vfs.FileDescription, dst usermem.IOSequence, opt
}
// Register for notifications.
- _, ch := waiter.NewChannelEntry(nil)
- // file.EventRegister(&w, EventMaskRead)
+ w, ch := waiter.NewChannelEntry(nil)
+ file.EventRegister(&w, EventMaskRead)
total := n
for {
@@ -89,7 +89,7 @@ func read(t *kernel.Task, file *vfs.FileDescription, dst usermem.IOSequence, opt
break
}
}
- //file.EventUnregister(&w)
+ file.EventUnregister(&w)
return total, err
}