diff options
author | Fabricio Voznika <fvoznika@google.com> | 2020-01-28 16:42:05 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-01-28 16:53:55 -0800 |
commit | 3d046fef06ece6ba20770fa62e0a21569226adaa (patch) | |
tree | de0d4ad6b0c25d3c423dc2e57df8b78c04666082 /pkg/sentry/syscalls/linux | |
parent | 431ff52768c2300e15cba609c2be4f507fd30d5b (diff) |
Changes missing in last submit
Updates #1487
Updates #1623
PiperOrigin-RevId: 292040835
Diffstat (limited to 'pkg/sentry/syscalls/linux')
-rw-r--r-- | pkg/sentry/syscalls/linux/sys_read.go | 2 | ||||
-rw-r--r-- | pkg/sentry/syscalls/linux/vfs2/sys_read.go | 16 |
2 files changed, 9 insertions, 9 deletions
diff --git a/pkg/sentry/syscalls/linux/sys_read.go b/pkg/sentry/syscalls/linux/sys_read.go index f9f594190..227692f06 100644 --- a/pkg/sentry/syscalls/linux/sys_read.go +++ b/pkg/sentry/syscalls/linux/sys_read.go @@ -29,7 +29,7 @@ import ( ) const ( - // EventMaskRead contains events that can be triggerd on reads. + // EventMaskRead contains events that can be triggered on reads. EventMaskRead = waiter.EventIn | waiter.EventHUp | waiter.EventErr ) 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 } |