From e34fdc5479037bf7b6efed3239362585a1c1ff3b Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Mon, 11 Jan 2021 10:49:38 -0500 Subject: [PATCH] LU-9859 libcfs: remove cfs_capable Use capable() directly. Linux-commit: 2eb90a757e9d953c9e2a8fce530422189992fb1b Change-Id: Iadaa3c743a350def37558b23d954f5dfd4e0844a Signed-off-by: Peng Tao Signed-off-by: Greg Kroah-Hartman Reviewed-on: https://review.whamcloud.com/41783 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Arshad Hussain Reviewed-by: Neil Brown Reviewed-by: Oleg Drokin --- libcfs/include/libcfs/curproc.h | 1 - libcfs/libcfs/linux/linux-curproc.c | 6 ------ lustre/llite/dir.c | 8 ++++---- lustre/llite/file.c | 6 +++--- lustre/llite/llite_lib.c | 4 ++-- lustre/obdclass/class_obd.c | 2 +- lustre/obdecho/echo_client.c | 12 ++++++------ lustre/osc/osc_io.c | 2 +- 8 files changed, 17 insertions(+), 24 deletions(-) diff --git a/libcfs/include/libcfs/curproc.h b/libcfs/include/libcfs/curproc.h index ac947e8..8501041 100644 --- a/libcfs/include/libcfs/curproc.h +++ b/libcfs/include/libcfs/curproc.h @@ -53,7 +53,6 @@ typedef __u32 cfs_cap_t; cfs_cap_t cfs_curproc_cap_pack(void); void cfs_curproc_cap_unpack(cfs_cap_t cap); -int cfs_capable(cfs_cap_t cap); /* __LIBCFS_CURPROC_H__ */ #endif diff --git a/libcfs/libcfs/linux/linux-curproc.c b/libcfs/libcfs/linux/linux-curproc.c index e6cdb63..da2b107 100644 --- a/libcfs/libcfs/linux/linux-curproc.c +++ b/libcfs/libcfs/linux/linux-curproc.c @@ -101,11 +101,6 @@ void cfs_curproc_cap_unpack(cfs_cap_t cap) } } -int cfs_capable(cfs_cap_t cap) -{ - return capable(cfs_cap_unpack(cap)); -} - static int cfs_access_process_vm(struct task_struct *tsk, struct mm_struct *mm, unsigned long addr, @@ -268,7 +263,6 @@ out: EXPORT_SYMBOL(cfs_get_environ); EXPORT_SYMBOL(cfs_curproc_cap_pack); -EXPORT_SYMBOL(cfs_capable); /* * Local variables: diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 6d083b6..2d631d9 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -1138,14 +1138,14 @@ int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl) case LUSTRE_Q_SETDEFAULT: case LUSTRE_Q_SETQUOTAPOOL: case LUSTRE_Q_SETINFOPOOL: - if (!cfs_capable(CAP_SYS_ADMIN)) + if (!capable(CAP_SYS_ADMIN)) RETURN(-EPERM); break; case Q_GETQUOTA: case LUSTRE_Q_GETDEFAULT: case LUSTRE_Q_GETQUOTAPOOL: if (check_owner(type, id) && - (!cfs_capable(CAP_SYS_ADMIN))) + (!capable(CAP_SYS_ADMIN))) RETURN(-EPERM); break; case Q_GETINFO: @@ -1274,7 +1274,7 @@ int ll_rmfid(struct file *file, void __user *arg) int i, rc, *rcs = NULL; ENTRY; - if (!cfs_capable(CAP_DAC_READ_SEARCH) && + if (!capable(CAP_DAC_READ_SEARCH) && !(ll_i2sbi(file_inode(file))->ll_flags & LL_SBI_USER_FID2PATH)) RETURN(-EPERM); /* Only need to get the buflen */ @@ -2040,7 +2040,7 @@ out_hur: RETURN(rc); } case LL_IOC_HSM_CT_START: - if (!cfs_capable(CAP_SYS_ADMIN)) + if (!capable(CAP_SYS_ADMIN)) RETURN(-EPERM); rc = copy_and_ct_start(cmd, sbi->ll_md_exp, diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 449f895..975112b 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -2243,7 +2243,7 @@ static int ll_lov_setea(struct inode *inode, struct file *file, int rc; ENTRY; - if (!cfs_capable(CAP_SYS_ADMIN)) + if (!capable(CAP_SYS_ADMIN)) RETURN(-EPERM); OBD_ALLOC_LARGE(lump, lum_size); @@ -2565,7 +2565,7 @@ int ll_fid2path(struct inode *inode, void __user *arg) ENTRY; - if (!cfs_capable(CAP_DAC_READ_SEARCH) && + if (!capable(CAP_DAC_READ_SEARCH) && !(ll_i2sbi(inode)->ll_flags & LL_SBI_USER_FID2PATH)) RETURN(-EPERM); @@ -2853,7 +2853,7 @@ int ll_hsm_state_set(struct inode *inode, struct hsm_state_set *hss) /* Non-root users are forbidden to set or clear flags which are * NOT defined in HSM_USER_MASK. */ if (((hss->hss_setmask | hss->hss_clearmask) & ~HSM_USER_MASK) && - !cfs_capable(CAP_SYS_ADMIN)) + !capable(CAP_SYS_ADMIN)) RETURN(-EPERM); if (!exp_connect_archive_id_array(exp)) { diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index c6aff22..2783678 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -2042,7 +2042,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, /* POSIX: check before ATTR_*TIME_SET set (from inode_change_ok) */ if (attr->ia_valid & TIMES_SET_FLAGS) { if ((!uid_eq(current_fsuid(), inode->i_uid)) && - !cfs_capable(CAP_FOWNER)) + !capable(CAP_FOWNER)) RETURN(-EPERM); } @@ -3382,7 +3382,7 @@ int ll_getparent(struct file *file, struct getparent __user *arg) ENTRY; - if (!cfs_capable(CAP_DAC_READ_SEARCH) && + if (!capable(CAP_DAC_READ_SEARCH) && !(ll_i2sbi(inode)->ll_flags & LL_SBI_USER_FID2PATH)) RETURN(-EPERM); diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 7fab38a..ac335ef 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -482,7 +482,7 @@ static long obd_class_ioctl(struct file *filp, unsigned int cmd, ENTRY; /* Allow non-root access for some limited ioctls */ - if (!cfs_capable(CAP_SYS_ADMIN)) + if (!capable(CAP_SYS_ADMIN)) RETURN(err = -EACCES); if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */ diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index 92c923d..1ef99a5 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -2841,7 +2841,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, switch (cmd) { case OBD_IOC_CREATE: /* may create echo object */ - if (!cfs_capable(CAP_SYS_ADMIN)) + if (!capable(CAP_SYS_ADMIN)) GOTO(out, rc = -EPERM); rc = echo_create_object(env, ed, oa); @@ -2855,7 +2855,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, int dirlen; __u64 id; - if (!cfs_capable(CAP_SYS_ADMIN)) + if (!capable(CAP_SYS_ADMIN)) GOTO(out, rc = -EPERM); count = data->ioc_count; @@ -2880,7 +2880,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, __u64 seq; int max_count; - if (!cfs_capable(CAP_SYS_ADMIN)) + if (!capable(CAP_SYS_ADMIN)) GOTO(out, rc = -EPERM); rc = seq_client_get_seq(env, ed->ed_cl_seq, &seq); @@ -2901,7 +2901,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, } #endif /* HAVE_SERVER_SUPPORT */ case OBD_IOC_DESTROY: - if (!cfs_capable(CAP_SYS_ADMIN)) + if (!capable(CAP_SYS_ADMIN)) GOTO(out, rc = -EPERM); rc = echo_get_object(&eco, ed, oa); @@ -2922,7 +2922,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, GOTO(out, rc); case OBD_IOC_SETATTR: - if (!cfs_capable(CAP_SYS_ADMIN)) + if (!capable(CAP_SYS_ADMIN)) GOTO(out, rc = -EPERM); rc = echo_get_object(&eco, ed, oa); @@ -2933,7 +2933,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, GOTO(out, rc); case OBD_IOC_BRW_WRITE: - if (!cfs_capable(CAP_SYS_ADMIN)) + if (!capable(CAP_SYS_ADMIN)) GOTO(out, rc = -EPERM); rw = OBD_BRW_WRITE; diff --git a/lustre/osc/osc_io.c b/lustre/osc/osc_io.c index 0cdd2ea..062fbe4 100644 --- a/lustre/osc/osc_io.c +++ b/lustre/osc/osc_io.c @@ -415,7 +415,7 @@ int osc_io_iter_init(const struct lu_env *env, const struct cl_io_slice *ios) } spin_unlock(&imp->imp_lock); - if (cfs_capable(CAP_SYS_RESOURCE)) + if (capable(CAP_SYS_RESOURCE)) oio->oi_cap_sys_resource = 1; RETURN(rc); -- 1.8.3.1