From 63f27e42d75c97c8b11f64e91f43127bfe2bda7b Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Wed, 8 May 2019 14:27:27 -0700 Subject: [PATCH] [LibOS] Remove abspath check from *at() syscalls This patch is a follow-up of https://github.com/oscarlab/graphene/pull/671. With #671, absolute path check is handled uniformly by __path_lookupat(). Now absolute path check in each system call isn't needed, so we can remove it. --- LibOS/shim/src/sys/shim_access.c | 3 --- LibOS/shim/src/sys/shim_fs.c | 16 +++------------- LibOS/shim/src/sys/shim_open.c | 3 --- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/LibOS/shim/src/sys/shim_access.c b/LibOS/shim/src/sys/shim_access.c index f7d5f9a1..2e6c61db 100644 --- a/LibOS/shim/src/sys/shim_access.c +++ b/LibOS/shim/src/sys/shim_access.c @@ -58,9 +58,6 @@ int shim_do_faccessat (int dfd, const char * filename, mode_t mode) if (test_user_string(filename)) return -EFAULT; - if (*filename == '/') - return shim_do_access(filename, mode); - struct shim_dentry * dir = NULL, * dent = NULL; int ret = 0; diff --git a/LibOS/shim/src/sys/shim_fs.c b/LibOS/shim/src/sys/shim_fs.c index ec9ba5d2..a0d94214 100644 --- a/LibOS/shim/src/sys/shim_fs.c +++ b/LibOS/shim/src/sys/shim_fs.c @@ -84,10 +84,6 @@ int shim_do_unlinkat (int dfd, const char * pathname, int flag) if (flag & ~AT_REMOVEDIR) return -EINVAL; - if (*pathname == '/') - return (flag & AT_REMOVEDIR) ? shim_do_rmdir(pathname) : - shim_do_unlink(pathname); - struct shim_dentry * dir = NULL, * dent = NULL; int ret = 0; @@ -142,9 +138,6 @@ int shim_do_mkdirat (int dfd, const char * pathname, int mode) if (test_user_string(pathname)) return -EFAULT; - if (*pathname == '/') - return shim_do_mkdir(pathname, mode); - struct shim_dentry * dir = NULL; int ret = 0; @@ -239,9 +232,6 @@ int shim_do_fchmodat (int dfd, const char * filename, mode_t mode) if (test_user_string(filename)) return -EFAULT; - if (*filename == '/') - return shim_do_chmod(filename, mode); - struct shim_dentry * dir = NULL, * dent = NULL; int ret = 0; @@ -313,15 +303,15 @@ int shim_do_fchownat (int dfd, const char * filename, uid_t uid, gid_t gid, int flags) { __UNUSED(flags); + __UNUSED(uid); + __UNUSED(gid); + if (!filename) return -EINVAL; if (test_user_string(filename)) return -EFAULT; - if (*filename == '/') - return shim_do_chown(filename, uid, gid); - struct shim_dentry * dir = NULL, * dent = NULL; int ret = 0; diff --git a/LibOS/shim/src/sys/shim_open.c b/LibOS/shim/src/sys/shim_open.c index b0ee7d13..ee9641bc 100644 --- a/LibOS/shim/src/sys/shim_open.c +++ b/LibOS/shim/src/sys/shim_open.c @@ -134,9 +134,6 @@ int shim_do_openat (int dfd, const char * filename, int flags, int mode) if (!filename || test_user_string(filename)) return -EFAULT; - if (*filename == '/') - return shim_do_open(filename, flags, mode); - struct shim_dentry * dir = NULL; int ret = 0;