fs: change return values from -EACCES to -EPERM
Subsystems (5)
PATCH v2 1/1 fs: change return values from -EACCES to -EPERM
From: Zhao Hongjiang <[email protected]>
According to SUSv3:
[EACCES] Permission denied. An attempt was made to access a file in a way forbidden by its file access permissions.
[EPERM] Operation not permitted. An attempt was made to perform an operation limited to processes with appropriate privileges or to the owner of a file or other resource.
So -EPERM should be returned if capability checks fails.
Strictly speaking this is an API change since the error code user sees is different but I don't think anyone really cares.
---
This patch is based on linux-next tree http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git
--- fs/autofs4/root.c | 2 +- fs/dlm/config.c | 2 +- fs/gfs2/sys.c | 18 +++++++++--------- fs/ncpfs/ioctl.c | 2 +- fs/proc/base.c | 6 +++--- fs/udf/file.c | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-)
fs/autofs4/root.c +1 -1
@@ -581,7 +581,7 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry)/* This allows root to remove symlinks */ if (!autofs4_oz_mode (sbi) && !capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ;if (atomic_dec_and_test (&ino->count)) { p_ino =autofs4_dentry_ino (dentry->d_parent);
fs/dlm/config.c +1 -1
@@ -158,7 +158,7 @@ static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,unsigned int x;if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ; x =simple_strtoul (buf,NULL ,0 );
fs/gfs2/sys.c +9 -9
@@ -107,7 +107,7 @@ static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len)int n =simple_strtol (buf,NULL ,0 );if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ;switch (n) {case 0 :
@@ -135,7 +135,7 @@ static ssize_t withdraw_show(struct gfs2_sbd *sdp, char *buf)static ssize_t withdraw_store (struct gfs2_sbd *sdp,const char *buf,size_t len) {if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ;if (simple_strtol (buf,NULL ,0 ) !=1 )return -EINVAL ;
@@ -150,7 +150,7 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf, size_t len) {if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ;if (simple_strtol (buf,NULL ,0 ) !=1 )return -EINVAL ;
@@ -163,7 +163,7 @@ static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf, size_t len) {if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ;if (simple_strtol (buf,NULL ,0 ) !=1 )return -EINVAL ;
@@ -179,7 +179,7 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd *sdp, const char *buf,u32 id;if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ; id =simple_strtoul (buf,NULL ,0 );
@@ -194,7 +194,7 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd *sdp, const char *buf,u32 id;if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ; id =simple_strtoul (buf,NULL ,0 );
@@ -213,7 +213,7 @@ static ssize_t demote_rq_store(struct gfs2_sbd *sdp, const char *buf, size_t lenint rv;if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ; rv =sscanf (buf,"%u:%llu %15s" , &gltype, &glnum, mode);
@@ -502,7 +502,7 @@ static ssize_t quota_scale_store(struct gfs2_sbd *sdp, const char *buf,unsigned int x, y;if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ;if (sscanf (buf,"%u %u" , &x, &y) !=2 || !y)return -EINVAL ;
@@ -521,7 +521,7 @@ static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned int *field,unsigned int x;if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ; x =simple_strtoul (buf,NULL ,0 );
fs/ncpfs/ioctl.c +1 -1
@@ -819,7 +819,7 @@ long ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)case NCP_IOC_CONN_LOGGED_IN :case NCP_IOC_SETROOT :if (!capable (CAP_SYS_ADMIN )) { - ret = -EACCES ; + ret = -EPERM ; goto out; }break ;
fs/proc/base.c +3 -3
@@ -1911,7 +1911,7 @@ static int map_files_d_revalidate(struct dentry *dentry, unsigned int flags)return -ECHILD ;if (!capable (CAP_SYS_ADMIN )) { - status = -EACCES ; + status = -EPERM ; goto out_notask; }
@@ -2047,7 +2047,7 @@ static struct dentry *proc_map_files_lookup(struct inode *dir,struct dentry *result;struct mm_struct *mm; - result =ERR_PTR (-EACCES ); + result =ERR_PTR (-EPERM );if (!capable (CAP_SYS_ADMIN )) goto out;
@@ -2101,7 +2101,7 @@ proc_map_files_readdir(struct file *filp, void *dirent, filldir_t filldir)ino_t ino;int ret; - ret = -EACCES ; + ret = -EPERM ;if (!capable (CAP_SYS_ADMIN )) goto out;
fs/udf/file.c +1 -1
@@ -204,7 +204,7 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) goto out;case UDF_RELOCATE_BLOCKS :if (!capable (CAP_SYS_ADMIN )) { - result = -EACCES ; + result = -EPERM ; goto out; }if (get_user (old_block, (long __user *)arg)) {
-- 1.7.1
Hi,
Quoted 11 lines · Zhao Hongjiang
From: Zhao Hongjiang <[email protected]>
According to SUSv3:
[EACCES] Permission denied. An attempt was made to access a file in a way forbidden by its file access permissions.
[EPERM] Operation not permitted. An attempt was made to perform an operation limited to processes with appropriate privileges or to the owner of a file or other resource.
Quoted 7 lines
So
-EPERMshould be returned if capability checks fails.Strictly speaking this is an API change since the error code user sees is different but I don't think anyone really cares.
Acked-by Jan Kara <[email protected]>Signed-off-by Zhao Hongjiang <[email protected]>
That should be ok from a GFS2 point of view. A number of those sysfs files are either obsolete or only used by a single userland tool, so it shouldn't make any difference that the error code has changed.
Quoted 182 lines
---
This patch is based on linux-next tree http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git
--- fs/autofs4/root.c | 2 +- fs/dlm/config.c | 2 +- fs/gfs2/sys.c | 18 +++++++++--------- fs/ncpfs/ioctl.c | 2 +- fs/proc/base.c | 6 +++--- fs/udf/file.c | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-)fs/autofs4/root.c +1
-1@@ -581,7 +581,7 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry)/* This allows root to remove symlinks */ if (!autofs4_oz_mode (sbi) && !capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ;if (atomic_dec_and_test (&ino->count)) { p_ino =autofs4_dentry_ino (dentry->d_parent);fs/dlm/config.c +1
-1@@ -158,7 +158,7 @@ static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,unsigned int x;if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ; x =simple_strtoul (buf,NULL ,0 );fs/gfs2/sys.c +9
-9@@ -107,7 +107,7 @@ static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len)int n =simple_strtol (buf,NULL ,0 );if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ;switch (n) {case 0 :@@ -135,7 +135,7 @@ static ssize_t withdraw_show(struct gfs2_sbd *sdp, char *buf)static ssize_t withdraw_store (struct gfs2_sbd *sdp,const char *buf,size_t len) {if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ;if (simple_strtol (buf,NULL ,0 ) !=1 )return -EINVAL ;@@ -150,7 +150,7 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf, size_t len) {if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ;if (simple_strtol (buf,NULL ,0 ) !=1 )return -EINVAL ;@@ -163,7 +163,7 @@ static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf, size_t len) {if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ;if (simple_strtol (buf,NULL ,0 ) !=1 )return -EINVAL ;@@ -179,7 +179,7 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd *sdp, const char *buf,u32 id;if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ; id =simple_strtoul (buf,NULL ,0 );@@ -194,7 +194,7 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd *sdp, const char *buf,u32 id;if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ; id =simple_strtoul (buf,NULL ,0 );@@ -213,7 +213,7 @@ static ssize_t demote_rq_store(struct gfs2_sbd *sdp, const char *buf, size_t lenint rv;if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ; rv =sscanf (buf,"%u:%llu %15s" , &gltype, &glnum, mode);@@ -502,7 +502,7 @@ static ssize_t quota_scale_store(struct gfs2_sbd *sdp, const char *buf,unsigned int x, y;if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ;if (sscanf (buf,"%u %u" , &x, &y) !=2 || !y)return -EINVAL ;@@ -521,7 +521,7 @@ static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned int *field,unsigned int x;if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ; x =simple_strtoul (buf,NULL ,0 );fs/ncpfs/ioctl.c +1
-1@@ -819,7 +819,7 @@ long ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)case NCP_IOC_CONN_LOGGED_IN :case NCP_IOC_SETROOT :if (!capable (CAP_SYS_ADMIN )) { - ret = -EACCES ; + ret = -EPERM ; goto out; }break ;fs/proc/base.c +3
-3@@ -1911,7 +1911,7 @@ static int map_files_d_revalidate(struct dentry *dentry, unsigned int flags)return -ECHILD ;if (!capable (CAP_SYS_ADMIN )) { - status = -EACCES ; + status = -EPERM ; goto out_notask; }@@ -2047,7 +2047,7 @@ static struct dentry *proc_map_files_lookup(struct inode *dir,struct dentry *result;struct mm_struct *mm; - result =ERR_PTR (-EACCES ); + result =ERR_PTR (-EPERM );if (!capable (CAP_SYS_ADMIN )) goto out;@@ -2101,7 +2101,7 @@ proc_map_files_readdir(struct file *filp, void *dirent, filldir_t filldir)ino_t ino;int ret; - ret = -EACCES ; + ret = -EPERM ;if (!capable (CAP_SYS_ADMIN )) goto out;fs/udf/file.c +1
-2@@ -204,7 +204,7 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) goto out;case UDF_RELOCATE_BLOCKS :if (!capable (CAP_SYS_ADMIN )) { - result = -EACCES ; + result = -EPERM ; goto out; }if (get_user (old_block, (long __user *)arg)) { -- 1.7.1
Quoted 4 lines · Zhao Hongjiang
From: Zhao Hongjiang <[email protected]>
According to SUSv3:
Quoted 8 lines
[EACCES] Permission denied. An attempt was made to access a file in a way forbidden by its file access permissions.
[EPERM] Operation not permitted. An attempt was made to perform an operation limited to processes with appropriate privileges or to the owner of a file or other resource.
So
-EPERMshould be returned if capability checks fails.
It shouldn't make a difference to autofs since the code is used to report the failure and a fail is a fail.
I don't know if this would have an impact on autodir or systemd.
Quoted 188 lines
Strictly speaking this is an API change since the error code user sees is different but I don't think anyone really cares.
Acked-by Jan Kara <[email protected]>Signed-off-by Zhao Hongjiang <[email protected]>---
This patch is based on linux-next tree http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git
--- fs/autofs4/root.c | 2 +- fs/dlm/config.c | 2 +- fs/gfs2/sys.c | 18 +++++++++--------- fs/ncpfs/ioctl.c | 2 +- fs/proc/base.c | 6 +++--- fs/udf/file.c | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-)fs/autofs4/root.c +1
-1@@ -581,7 +581,7 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry)/* This allows root to remove symlinks */ if (!autofs4_oz_mode (sbi) && !capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ;if (atomic_dec_and_test (&ino->count)) { p_ino =autofs4_dentry_ino (dentry->d_parent);fs/dlm/config.c +1
-1@@ -158,7 +158,7 @@ static ssize_t cluster_set(struct dlm_cluster *cl, unsigned int *cl_field,unsigned int x;if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ; x =simple_strtoul (buf,NULL ,0 );fs/gfs2/sys.c +9
-9@@ -107,7 +107,7 @@ static ssize_t freeze_store(struct gfs2_sbd *sdp, const char *buf, size_t len)int n =simple_strtol (buf,NULL ,0 );if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ;switch (n) {case 0 :@@ -135,7 +135,7 @@ static ssize_t withdraw_show(struct gfs2_sbd *sdp, char *buf)static ssize_t withdraw_store (struct gfs2_sbd *sdp,const char *buf,size_t len) {if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ;if (simple_strtol (buf,NULL ,0 ) !=1 )return -EINVAL ;@@ -150,7 +150,7 @@ static ssize_t statfs_sync_store(struct gfs2_sbd *sdp, const char *buf, size_t len) {if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ;if (simple_strtol (buf,NULL ,0 ) !=1 )return -EINVAL ;@@ -163,7 +163,7 @@ static ssize_t quota_sync_store(struct gfs2_sbd *sdp, const char *buf, size_t len) {if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ;if (simple_strtol (buf,NULL ,0 ) !=1 )return -EINVAL ;@@ -179,7 +179,7 @@ static ssize_t quota_refresh_user_store(struct gfs2_sbd *sdp, const char *buf,u32 id;if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ; id =simple_strtoul (buf,NULL ,0 );@@ -194,7 +194,7 @@ static ssize_t quota_refresh_group_store(struct gfs2_sbd *sdp, const char *buf,u32 id;if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ; id =simple_strtoul (buf,NULL ,0 );@@ -213,7 +213,7 @@ static ssize_t demote_rq_store(struct gfs2_sbd *sdp, const char *buf, size_t lenint rv;if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ; rv =sscanf (buf,"%u:%llu %15s" , &gltype, &glnum, mode);@@ -502,7 +502,7 @@ static ssize_t quota_scale_store(struct gfs2_sbd *sdp, const char *buf,unsigned int x, y;if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ;if (sscanf (buf,"%u %u" , &x, &y) !=2 || !y)return -EINVAL ;@@ -521,7 +521,7 @@ static ssize_t tune_set(struct gfs2_sbd *sdp, unsigned int *field,unsigned int x;if (!capable (CAP_SYS_ADMIN )) -return -EACCES ; +return -EPERM ; x =simple_strtoul (buf,NULL ,0 );fs/ncpfs/ioctl.c +1
-1@@ -819,7 +819,7 @@ long ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)case NCP_IOC_CONN_LOGGED_IN :case NCP_IOC_SETROOT :if (!capable (CAP_SYS_ADMIN )) { - ret = -EACCES ; + ret = -EPERM ; goto out; }break ;fs/proc/base.c +3
-3@@ -1911,7 +1911,7 @@ static int map_files_d_revalidate(struct dentry *dentry, unsigned int flags)return -ECHILD ;if (!capable (CAP_SYS_ADMIN )) { - status = -EACCES ; + status = -EPERM ; goto out_notask; }@@ -2047,7 +2047,7 @@ static struct dentry *proc_map_files_lookup(struct inode *dir,struct dentry *result;struct mm_struct *mm; - result =ERR_PTR (-EACCES ); + result =ERR_PTR (-EPERM );if (!capable (CAP_SYS_ADMIN )) goto out;@@ -2101,7 +2101,7 @@ proc_map_files_readdir(struct file *filp, void *dirent, filldir_t filldir)ino_t ino;int ret; - ret = -EACCES ; + ret = -EPERM ;if (!capable (CAP_SYS_ADMIN )) goto out;fs/udf/file.c +1
-2@@ -204,7 +204,7 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) goto out;case UDF_RELOCATE_BLOCKS :if (!capable (CAP_SYS_ADMIN )) { - result = -EACCES ; + result = -EPERM ; goto out; }if (get_user (old_block, (long __user *)arg)) { -- 1.7.1