From 9d5f5e4edc96d3cf17a20192acc62662df1f8bd3 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 Lustre-change: https://review.whamcloud.com/41783 Lustre-commit: e34fdc5479037bf7b6efed3239362585a1c1ff3b Change-Id: Iadaa3c743a350def37558b23d954f5dfd4e0844a Signed-off-by: Peng Tao Signed-off-by: Greg Kroah-Hartman Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/51741 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- 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 1bfd9b9..e0f1f96 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -1205,7 +1205,7 @@ int quotactl_ioctl(struct super_block *sb, struct if_quotactl *qctl) case LUSTRE_Q_SETDEFAULT_POOL: case LUSTRE_Q_DELETEQID: case LUSTRE_Q_RESETQID: - if (!cfs_capable(CAP_SYS_ADMIN)) + if (!capable(CAP_SYS_ADMIN)) RETURN(-EPERM); if (sb->s_flags & SB_RDONLY) @@ -1216,7 +1216,7 @@ int quotactl_ioctl(struct super_block *sb, struct if_quotactl *qctl) case LUSTRE_Q_GETQUOTAPOOL: case LUSTRE_Q_GETDEFAULT_POOL: if (check_owner(type, id) && - (!cfs_capable(CAP_SYS_ADMIN))) + (!capable(CAP_SYS_ADMIN))) RETURN(-EPERM); break; case Q_GETINFO: @@ -1346,7 +1346,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 */ @@ -2246,7 +2246,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 1a02f38..62d7022 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -2619,7 +2619,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); @@ -3105,7 +3105,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); @@ -3397,7 +3397,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 1c6e226..ec9e140 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -2119,7 +2119,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)) GOTO(clear, rc = -EPERM); } @@ -3739,7 +3739,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 fada3da..81fe19f 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -484,7 +484,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 3f543f1..eb35e09 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -2849,7 +2849,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); @@ -2863,7 +2863,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; @@ -2888,7 +2888,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); @@ -2909,7 +2909,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); @@ -2930,7 +2930,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); @@ -2941,7 +2941,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 04c4e20..1aaf4a1 100644 --- a/lustre/osc/osc_io.c +++ b/lustre/osc/osc_io.c @@ -421,7 +421,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