From: Waldemar Kozaczuk <jwkozac...@gmail.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master
vfs: Harden task_conv() to return EFAULT when cpath argument is null
This patch also reverts the commit a0dcf8530c352536ab6633952b6f614f73eed154.
Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>
Message-Id: <20190519204728.16752-1-jwkozac...@gmail.com>
---
diff --git a/fs/vfs/main.cc b/fs/vfs/main.cc
--- a/fs/vfs/main.cc
+++ b/fs/vfs/main.cc
@@ -120,11 +120,6 @@ int open(const char *pathname, int flags, ...)
int fd, error;
int acc;
- if (pathname == nullptr) {
- error = EFAULT;
- goto out_errno;
- }
-
acc = 0;
switch (flags & O_ACCMODE) {
case O_RDONLY:
diff --git a/fs/vfs/vfs_syscalls.cc b/fs/vfs/vfs_syscalls.cc
--- a/fs/vfs/vfs_syscalls.cc
+++ b/fs/vfs/vfs_syscalls.cc
@@ -117,10 +117,6 @@ sys_open(char *path, int flags, mode_t mode, struct
file **fpp)
DPRINTF(VFSDB_SYSCALL, ("sys_open: path=%s flags=%x mode=%x\n",
path, flags, mode));
- if (path == nullptr) {
- return (EFAULT);
- }
-
flags = fflags(flags);
if (flags & O_CREAT) {
error = namei(path, &dp);
diff --git a/fs/vfs/vfs_task.cc b/fs/vfs/vfs_task.cc
--- a/fs/vfs/vfs_task.cc
+++ b/fs/vfs/vfs_task.cc
@@ -146,6 +146,10 @@ task_conv(struct task *t, const char *cpath, int acc,
char *full)
{
int rc;
+ if (cpath == nullptr) {
+ return (EFAULT);
+ }
+
rc = path_conv(t->t_cwd, cpath, full);
if (rc != 0) {
return (rc);
--
You received this message because you are subscribed to the Google Groups "OSv
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/osv-dev/0000000000005e461805894dafb8%40google.com.
For more options, visit https://groups.google.com/d/optout.