From: Andreas Dilger Date: Sun, 19 Mar 2023 19:58:04 +0000 (-0600) Subject: LU-16634 misc: remove unnecessary ioctl typecasts X-Git-Tag: 2.15.56~219 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=4a1465577e1310ce09834103f7136bef0e1a1eeb;p=fs%2Flustre-release.git LU-16634 misc: remove unnecessary ioctl typecasts Declare "void __user *uarg" in the ioctl handling code so that it isn't typecast on every access in the ioctl handler. Unnecessary typecast risks hiding compiler warnings and bugs. Convert indentation to tabs for lines previously using spaces. Change local variable declarations to use only a single space. Test-Parameters: trivial Change-Id: I1a0d2f839949debf346aa15c65b0f407e1ce7057 Signed-off-by: Andreas Dilger Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50333 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Arshad Hussain Reviewed-by: Vitaliy Kuznetsov Reviewed-by: jsimmons Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index d56fc5b..4033524 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -61,7 +61,7 @@ extern rwlock_t obd_dev_lock; /* OBD Operations Declarations */ extern struct obd_device *class_exp2obd(struct obd_export *); -extern int class_handle_ioctl(unsigned int cmd, unsigned long arg); +extern int class_handle_ioctl(unsigned int cmd, void __user *uarg); int lustre_get_jobid(char *jobid, size_t len); void lustre_jobid_clear(const char *jobid); void jobid_cache_fini(void); diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 0ff2e45..9a2fc31 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -1496,6 +1496,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct inode *inode = file_inode(file); struct ll_sb_info *sbi = ll_i2sbi(inode); struct obd_ioctl_data *data = NULL; + void __user *uarg = (void __user *)arg; int rc = 0; ENTRY; @@ -1510,7 +1511,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) switch (cmd) { case FS_IOC_GETFLAGS: case FS_IOC_SETFLAGS: - RETURN(ll_iocontrol(inode, file, cmd, arg)); + RETURN(ll_iocontrol(inode, file, cmd, uarg)); case FSFILT_IOC_GETVERSION: case FS_IOC_GETVERSION: RETURN(put_user(inode->i_generation, (int __user *)arg)); @@ -1536,7 +1537,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) int namelen, len = 0; char *filename; - rc = obd_ioctl_getdata(&data, &len, (void __user *)arg); + rc = obd_ioctl_getdata(&data, &len, uarg); if (rc != 0) RETURN(rc); @@ -1567,7 +1568,7 @@ out_free: int len; int rc; - rc = obd_ioctl_getdata(&data, &len, (void __user *)arg); + rc = obd_ioctl_getdata(&data, &len, uarg); if (rc) RETURN(rc); @@ -1616,10 +1617,9 @@ lmv_out_free: } case LL_IOC_LMV_SET_DEFAULT_STRIPE: { - struct lmv_user_md lum; - struct lmv_user_md __user *ulump = - (struct lmv_user_md __user *)arg; - int rc; + struct lmv_user_md lum; + struct lmv_user_md __user *ulump = uarg; + int rc; if (copy_from_user(&lum, ulump, sizeof(lum))) RETURN(-EFAULT); @@ -1636,12 +1636,9 @@ lmv_out_free: struct lov_user_md_v3 *lumv3 = NULL; struct lov_user_md_v1 lumv1; struct lov_user_md_v1 *lumv1_ptr = &lumv1; - struct lov_user_md_v1 __user *lumv1p = - (struct lov_user_md_v1 __user *)arg; - struct lov_user_md_v3 __user *lumv3p = - (struct lov_user_md_v3 __user *)arg; + struct lov_user_md_v1 __user *lumv1p = uarg; + struct lov_user_md_v3 __user *lumv3p = uarg; int lum_size = 0; - int set_default = 0; BUILD_BUG_ON(sizeof(struct lov_user_md_v3) <= @@ -1681,21 +1678,20 @@ out: RETURN(rc); } case LL_IOC_LMV_GETSTRIPE: { - struct lmv_user_md __user *ulmv = - (struct lmv_user_md __user *)arg; - struct lmv_user_md lum; - struct ptlrpc_request *request = NULL; - struct ptlrpc_request *root_request = NULL; - union lmv_mds_md *lmm = NULL; - int lmmsize; - u64 valid = 0; - struct lmv_user_md *tmp = NULL; - int mdt_index; - int lum_size; - int stripe_count; - int max_stripe_count; - int i; - int rc; + struct lmv_user_md __user *ulmv = uarg; + struct lmv_user_md lum; + struct ptlrpc_request *request = NULL; + struct ptlrpc_request *root_request = NULL; + union lmv_mds_md *lmm = NULL; + int lmmsize; + u64 valid = 0; + struct lmv_user_md *tmp = NULL; + int mdt_index; + int lum_size; + int stripe_count; + int max_stripe_count; + int i; + int rc; if (copy_from_user(&lum, ulmv, sizeof(*ulmv))) RETURN(-EFAULT); @@ -1872,7 +1868,7 @@ finish_req: if (!(exp_connect_flags(sbi->ll_md_exp) & OBD_CONNECT_LVB_TYPE)) RETURN(-ENOTSUPP); - filename = ll_getname((const char __user *)arg); + filename = ll_getname(uarg); if (IS_ERR(filename)) RETURN(PTR_ERR(filename)); @@ -1882,16 +1878,16 @@ finish_req: rc = ll_rmdir_entry(inode, filename, namelen); out_rmdir: - if (filename) - ll_putname(filename); + if (filename) + ll_putname(filename); RETURN(rc); } case LL_IOC_RMFID: - RETURN(ll_rmfid(file, (void __user *)arg)); + RETURN(ll_rmfid(file, uarg)); case LL_IOC_LOV_SWAP_LAYOUTS: RETURN(-EPERM); case IOC_OBD_STATFS: - RETURN(ll_obd_statfs(inode, (void __user *)arg)); + RETURN(ll_obd_statfs(inode, uarg)); case LL_IOC_LOV_GETSTRIPE: case LL_IOC_LOV_GETSTRIPE_NEW: case LL_IOC_MDC_GETINFO_V1: @@ -1916,7 +1912,7 @@ out_rmdir: if (cmd == IOC_MDC_GETFILEINFO_V1 || cmd == IOC_MDC_GETFILEINFO_V2 || cmd == IOC_MDC_GETFILESTRIPE) { - filename = ll_getname((const char __user *)arg); + filename = ll_getname(uarg); if (IS_ERR(filename)) RETURN(PTR_ERR(filename)); @@ -1950,18 +1946,18 @@ out_rmdir: if (cmd == IOC_MDC_GETFILESTRIPE || cmd == LL_IOC_LOV_GETSTRIPE || cmd == LL_IOC_LOV_GETSTRIPE_NEW) { - lump = (struct lov_user_md __user *)arg; + lump = uarg; } else if (cmd == IOC_MDC_GETFILEINFO_V1 || cmd == LL_IOC_MDC_GETINFO_V1){ struct lov_user_mds_data_v1 __user *lmdp; - lmdp = (struct lov_user_mds_data_v1 __user *)arg; + lmdp = uarg; statp = &lmdp->lmd_st; lump = &lmdp->lmd_lmm; } else { struct lov_user_mds_data __user *lmdp; - lmdp = (struct lov_user_mds_data __user *)arg; + lmdp = uarg; fidp = &lmdp->lmd_fid; stxp = &lmdp->lmd_stx; flagsp = &lmdp->lmd_flags; @@ -2085,11 +2081,11 @@ out_req: if (!qctl) RETURN(-ENOMEM); - if (copy_from_user(qctl, (void __user *)arg, sizeof(*qctl))) + if (copy_from_user(qctl, uarg, sizeof(*qctl))) GOTO(out_quotactl, rc = -EFAULT); if (LUSTRE_Q_CMD_IS_POOL(qctl->qc_cmd)) { - char __user *from = (char __user *)arg + + char __user *from = uarg + offsetof(typeof(*qctl), qc_poolname); if (copy_from_user(qctl->qc_poolname, from, LOV_MAXPOOLNAME + 1)) @@ -2098,61 +2094,57 @@ out_req: rc = quotactl_ioctl(inode->i_sb, qctl); if ((rc == 0 || rc == -ENODATA) && - copy_to_user((void __user *)arg, qctl, sizeof(*qctl))) - rc = -EFAULT; - + copy_to_user(uarg, qctl, sizeof(*qctl))) + rc = -EFAULT; out_quotactl: OBD_FREE(qctl, qctl_len); RETURN(rc); - } + } case OBD_IOC_GETNAME_OLD: case OBD_IOC_GETDTNAME: case OBD_IOC_GETMDNAME: - RETURN(ll_get_obd_name(inode, cmd, arg)); - case LL_IOC_FLUSHCTX: - RETURN(ll_flush_ctx(inode)); - case LL_IOC_GETOBDCOUNT: { + RETURN(ll_get_obd_name(inode, cmd, uarg)); + case LL_IOC_FLUSHCTX: + RETURN(ll_flush_ctx(inode)); + case LL_IOC_GETOBDCOUNT: { u32 count, vallen; - struct obd_export *exp; + struct obd_export *exp; - if (copy_from_user(&count, (int __user *)arg, sizeof(int))) - RETURN(-EFAULT); + if (copy_from_user(&count, uarg, sizeof(count))) + RETURN(-EFAULT); - /* get ost count when count is zero, get mdt count otherwise */ - exp = count ? sbi->ll_md_exp : sbi->ll_dt_exp; - vallen = sizeof(count); + /* get ost count when count is zero, get mdt count otherwise */ + exp = count ? sbi->ll_md_exp : sbi->ll_dt_exp; + vallen = sizeof(count); rc = obd_get_info(NULL, exp, sizeof(KEY_TGT_COUNT), KEY_TGT_COUNT, &vallen, &count); - if (rc) { - CERROR("get target count failed: %d\n", rc); - RETURN(rc); - } + if (rc) { + CERROR("get target count failed: %d\n", rc); + RETURN(rc); + } + + if (copy_to_user(uarg, &count, sizeof(count))) + RETURN(-EFAULT); - if (copy_to_user((int __user *)arg, &count, sizeof(int))) - RETURN(-EFAULT); - - RETURN(0); - } - case LL_IOC_PATH2FID: - if (copy_to_user((void __user *)arg, ll_inode2fid(inode), - sizeof(struct lu_fid))) - RETURN(-EFAULT); - RETURN(0); - case LL_IOC_GET_CONNECT_FLAGS: { - RETURN(obd_iocontrol(cmd, sbi->ll_md_exp, 0, NULL, - (void __user *)arg)); - } + RETURN(0); + } + case LL_IOC_PATH2FID: + if (copy_to_user(uarg, ll_inode2fid(inode), + sizeof(struct lu_fid))) + RETURN(-EFAULT); + RETURN(0); + case LL_IOC_GET_CONNECT_FLAGS: + RETURN(obd_iocontrol(cmd, sbi->ll_md_exp, 0, NULL, uarg)); case OBD_IOC_FID2PATH: - RETURN(ll_fid2path(inode, (void __user *)arg)); + RETURN(ll_fid2path(inode, uarg)); case LL_IOC_GETPARENT: - RETURN(ll_getparent(file, (void __user *)arg)); + RETURN(ll_getparent(file, uarg)); case LL_IOC_FID2MDTIDX: { struct obd_export *exp = ll_i2mdexp(inode); - struct lu_fid fid; - __u32 index; + struct lu_fid fid; + __u32 index; - if (copy_from_user(&fid, (const struct lu_fid __user *)arg, - sizeof(fid))) + if (copy_from_user(&fid, uarg, sizeof(fid))) RETURN(-EFAULT); /* Call mdc_iocontrol */ @@ -2164,15 +2156,15 @@ out_quotactl: RETURN(index); } case LL_IOC_HSM_REQUEST: { - struct hsm_user_request *hur; - ssize_t totalsize; + struct hsm_user_request *hur; + ssize_t totalsize; OBD_ALLOC_PTR(hur); if (hur == NULL) RETURN(-ENOMEM); /* We don't know the true size yet; copy the fixed-size part */ - if (copy_from_user(hur, (void __user *)arg, sizeof(*hur))) { + if (copy_from_user(hur, uarg, sizeof(*hur))) { OBD_FREE_PTR(hur); RETURN(-EFAULT); } @@ -2192,7 +2184,7 @@ out_quotactl: RETURN(-ENOMEM); /* Copy the whole struct */ - if (copy_from_user(hur, (void __user *)arg, totalsize)) + if (copy_from_user(hur, uarg, totalsize)) GOTO(out_hur, rc = -EFAULT); if (hur->hur_request.hr_action == HUA_RELEASE) { @@ -2217,17 +2209,16 @@ out_quotactl: rc = obd_iocontrol(cmd, ll_i2mdexp(inode), totalsize, hur, NULL); } - out_hur: OBD_FREE_LARGE(hur, totalsize); RETURN(rc); } case LL_IOC_HSM_PROGRESS: { - struct hsm_progress_kernel hpk; - struct hsm_progress hp; + struct hsm_progress_kernel hpk; + struct hsm_progress hp; - if (copy_from_user(&hp, (void __user *)arg, sizeof(hp))) + if (copy_from_user(&hp, uarg, sizeof(hp))) RETURN(-EFAULT); hpk.hpk_fid = hp.hp_fid; @@ -2247,43 +2238,42 @@ out_hur: if (!capable(CAP_SYS_ADMIN)) RETURN(-EPERM); - rc = copy_and_ct_start(cmd, sbi->ll_md_exp, - (struct lustre_kernelcomm __user *)arg); + rc = copy_and_ct_start(cmd, sbi->ll_md_exp, uarg); RETURN(rc); case LL_IOC_HSM_COPY_START: { - struct hsm_copy *copy; - int rc; + struct hsm_copy *copy; + int rc; OBD_ALLOC_PTR(copy); if (copy == NULL) RETURN(-ENOMEM); - if (copy_from_user(copy, (char __user *)arg, sizeof(*copy))) { + if (copy_from_user(copy, uarg, sizeof(*copy))) { OBD_FREE_PTR(copy); RETURN(-EFAULT); } rc = ll_ioc_copy_start(inode->i_sb, copy); - if (copy_to_user((char __user *)arg, copy, sizeof(*copy))) + if (copy_to_user(uarg, copy, sizeof(*copy))) rc = -EFAULT; OBD_FREE_PTR(copy); RETURN(rc); } case LL_IOC_HSM_COPY_END: { - struct hsm_copy *copy; - int rc; + struct hsm_copy *copy; + int rc; OBD_ALLOC_PTR(copy); if (copy == NULL) RETURN(-ENOMEM); - if (copy_from_user(copy, (char __user *)arg, sizeof(*copy))) { + if (copy_from_user(copy, uarg, sizeof(*copy))) { OBD_FREE_PTR(copy); RETURN(-EFAULT); } rc = ll_ioc_copy_end(inode->i_sb, copy); - if (copy_to_user((char __user *)arg, copy, sizeof(*copy))) + if (copy_to_user(uarg, copy, sizeof(*copy))) rc = -EFAULT; OBD_FREE_PTR(copy); @@ -2297,7 +2287,7 @@ out_hur: __u32 flags; int rc; - rc = obd_ioctl_getdata(&data, &len, (void __user *)arg); + rc = obd_ioctl_getdata(&data, &len, uarg); if (rc) RETURN(rc); @@ -2330,11 +2320,11 @@ migrate_free: RETURN(rc); } case FS_IOC_FSGETXATTR: - RETURN(ll_ioctl_fsgetxattr(inode, cmd, arg)); + RETURN(ll_ioctl_fsgetxattr(inode, cmd, uarg)); case FS_IOC_FSSETXATTR: - RETURN(ll_ioctl_fssetxattr(inode, cmd, arg)); + RETURN(ll_ioctl_fssetxattr(inode, cmd, uarg)); case LL_IOC_PROJECT: - RETURN(ll_ioctl_project(file, cmd, arg)); + RETURN(ll_ioctl_project(file, cmd, uarg)); case LL_IOC_PCC_DETACH_BY_FID: { struct lu_pcc_detach_fid *detach; struct lu_fid *fid; @@ -2345,9 +2335,7 @@ migrate_free: if (detach == NULL) RETURN(-ENOMEM); - if (copy_from_user(detach, - (const struct lu_pcc_detach_fid __user *)arg, - sizeof(*detach))) + if (copy_from_user(detach, uarg, sizeof(*detach))) GOTO(out_detach, rc = -EFAULT); fid = &detach->pccd_fid; @@ -2376,15 +2364,15 @@ out_detach: case LL_IOC_SET_ENCRYPTION_POLICY: if (!ll_sbi_has_encrypt(ll_i2sbi(inode))) return -EOPNOTSUPP; - return llcrypt_ioctl_set_policy(file, (const void __user *)arg); + return llcrypt_ioctl_set_policy(file, uarg); case LL_IOC_GET_ENCRYPTION_POLICY_EX: if (!ll_sbi_has_encrypt(ll_i2sbi(inode))) return -EOPNOTSUPP; - return llcrypt_ioctl_get_policy_ex(file, (void __user *)arg); + return llcrypt_ioctl_get_policy_ex(file, uarg); case LL_IOC_ADD_ENCRYPTION_KEY: if (!ll_sbi_has_encrypt(ll_i2sbi(inode))) return -EOPNOTSUPP; - rc = llcrypt_ioctl_add_key(file, (void __user *)arg); + rc = llcrypt_ioctl_add_key(file, uarg); #ifdef CONFIG_LL_ENCRYPTION if (!rc) sptlrpc_enc_pool_add_user(); @@ -2393,20 +2381,18 @@ out_detach: case LL_IOC_REMOVE_ENCRYPTION_KEY: if (!ll_sbi_has_encrypt(ll_i2sbi(inode))) return -EOPNOTSUPP; - return llcrypt_ioctl_remove_key(file, (void __user *)arg); + return llcrypt_ioctl_remove_key(file, uarg); case LL_IOC_REMOVE_ENCRYPTION_KEY_ALL_USERS: if (!ll_sbi_has_encrypt(ll_i2sbi(inode))) return -EOPNOTSUPP; - return llcrypt_ioctl_remove_key_all_users(file, - (void __user *)arg); + return llcrypt_ioctl_remove_key_all_users(file, uarg); case LL_IOC_GET_ENCRYPTION_KEY_STATUS: if (!ll_sbi_has_encrypt(ll_i2sbi(inode))) return -EOPNOTSUPP; - return llcrypt_ioctl_get_key_status(file, (void __user *)arg); + return llcrypt_ioctl_get_key_status(file, uarg); #endif default: - RETURN(obd_iocontrol(cmd, sbi->ll_dt_exp, 0, NULL, - (void __user *)arg)); + RETURN(obd_iocontrol(cmd, sbi->ll_dt_exp, 0, NULL, uarg)); } } diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 3db2226..0828c33 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -1376,7 +1376,7 @@ static int ll_lease_close(struct obd_client_handle *och, struct inode *inode, * After lease is taken, send the RPC MDS_REINT_RESYNC to the MDT */ static int ll_lease_file_resync(struct obd_client_handle *och, - struct inode *inode, unsigned long arg) + struct inode *inode, void __user *uarg) { struct ll_sb_info *sbi = ll_i2sbi(inode); struct md_op_data *op_data; @@ -1390,8 +1390,7 @@ static int ll_lease_file_resync(struct obd_client_handle *och, if (IS_ERR(op_data)) RETURN(PTR_ERR(op_data)); - if (copy_from_user(&ioc, (struct ll_ioc_lease_id __user *)arg, - sizeof(ioc))) + if (copy_from_user(&ioc, uarg, sizeof(ioc))) RETURN(-EFAULT); /* before starting file resync, it's necessary to clean up page cache @@ -2625,10 +2624,10 @@ static int ll_file_getstripe(struct inode *inode, void __user *lum, size_t size) static int ll_lov_setstripe(struct inode *inode, struct file *file, void __user *arg) { - struct lov_user_md __user *lum = (struct lov_user_md __user *)arg; - struct lov_user_md *klum; - int lum_size, rc; - __u64 flags = FMODE_WRITE; + struct lov_user_md __user *lum = arg; + struct lov_user_md *klum; + int lum_size, rc; + __u64 flags = FMODE_WRITE; ENTRY; rc = ll_copy_user_md(lum, &klum); @@ -2687,8 +2686,9 @@ retry: if (file->f_flags & O_NONBLOCK) { if (!mutex_trylock(&lli->lli_group_mutex)) RETURN(-EAGAIN); - } else + } else { mutex_lock(&lli->lli_group_mutex); + } if (fd->fd_flags & LL_FILE_GROUP_LOCKED) { CWARN("group lock already existed with gid %lu\n", @@ -3730,21 +3730,18 @@ static int ll_lock_noexpand(struct file *file, int flags) } int ll_ioctl_fsgetxattr(struct inode *inode, unsigned int cmd, - unsigned long arg) + void __user *uarg) { struct fsxattr fsxattr; - if (copy_from_user(&fsxattr, - (const struct fsxattr __user *)arg, - sizeof(fsxattr))) + if (copy_from_user(&fsxattr, uarg, sizeof(fsxattr))) RETURN(-EFAULT); fsxattr.fsx_xflags = ll_inode_flags_to_xflags(inode->i_flags); if (test_bit(LLIF_PROJECT_INHERIT, &ll_i2info(inode)->lli_flags)) fsxattr.fsx_xflags |= FS_XFLAG_PROJINHERIT; fsxattr.fsx_projid = ll_i2info(inode)->lli_projid; - if (copy_to_user((struct fsxattr __user *)arg, - &fsxattr, sizeof(fsxattr))) + if (copy_to_user(uarg, &fsxattr, sizeof(fsxattr))) RETURN(-EFAULT); RETURN(0); @@ -3835,23 +3832,20 @@ out_fsxattr: } int ll_ioctl_fssetxattr(struct inode *inode, unsigned int cmd, - unsigned long arg) + void __user *uarg) { struct fsxattr fsxattr; ENTRY; - if (copy_from_user(&fsxattr, - (const struct fsxattr __user *)arg, - sizeof(fsxattr))) + if (copy_from_user(&fsxattr, uarg, sizeof(fsxattr))) RETURN(-EFAULT); RETURN(ll_set_project(inode, fsxattr.fsx_xflags, fsxattr.fsx_projid)); } -int ll_ioctl_project(struct file *file, unsigned int cmd, - unsigned long arg) +int ll_ioctl_project(struct file *file, unsigned int cmd, void __user *uarg) { struct lu_project lu_project; struct dentry *dentry = file_dentry(file); @@ -3859,9 +3853,7 @@ int ll_ioctl_project(struct file *file, unsigned int cmd, struct dentry *child_dentry = NULL; int rc = 0, name_len; - if (copy_from_user(&lu_project, - (const struct lu_project __user *)arg, - sizeof(lu_project))) + if (copy_from_user(&lu_project, uarg, sizeof(lu_project))) RETURN(-EFAULT); /* apply child dentry if name is valid */ @@ -3897,8 +3889,7 @@ int ll_ioctl_project(struct file *file, unsigned int cmd, &ll_i2info(inode)->lli_flags)) lu_project.project_xflags |= FS_XFLAG_PROJINHERIT; lu_project.project_id = ll_i2info(inode)->lli_projid; - if (copy_to_user((struct lu_project __user *)arg, - &lu_project, sizeof(lu_project))) { + if (copy_to_user(uarg, &lu_project, sizeof(lu_project))) { rc = -EFAULT; goto out; } @@ -3914,11 +3905,11 @@ out: } static long ll_file_unlock_lease(struct file *file, struct ll_ioc_lease *ioc, - unsigned long arg) + void __user *uarg) { - struct inode *inode = file_inode(file); - struct ll_file_data *fd = file->private_data; - struct ll_inode_info *lli = ll_i2info(inode); + struct inode *inode = file_inode(file); + struct ll_file_data *fd = file->private_data; + struct ll_inode_info *lli = ll_i2info(inode); struct obd_client_handle *och = NULL; struct split_param sp; struct pcc_param param; @@ -3956,18 +3947,17 @@ static long ll_file_unlock_lease(struct file *file, struct ll_ioc_lease *ioc, if (!data) GOTO(out_lease_close, rc = -ENOMEM); - if (copy_from_user(data, (void __user *)arg, data_size)) + if (copy_from_user(data, uarg, data_size)) GOTO(out_lease_close, rc = -EFAULT); bias = MDS_CLOSE_RESYNC_DONE; break; case LL_LEASE_LAYOUT_MERGE: { - if (ioc->lil_count != 1) GOTO(out_lease_close, rc = -EINVAL); - arg += sizeof(*ioc); - if (copy_from_user(&fdv, (void __user *)arg, sizeof(__u32))) + uarg += sizeof(*ioc); + if (copy_from_user(&fdv, uarg, sizeof(__u32))) GOTO(out_lease_close, rc = -EFAULT); layout_file = fget(fdv); @@ -3988,13 +3978,12 @@ static long ll_file_unlock_lease(struct file *file, struct ll_ioc_lease *ioc, if (ioc->lil_count != 2) GOTO(out_lease_close, rc = -EINVAL); - arg += sizeof(*ioc); - if (copy_from_user(&fdv, (void __user *)arg, sizeof(__u32))) + uarg += sizeof(*ioc); + if (copy_from_user(&fdv, uarg, sizeof(__u32))) GOTO(out_lease_close, rc = -EFAULT); - arg += sizeof(__u32); - if (copy_from_user(&mirror_id, (void __user *)arg, - sizeof(__u32))) + uarg += sizeof(__u32); + if (copy_from_user(&mirror_id, uarg, sizeof(__u32))) GOTO(out_lease_close, rc = -EFAULT); layout_file = fget(fdv); @@ -4015,9 +4004,8 @@ static long ll_file_unlock_lease(struct file *file, struct ll_ioc_lease *ioc, if (IS_ENCRYPTED(inode)) RETURN(-EOPNOTSUPP); - arg += sizeof(*ioc); - if (copy_from_user(¶m.pa_archive_id, (void __user *)arg, - sizeof(__u32))) + uarg += sizeof(*ioc); + if (copy_from_user(¶m.pa_archive_id, uarg, sizeof(__u32))) GOTO(out_lease_close, rc2 = -EFAULT); rc2 = pcc_readwrite_attach(file, inode, param.pa_archive_id); @@ -4076,7 +4064,7 @@ out: } static long ll_file_set_lease(struct file *file, struct ll_ioc_lease *ioc, - unsigned long arg) + void __user *uarg) { struct inode *inode = file_inode(file); struct ll_inode_info *lli = ll_i2info(inode); @@ -4100,7 +4088,7 @@ static long ll_file_set_lease(struct file *file, struct ll_ioc_lease *ioc, fmode = FMODE_READ; break; case LL_LEASE_UNLCK: - RETURN(ll_file_unlock_lease(file, ioc, arg)); + RETURN(ll_file_unlock_lease(file, ioc, uarg)); default: RETURN(-EINVAL); } @@ -4115,7 +4103,7 @@ static long ll_file_set_lease(struct file *file, struct ll_ioc_lease *ioc, RETURN(PTR_ERR(och)); if (ioc->lil_flags & LL_LEASE_RESYNC) { - rc = ll_lease_file_resync(och, inode, arg); + rc = ll_lease_file_resync(och, inode, uarg); if (rc) { ll_lease_close(och, inode, NULL); RETURN(rc); @@ -4180,9 +4168,10 @@ static int ll_heat_set(struct inode *inode, enum lu_heat_flag flags) static long ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { - struct inode *inode = file_inode(file); - struct ll_file_data *fd = file->private_data; - int flags, rc; + struct inode *inode = file_inode(file); + struct ll_file_data *fd = file->private_data; + void __user *uarg = (void __user *)arg; + int flags, rc; ENTRY; CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p), cmd=%x\n", @@ -4197,39 +4186,38 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case LL_IOC_GETFLAGS: /* Get the current value of the file flags */ return put_user(fd->fd_flags, (int __user *)arg); - case LL_IOC_SETFLAGS: - case LL_IOC_CLRFLAGS: - /* Set or clear specific file flags */ - /* XXX This probably needs checks to ensure the flags are - * not abused, and to handle any flag side effects. - */ - if (get_user(flags, (int __user *) arg)) - RETURN(-EFAULT); - - if (cmd == LL_IOC_SETFLAGS) { - if ((flags & LL_FILE_IGNORE_LOCK) && - !(file->f_flags & O_DIRECT)) { - CERROR("%s: unable to disable locking on " - "non-O_DIRECT file\n", current->comm); - RETURN(-EINVAL); - } - - fd->fd_flags |= flags; - } else { - fd->fd_flags &= ~flags; - } - RETURN(0); + case LL_IOC_SETFLAGS: + case LL_IOC_CLRFLAGS: + /* Set or clear specific file flags */ + /* XXX This probably needs checks to ensure the flags are + * not abused, and to handle any flag side effects. + */ + if (get_user(flags, (int __user *)arg)) + RETURN(-EFAULT); + + if (cmd == LL_IOC_SETFLAGS) { + if ((flags & LL_FILE_IGNORE_LOCK) && + !(file->f_flags & O_DIRECT)) { + CERROR("%s: unable to disable locking on " + "non-O_DIRECT file\n", current->comm); + RETURN(-EINVAL); + } + + fd->fd_flags |= flags; + } else { + fd->fd_flags &= ~flags; + } + RETURN(0); case LL_IOC_LOV_SETSTRIPE: case LL_IOC_LOV_SETSTRIPE_NEW: - RETURN(ll_lov_setstripe(inode, file, (void __user *)arg)); + RETURN(ll_lov_setstripe(inode, file, uarg)); case LL_IOC_LOV_SETEA: - RETURN(ll_lov_setea(inode, file, (void __user *)arg)); + RETURN(ll_lov_setea(inode, file, uarg)); case LL_IOC_LOV_SWAP_LAYOUTS: { struct file *file2; struct lustre_swap_layouts lsl; - if (copy_from_user(&lsl, (char __user *)arg, - sizeof(struct lustre_swap_layouts))) + if (copy_from_user(&lsl, uarg, sizeof(lsl))) RETURN(-EFAULT); if ((file->f_flags & O_ACCMODE) == O_RDONLY) @@ -4244,9 +4232,9 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) GOTO(out, rc = -EPERM); if (lsl.sl_flags & SWAP_LAYOUTS_CLOSE) { - struct inode *inode2; - struct ll_inode_info *lli; - struct obd_client_handle *och = NULL; + struct obd_client_handle *och = NULL; + struct ll_inode_info *lli; + struct inode *inode2; lli = ll_i2info(inode); mutex_lock(&lli->lli_och_mutex); @@ -4268,10 +4256,10 @@ out: } case LL_IOC_LOV_GETSTRIPE: case LL_IOC_LOV_GETSTRIPE_NEW: - RETURN(ll_file_getstripe(inode, (void __user *)arg, 0)); + RETURN(ll_file_getstripe(inode, uarg, 0)); case FS_IOC_GETFLAGS: case FS_IOC_SETFLAGS: - RETURN(ll_iocontrol(inode, file, cmd, arg)); + RETURN(ll_iocontrol(inode, file, cmd, uarg)); case FSFILT_IOC_GETVERSION: case FS_IOC_GETVERSION: RETURN(put_user(inode->i_generation, (int __user *)arg)); @@ -4281,64 +4269,63 @@ out: case FS_IOC_SETVERSION: RETURN(-ENOTSUPP); - case LL_IOC_GROUP_LOCK: - RETURN(ll_get_grouplock(inode, file, arg)); - case LL_IOC_GROUP_UNLOCK: - RETURN(ll_put_grouplock(inode, file, arg)); - case IOC_OBD_STATFS: - RETURN(ll_obd_statfs(inode, (void __user *)arg)); + case LL_IOC_GROUP_LOCK: + RETURN(ll_get_grouplock(inode, file, arg)); + case LL_IOC_GROUP_UNLOCK: + RETURN(ll_put_grouplock(inode, file, arg)); + case IOC_OBD_STATFS: + RETURN(ll_obd_statfs(inode, uarg)); case LL_IOC_FLUSHCTX: RETURN(ll_flush_ctx(inode)); case LL_IOC_PATH2FID: { - if (copy_to_user((void __user *)arg, ll_inode2fid(inode), + if (copy_to_user(uarg, ll_inode2fid(inode), sizeof(struct lu_fid))) RETURN(-EFAULT); RETURN(0); } case LL_IOC_GETPARENT: - RETURN(ll_getparent(file, (struct getparent __user *)arg)); + RETURN(ll_getparent(file, uarg)); case OBD_IOC_FID2PATH: - RETURN(ll_fid2path(inode, (void __user *)arg)); + RETURN(ll_fid2path(inode, uarg)); case LL_IOC_DATA_VERSION: { - struct ioc_data_version idv; + struct ioc_data_version idv; int rc; - if (copy_from_user(&idv, (char __user *)arg, sizeof(idv))) + if (copy_from_user(&idv, uarg, sizeof(idv))) RETURN(-EFAULT); idv.idv_flags &= LL_DV_RD_FLUSH | LL_DV_WR_FLUSH; rc = ll_ioc_data_version(inode, &idv); - if (rc == 0 && - copy_to_user((char __user *)arg, &idv, sizeof(idv))) + if (rc == 0 && copy_to_user(uarg, &idv, sizeof(idv))) RETURN(-EFAULT); RETURN(rc); } - case LL_IOC_GET_MDTIDX: { - int mdtidx; + case LL_IOC_GET_MDTIDX: { + int mdtidx; - mdtidx = ll_get_mdt_idx(inode); - if (mdtidx < 0) - RETURN(mdtidx); + mdtidx = ll_get_mdt_idx(inode); + if (mdtidx < 0) + RETURN(mdtidx); - if (put_user((int)mdtidx, (int __user *)arg)) - RETURN(-EFAULT); + if (put_user(mdtidx, (int __user *)arg)) + RETURN(-EFAULT); - RETURN(0); - } + RETURN(0); + } case OBD_IOC_GETNAME_OLD: case OBD_IOC_GETDTNAME: case OBD_IOC_GETMDNAME: - RETURN(ll_get_obd_name(inode, cmd, arg)); + RETURN(ll_get_obd_name(inode, cmd, uarg)); case LL_IOC_HSM_STATE_GET: { - struct md_op_data *op_data; - struct hsm_user_state *hus; - int rc; + struct md_op_data *op_data; + struct hsm_user_state *hus; + int rc; OBD_ALLOC_PTR(hus); if (hus == NULL) @@ -4354,7 +4341,7 @@ out: rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data), op_data, NULL); - if (copy_to_user((void __user *)arg, hus, sizeof(*hus))) + if (copy_to_user(uarg, hus, sizeof(*hus))) rc = -EFAULT; ll_finish_md_op_data(op_data); @@ -4362,14 +4349,14 @@ out: RETURN(rc); } case LL_IOC_HSM_STATE_SET: { - struct hsm_state_set *hss; - int rc; + struct hsm_state_set *hss; + int rc; OBD_ALLOC_PTR(hss); if (hss == NULL) RETURN(-ENOMEM); - if (copy_from_user(hss, (char __user *)arg, sizeof(*hss))) { + if (copy_from_user(hss, uarg, sizeof(*hss))) { OBD_FREE_PTR(hss); RETURN(-EFAULT); } @@ -4415,7 +4402,7 @@ out: hca->hca_location.offset, hca->hca_location.length); } - if (copy_to_user((char __user *)arg, hca, sizeof(*hca))) + if (copy_to_user(uarg, hca, sizeof(*hca))) rc = -EFAULT; skip_copy: ll_finish_md_op_data(op_data); @@ -4423,17 +4410,17 @@ skip_copy: RETURN(rc); } case LL_IOC_SET_LEASE_OLD: { - struct ll_ioc_lease ioc = { .lil_mode = (__u32)arg }; + struct ll_ioc_lease ioc = { .lil_mode = arg }; RETURN(ll_file_set_lease(file, &ioc, 0)); } case LL_IOC_SET_LEASE: { struct ll_ioc_lease ioc; - if (copy_from_user(&ioc, (void __user *)arg, sizeof(ioc))) + if (copy_from_user(&ioc, uarg, sizeof(ioc))) RETURN(-EFAULT); - RETURN(ll_file_set_lease(file, &ioc, arg)); + RETURN(ll_file_set_lease(file, &ioc, uarg)); } case LL_IOC_GET_LEASE: { struct ll_inode_info *lli = ll_i2info(inode); @@ -4465,7 +4452,7 @@ skip_copy: if (hui == NULL) RETURN(-ENOMEM); - if (copy_from_user(hui, (void __user *)arg, sizeof(*hui))) { + if (copy_from_user(hui, uarg, sizeof(*hui))) { OBD_FREE_PTR(hui); RETURN(-EFAULT); } @@ -4478,9 +4465,7 @@ skip_copy: case LL_IOC_FUTIMES_3: { struct ll_futimes_3 lfu; - if (copy_from_user(&lfu, - (const struct ll_futimes_3 __user *)arg, - sizeof(lfu))) + if (copy_from_user(&lfu, uarg, sizeof(lfu))) RETURN(-EFAULT); RETURN(ll_file_futimes_3(file, &lfu)); @@ -4493,7 +4478,7 @@ skip_copy: int alloc_size = sizeof(*k_ladvise_hdr); rc = 0; - u_ladvise_hdr = (void __user *)arg; + u_ladvise_hdr = uarg; OBD_ALLOC_PTR(k_ladvise_hdr); if (k_ladvise_hdr == NULL) RETURN(-ENOMEM); @@ -4569,15 +4554,15 @@ out_ladvise: if (!(file->f_flags & O_DIRECT)) RETURN(-EINVAL); - fd->fd_designated_mirror = (__u32)arg; + fd->fd_designated_mirror = arg; RETURN(0); } case FS_IOC_FSGETXATTR: - RETURN(ll_ioctl_fsgetxattr(inode, cmd, arg)); + RETURN(ll_ioctl_fsgetxattr(inode, cmd, uarg)); case FS_IOC_FSSETXATTR: - RETURN(ll_ioctl_fssetxattr(inode, cmd, arg)); + RETURN(ll_ioctl_fssetxattr(inode, cmd, uarg)); case LL_IOC_PROJECT: - RETURN(ll_ioctl_project(file, cmd, arg)); + RETURN(ll_ioctl_project(file, cmd, uarg)); case BLKSSZGET: RETURN(put_user(PAGE_SIZE, (int __user *)arg)); case LL_IOC_HEAT_GET: { @@ -4585,7 +4570,7 @@ out_ladvise: struct lu_heat *heat; int size; - if (copy_from_user(&uheat, (void __user *)arg, sizeof(uheat))) + if (copy_from_user(&uheat, uarg, sizeof(uheat))) RETURN(-EFAULT); if (uheat.lh_count > OBD_HEAT_COUNT) @@ -4598,14 +4583,14 @@ out_ladvise: heat->lh_count = uheat.lh_count; ll_heat_get(inode, heat); - rc = copy_to_user((char __user *)arg, heat, size); + rc = copy_to_user(uarg, heat, size); OBD_FREE(heat, size); RETURN(rc ? -EFAULT : 0); } case LL_IOC_HEAT_SET: { __u64 flags; - if (copy_from_user(&flags, (void __user *)arg, sizeof(flags))) + if (copy_from_user(&flags, uarg, sizeof(flags))) RETURN(-EFAULT); rc = ll_heat_set(inode, flags); @@ -4618,9 +4603,7 @@ out_ladvise: if (detach == NULL) RETURN(-ENOMEM); - if (copy_from_user(detach, - (const struct lu_pcc_detach __user *)arg, - sizeof(*detach))) + if (copy_from_user(detach, uarg, sizeof(*detach))) GOTO(out_detach_free, rc = -EFAULT); if (!S_ISREG(inode->i_mode)) @@ -4635,8 +4618,7 @@ out_detach_free: RETURN(rc); } case LL_IOC_PCC_STATE: { - struct lu_pcc_state __user *ustate = - (struct lu_pcc_state __user *)arg; + struct lu_pcc_state __user *ustate = uarg; struct lu_pcc_state *state; OBD_ALLOC_PTR(state); @@ -4661,28 +4643,27 @@ out_state: case LL_IOC_SET_ENCRYPTION_POLICY: if (!ll_sbi_has_encrypt(ll_i2sbi(inode))) return -EOPNOTSUPP; - return llcrypt_ioctl_set_policy(file, (const void __user *)arg); + return llcrypt_ioctl_set_policy(file, uarg); case LL_IOC_GET_ENCRYPTION_POLICY_EX: if (!ll_sbi_has_encrypt(ll_i2sbi(inode))) return -EOPNOTSUPP; - return llcrypt_ioctl_get_policy_ex(file, (void __user *)arg); + return llcrypt_ioctl_get_policy_ex(file, uarg); case LL_IOC_ADD_ENCRYPTION_KEY: if (!ll_sbi_has_encrypt(ll_i2sbi(inode))) return -EOPNOTSUPP; - return llcrypt_ioctl_add_key(file, (void __user *)arg); + return llcrypt_ioctl_add_key(file, uarg); case LL_IOC_REMOVE_ENCRYPTION_KEY: if (!ll_sbi_has_encrypt(ll_i2sbi(inode))) return -EOPNOTSUPP; - return llcrypt_ioctl_remove_key(file, (void __user *)arg); + return llcrypt_ioctl_remove_key(file, uarg); case LL_IOC_REMOVE_ENCRYPTION_KEY_ALL_USERS: if (!ll_sbi_has_encrypt(ll_i2sbi(inode))) return -EOPNOTSUPP; - return llcrypt_ioctl_remove_key_all_users(file, - (void __user *)arg); + return llcrypt_ioctl_remove_key_all_users(file, uarg); case LL_IOC_GET_ENCRYPTION_KEY_STATUS: if (!ll_sbi_has_encrypt(ll_i2sbi(inode))) return -EOPNOTSUPP; - return llcrypt_ioctl_get_key_status(file, (void __user *)arg); + return llcrypt_ioctl_get_key_status(file, uarg); #endif case LL_IOC_UNLOCK_FOREIGN: { @@ -4699,8 +4680,7 @@ out_state: } default: - RETURN(obd_iocontrol(cmd, ll_i2dtexp(inode), 0, NULL, - (void __user *)arg)); + RETURN(obd_iocontrol(cmd, ll_i2dtexp(inode), 0, NULL, uarg)); } } diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 6e76c82..6e8b5c6 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -1229,12 +1229,10 @@ int ll_inode_permission(struct user_namespace *mnt_userns, struct inode *inode, int mask); int ll_ioctl_check_project(struct inode *inode, __u32 xflags, __u32 projid); int ll_ioctl_fsgetxattr(struct inode *inode, unsigned int cmd, - unsigned long arg); + void __user *uarg); int ll_ioctl_fssetxattr(struct inode *inode, unsigned int cmd, - unsigned long arg); -int ll_ioctl_project(struct file *file, unsigned int cmd, - unsigned long arg); - + void __user *uarg); +int ll_ioctl_project(struct file *file, unsigned int cmd, void __user *uarg); int ll_lov_setstripe_ea_info(struct inode *inode, struct dentry *dentry, __u64 flags, struct lov_user_md *lum, int lum_size); @@ -1309,7 +1307,7 @@ int ll_read_inode2(struct inode *inode, void *opaque); void ll_truncate_inode_pages_final(struct inode *inode, struct cl_io *io); void ll_delete_inode(struct inode *inode); int ll_iocontrol(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg); + unsigned int cmd, void __user *uarg); int ll_flush_ctx(struct inode *inode); void ll_umount_begin(struct super_block *sb); int ll_remount_fs(struct super_block *sb, int *flags, char *data); @@ -1329,7 +1327,7 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data, __u32 mode, enum md_op_code opc, void *data); void ll_finish_md_op_data(struct md_op_data *op_data); -int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg); +int ll_get_obd_name(struct inode *inode, unsigned int cmd, void __user *arg); void ll_compute_rootsquash_state(struct ll_sb_info *sbi); ssize_t ll_copy_user_md(const struct lov_user_md __user *md, struct lov_user_md **kbuf); diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index cbe56d0..59613e5 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -2975,7 +2975,7 @@ void ll_delete_inode(struct inode *inode) } int ll_iocontrol(struct inode *inode, struct file *file, - unsigned int cmd, unsigned long arg) + unsigned int cmd, void __user *uarg) { struct ll_sb_info *sbi = ll_i2sbi(inode); struct ptlrpc_request *req = NULL; @@ -3014,7 +3014,7 @@ int ll_iocontrol(struct inode *inode, struct file *file, ptlrpc_req_finished(req); - RETURN(put_user(flags, (int __user *)arg)); + RETURN(put_user(flags, (int __user *)uarg)); } case FS_IOC_SETFLAGS: { struct iattr *attr; @@ -3022,7 +3022,7 @@ int ll_iocontrol(struct inode *inode, struct file *file, struct cl_object *obj; struct fsxattr fa = { 0 }; - if (get_user(flags, (int __user *)arg)) + if (get_user(flags, (int __user *)uarg)) RETURN(-EFAULT); fa.fsx_projid = ll_i2info(inode)->lli_projid; @@ -3366,7 +3366,7 @@ out: return rc; } -int ll_obd_statfs(struct inode *inode, void __user *arg) +int ll_obd_statfs(struct inode *inode, void __user *uarg) { struct ll_sb_info *sbi = NULL; struct obd_export *exp; @@ -3379,7 +3379,7 @@ int ll_obd_statfs(struct inode *inode, void __user *arg) if (!sbi) GOTO(out_statfs, rc = -EINVAL); - rc = obd_ioctl_getdata(&data, &len, arg); + rc = obd_ioctl_getdata(&data, &len, uarg); if (rc) GOTO(out_statfs, rc); @@ -3629,24 +3629,23 @@ int ll_show_options(struct seq_file *seq, struct dentry *dentry) /** * Get obd name by cmd, and copy out to user space */ -int ll_get_obd_name(struct inode *inode, unsigned int cmd, unsigned long arg) +int ll_get_obd_name(struct inode *inode, unsigned int cmd, void __user *uarg) { - struct ll_sb_info *sbi = ll_i2sbi(inode); - struct obd_device *obd; - ENTRY; + struct ll_sb_info *sbi = ll_i2sbi(inode); + struct obd_device *obd; + ENTRY; if (cmd == OBD_IOC_GETNAME_OLD || cmd == OBD_IOC_GETDTNAME) - obd = class_exp2obd(sbi->ll_dt_exp); - else if (cmd == OBD_IOC_GETMDNAME) - obd = class_exp2obd(sbi->ll_md_exp); - else - RETURN(-EINVAL); + obd = class_exp2obd(sbi->ll_dt_exp); + else if (cmd == OBD_IOC_GETMDNAME) + obd = class_exp2obd(sbi->ll_md_exp); + else + RETURN(-EINVAL); - if (!obd) - RETURN(-ENOENT); + if (!obd) + RETURN(-ENOENT); - if (copy_to_user((void __user *)arg, obd->obd_name, - strlen(obd->obd_name) + 1)) + if (copy_to_user(uarg, obd->obd_name, strlen(obd->obd_name) + 1)) RETURN(-EFAULT); RETURN(0); diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 9db9d2a..c10a8da 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -305,7 +305,7 @@ int obd_ioctl_getdata(struct obd_ioctl_data **datap, int *len, void __user *arg) } EXPORT_SYMBOL(obd_ioctl_getdata); -int class_handle_ioctl(unsigned int cmd, unsigned long arg) +int class_handle_ioctl(unsigned int cmd, void __user *uarg) { struct obd_ioctl_data *data; struct obd_device *obd = NULL; @@ -313,7 +313,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) ENTRY; CDEBUG(D_IOCTL, "cmd = %x\n", cmd); - if (obd_ioctl_getdata(&data, &len, (void __user *)arg)) { + if (obd_ioctl_getdata(&data, &len, uarg)) { CERROR("OBD ioctl: data error\n"); RETURN(-EINVAL); } @@ -363,27 +363,25 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) memcpy(data->ioc_bulk, LUSTRE_VERSION_STRING, strlen(LUSTRE_VERSION_STRING) + 1); - if (copy_to_user((void __user *)arg, data, len)) + if (copy_to_user(uarg, data, len)) err = -EFAULT; GOTO(out, err); } #endif - case OBD_IOC_NAME2DEV: { - /* Resolve a device name. This does not change the - * currently selected device. - */ - int dev; - - dev = class_resolve_dev_name(data->ioc_inllen1, - data->ioc_inlbuf1); - data->ioc_dev = dev; - if (dev < 0) - GOTO(out, err = -EINVAL); + case OBD_IOC_NAME2DEV: { + /* Resolve device name, does not change current selected dev */ + int dev; + + dev = class_resolve_dev_name(data->ioc_inllen1, + data->ioc_inlbuf1); + data->ioc_dev = dev; + if (dev < 0) + GOTO(out, err = -EINVAL); - if (copy_to_user((void __user *)arg, data, sizeof(*data))) - err = -EFAULT; - GOTO(out, err); - } + if (copy_to_user(uarg, data, sizeof(*data))) + err = -EFAULT; + GOTO(out, err); + } case OBD_IOC_UUID2DEV: { /* Resolve a device uuid. This does not change the @@ -411,12 +409,12 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) GOTO(out, err = -EINVAL); } - CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1, - dev); - if (copy_to_user((void __user *)arg, data, sizeof(*data))) - err = -EFAULT; - GOTO(out, err); - } + CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1, + dev); + if (copy_to_user(uarg, data, sizeof(*data))) + err = -EFAULT; + GOTO(out, err); + } case OBD_IOC_GETDEVICE: { int index = data->ioc_count; @@ -446,19 +444,18 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) else status = "--"; - str = (char *)data->ioc_bulk; - snprintf(str, len - sizeof(*data), "%3d %s %s %s %s %d", - (int)index, status, obd->obd_type->typ_name, - obd->obd_name, obd->obd_uuid.uuid, + str = data->ioc_bulk; + snprintf(str, len - sizeof(*data), "%3d %s %s %s %s %d", + index, status, obd->obd_type->typ_name, + obd->obd_name, obd->obd_uuid.uuid, atomic_read(&obd->obd_refcount)); - if (copy_to_user((void __user *)arg, data, len)) + if (copy_to_user(uarg, data, len)) err = -EFAULT; GOTO(out, err); - } - - } + } + } if (data->ioc_dev == OBD_DEV_BY_DEVNAME) { if (data->ioc_inllen4 <= 0 || data->ioc_inlbuf4 == NULL) @@ -488,7 +485,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) if (err) GOTO(out, err); - if (copy_to_user((void __user *)arg, data, len)) + if (copy_to_user(uarg, data, len)) err = -EFAULT; out: OBD_FREE_LARGE(data, len); @@ -509,7 +506,7 @@ static long obd_class_ioctl(struct file *filp, unsigned int cmd, if ((cmd & 0xffffff00) == ((int)'T') << 8) /* ignore all tty ioctls */ RETURN(err = -ENOTTY); - err = class_handle_ioctl(cmd, (unsigned long)arg); + err = class_handle_ioctl(cmd, (void __user *)arg); RETURN(err); } diff --git a/lustre/ofd/ofd_access_log.c b/lustre/ofd/ofd_access_log.c index a1db9b2..b2a5115 100644 --- a/lustre/ofd/ofd_access_log.c +++ b/lustre/ofd/ofd_access_log.c @@ -341,10 +341,9 @@ unsigned int oal_file_poll(struct file *filp, struct poll_table_struct *wait) return mask; } -static long oal_ioctl_info(struct oal_circ_buf *ocb, unsigned long arg) +static long oal_ioctl_info(struct oal_circ_buf *ocb, void __user *uarg) { struct ofd_access_log *oal = ocb->ocb_access_log; - struct lustre_access_log_info_v1 __user *lali; u32 entry_count = CIRC_CNT(ocb->ocb_circ.head, ocb->ocb_circ.tail, @@ -353,7 +352,7 @@ static long oal_ioctl_info(struct oal_circ_buf *ocb, unsigned long arg) ocb->ocb_circ.tail, oal->oal_log_size) / oal->oal_entry_size; - lali = (struct lustre_access_log_info_v1 __user *)arg; + lali = uarg; BUILD_BUG_ON(sizeof(lali->lali_name) != sizeof(oal->oal_name)); if (put_user(LUSTRE_ACCESS_LOG_VERSION_1, &lali->lali_version)) @@ -393,7 +392,7 @@ static long oal_ioctl_info(struct oal_circ_buf *ocb, unsigned long arg) } static long oal_file_ioctl(struct file *filp, unsigned int cmd, - unsigned long arg) + unsigned long arg) { struct oal_circ_buf *ocb = filp->private_data; @@ -401,7 +400,7 @@ static long oal_file_ioctl(struct file *filp, unsigned int cmd, case LUSTRE_ACCESS_LOG_IOCTL_VERSION: return LUSTRE_ACCESS_LOG_VERSION_1; case LUSTRE_ACCESS_LOG_IOCTL_INFO: - return oal_ioctl_info(ocb, arg); + return oal_ioctl_info(ocb, (void __user *)arg); case LUSTRE_ACCESS_LOG_IOCTL_FILTER: ocb->ocb_filter = arg; return 0; @@ -629,7 +628,7 @@ static unsigned int oal_control_file_poll(struct file *filp, poll_table *wait) } static long oal_control_file_ioctl(struct file *filp, unsigned int cmd, - unsigned long arg) + unsigned long arg) { struct oal_control_file *ccf = filp->private_data;