summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/syscalls
diff options
context:
space:
mode:
authorNicolas Lacasse <nlacasse@google.com>2019-04-29 10:29:14 -0700
committerShentubot <shentubot@google.com>2019-04-29 10:30:24 -0700
commit2df64cd6d2c835ce5b37a8b9111d24ad382b5d3d (patch)
treec6a051741939cefb927ebb059ec893e5d510b618 /pkg/sentry/syscalls
parent66bca6fc221393c9553cbaa0486e07c8124e2477 (diff)
createAt should return all errors from FindInode except ENOENT.
Previously, createAt was eating all errors from FindInode except for EACCES and proceeding with the creation. This is incorrect, as FindInode can return many other errors (like ENAMETOOLONG) that should stop creation. This CL changes createAt to return all errors encountered except for ENOENT, which we can ignore because we are about to create the thing. PiperOrigin-RevId: 245773222 Change-Id: I1b317021de70f0550fb865506f6d8147d4aebc56
Diffstat (limited to 'pkg/sentry/syscalls')
-rw-r--r--pkg/sentry/syscalls/linux/sys_file.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/pkg/sentry/syscalls/linux/sys_file.go b/pkg/sentry/syscalls/linux/sys_file.go
index d2d351449..50151f7b6 100644
--- a/pkg/sentry/syscalls/linux/sys_file.go
+++ b/pkg/sentry/syscalls/linux/sys_file.go
@@ -347,10 +347,9 @@ func createAt(t *kernel.Task, dirFD kdefs.FD, addr usermem.Addr, flags uint, mod
return syserror.ConvertIntr(err, kernel.ERESTARTSYS)
}
defer newFile.DecRef()
- case syserror.EACCES:
- // Permission denied while walking to the file.
- return err
- default:
+ case syserror.ENOENT:
+ // File does not exist. Proceed with creation.
+
// Do we have write permissions on the parent?
if err := d.Inode.CheckPermission(t, fs.PermMask{Write: true, Execute: true}); err != nil {
return err
@@ -365,6 +364,8 @@ func createAt(t *kernel.Task, dirFD kdefs.FD, addr usermem.Addr, flags uint, mod
}
defer newFile.DecRef()
targetDirent = newFile.Dirent
+ default:
+ return err
}
// Success.