Commit af00f6c5 authored by Oleg Drokin's avatar Oleg Drokin Committed by Greg Kroah-Hartman

staging/lustre/llite: Update ll_dir_ioctl pointer casts with __user

When casting unsingned long userspace pointer from ioctl argument to
a pointer suitable for use with userspace access functions, need
to remember to add __user attribute, to make sparse happy.
Signed-off-by: default avatarOleg Drokin <green@linuxhacker.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d47bb83b
...@@ -1253,7 +1253,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1253,7 +1253,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return ll_iocontrol(inode, file, cmd, arg); return ll_iocontrol(inode, file, cmd, arg);
case FSFILT_IOC_GETVERSION_OLD: case FSFILT_IOC_GETVERSION_OLD:
case FSFILT_IOC_GETVERSION: case FSFILT_IOC_GETVERSION:
return put_user(inode->i_generation, (int *)arg); return put_user(inode->i_generation, (int __user *)arg);
/* We need to special case any other ioctls we want to handle, /* We need to special case any other ioctls we want to handle,
* to send them to the MDS/OST as appropriate and to properly * to send them to the MDS/OST as appropriate and to properly
* network encode the arg field. * network encode the arg field.
...@@ -1267,7 +1267,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1267,7 +1267,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
if (mdtidx < 0) if (mdtidx < 0)
return mdtidx; return mdtidx;
if (put_user((int)mdtidx, (int *)arg)) if (put_user((int)mdtidx, (int __user *)arg))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -1364,8 +1364,8 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1364,8 +1364,8 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
case LL_IOC_LOV_SETSTRIPE: { case LL_IOC_LOV_SETSTRIPE: {
struct lov_user_md_v3 lumv3; struct lov_user_md_v3 lumv3;
struct lov_user_md_v1 *lumv1 = (struct lov_user_md_v1 *)&lumv3; struct lov_user_md_v1 *lumv1 = (struct lov_user_md_v1 *)&lumv3;
struct lov_user_md_v1 *lumv1p = (struct lov_user_md_v1 *)arg; struct lov_user_md_v1 __user *lumv1p = (void __user *)arg;
struct lov_user_md_v3 *lumv3p = (struct lov_user_md_v3 *)arg; struct lov_user_md_v3 __user *lumv3p = (void __user *)arg;
int set_default = 0; int set_default = 0;
...@@ -1390,7 +1390,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1390,7 +1390,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return rc; return rc;
} }
case LL_IOC_LMV_GETSTRIPE: { case LL_IOC_LMV_GETSTRIPE: {
struct lmv_user_md *lump = (struct lmv_user_md *)arg; struct lmv_user_md __user *lump = (void __user *)arg;
struct lmv_user_md lum; struct lmv_user_md lum;
struct lmv_user_md *tmp; struct lmv_user_md *tmp;
int lum_size; int lum_size;
...@@ -1423,7 +1423,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1423,7 +1423,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
tmp->lum_objects[0].lum_mds = mdtindex; tmp->lum_objects[0].lum_mds = mdtindex;
memcpy(&tmp->lum_objects[0].lum_fid, ll_inode2fid(inode), memcpy(&tmp->lum_objects[0].lum_fid, ll_inode2fid(inode),
sizeof(struct lu_fid)); sizeof(struct lu_fid));
if (copy_to_user((void *)arg, tmp, lum_size)) { if (copy_to_user((void __user *)arg, tmp, lum_size)) {
rc = -EFAULT; rc = -EFAULT;
goto free_lmv; goto free_lmv;
} }
...@@ -1440,7 +1440,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1440,7 +1440,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
case IOC_MDC_GETFILEINFO: case IOC_MDC_GETFILEINFO:
case IOC_MDC_GETFILESTRIPE: { case IOC_MDC_GETFILESTRIPE: {
struct ptlrpc_request *request = NULL; struct ptlrpc_request *request = NULL;
struct lov_user_md *lump; struct lov_user_md __user *lump;
struct lov_mds_md *lmm = NULL; struct lov_mds_md *lmm = NULL;
struct mdt_body *body; struct mdt_body *body;
char *filename = NULL; char *filename = NULL;
...@@ -1477,11 +1477,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1477,11 +1477,11 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
if (cmd == IOC_MDC_GETFILESTRIPE || if (cmd == IOC_MDC_GETFILESTRIPE ||
cmd == LL_IOC_LOV_GETSTRIPE) { cmd == LL_IOC_LOV_GETSTRIPE) {
lump = (struct lov_user_md *)arg; lump = (struct lov_user_md __user *)arg;
} else { } else {
struct lov_user_mds_data *lmdp; struct lov_user_mds_data __user *lmdp;
lmdp = (struct lov_user_mds_data *)arg; lmdp = (struct lov_user_mds_data __user *)arg;
lump = &lmdp->lmd_lmm; lump = &lmdp->lmd_lmm;
} }
if (copy_to_user(lump, lmm, lmmsize)) { if (copy_to_user(lump, lmm, lmmsize)) {
...@@ -1493,7 +1493,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1493,7 +1493,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
} }
skip_lmm: skip_lmm:
if (cmd == IOC_MDC_GETFILEINFO || cmd == LL_IOC_MDC_GETINFO) { if (cmd == IOC_MDC_GETFILEINFO || cmd == LL_IOC_MDC_GETINFO) {
struct lov_user_mds_data *lmdp; struct lov_user_mds_data __user *lmdp;
lstat_t st = { 0 }; lstat_t st = { 0 };
st.st_dev = inode->i_sb->s_dev; st.st_dev = inode->i_sb->s_dev;
...@@ -1510,7 +1510,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1510,7 +1510,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
st.st_ctime = body->ctime; st.st_ctime = body->ctime;
st.st_ino = inode->i_ino; st.st_ino = inode->i_ino;
lmdp = (struct lov_user_mds_data *)arg; lmdp = (struct lov_user_mds_data __user *)arg;
if (copy_to_user(&lmdp->lmd_st, &st, sizeof(st))) { if (copy_to_user(&lmdp->lmd_st, &st, sizeof(st))) {
rc = -EFAULT; rc = -EFAULT;
goto out_req; goto out_req;
...@@ -1524,14 +1524,14 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1524,14 +1524,14 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return rc; return rc;
} }
case IOC_LOV_GETINFO: { case IOC_LOV_GETINFO: {
struct lov_user_mds_data *lumd; struct lov_user_mds_data __user *lumd;
struct lov_stripe_md *lsm; struct lov_stripe_md *lsm;
struct lov_user_md *lum; struct lov_user_md __user *lum;
struct lov_mds_md *lmm; struct lov_mds_md *lmm;
int lmmsize; int lmmsize;
lstat_t st; lstat_t st;
lumd = (struct lov_user_mds_data *)arg; lumd = (struct lov_user_mds_data __user *)arg;
lum = &lumd->lmd_lmm; lum = &lumd->lmd_lmm;
rc = ll_get_max_mdsize(sbi, &lmmsize); rc = ll_get_max_mdsize(sbi, &lmmsize);
...@@ -1637,7 +1637,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1637,7 +1637,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
NULL); NULL);
if (rc) { if (rc) {
CDEBUG(D_QUOTA, "mdc ioctl %d failed: %d\n", cmd, rc); CDEBUG(D_QUOTA, "mdc ioctl %d failed: %d\n", cmd, rc);
if (copy_to_user((void *)arg, check, if (copy_to_user((void __user *)arg, check,
sizeof(*check))) sizeof(*check)))
CDEBUG(D_QUOTA, "copy_to_user failed\n"); CDEBUG(D_QUOTA, "copy_to_user failed\n");
goto out_poll; goto out_poll;
...@@ -1647,7 +1647,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1647,7 +1647,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
NULL); NULL);
if (rc) { if (rc) {
CDEBUG(D_QUOTA, "osc ioctl %d failed: %d\n", cmd, rc); CDEBUG(D_QUOTA, "osc ioctl %d failed: %d\n", cmd, rc);
if (copy_to_user((void *)arg, check, if (copy_to_user((void __user *)arg, check,
sizeof(*check))) sizeof(*check)))
CDEBUG(D_QUOTA, "copy_to_user failed\n"); CDEBUG(D_QUOTA, "copy_to_user failed\n");
goto out_poll; goto out_poll;
...@@ -1663,14 +1663,15 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1663,14 +1663,15 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
if (!qctl) if (!qctl)
return -ENOMEM; return -ENOMEM;
if (copy_from_user(qctl, (void *)arg, sizeof(*qctl))) { if (copy_from_user(qctl, (void __user *)arg, sizeof(*qctl))) {
rc = -EFAULT; rc = -EFAULT;
goto out_quotactl; goto out_quotactl;
} }
rc = quotactl_ioctl(sbi, qctl); rc = quotactl_ioctl(sbi, qctl);
if (rc == 0 && copy_to_user((void *)arg, qctl, sizeof(*qctl))) if (rc == 0 && copy_to_user((void __user *)arg, qctl,
sizeof(*qctl)))
rc = -EFAULT; rc = -EFAULT;
out_quotactl: out_quotactl:
...@@ -1700,7 +1701,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1700,7 +1701,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
int count, vallen; int count, vallen;
struct obd_export *exp; struct obd_export *exp;
if (copy_from_user(&count, (int *)arg, sizeof(int))) if (copy_from_user(&count, (int __user *)arg, sizeof(int)))
return -EFAULT; return -EFAULT;
/* get ost count when count is zero, get mdt count otherwise */ /* get ost count when count is zero, get mdt count otherwise */
...@@ -1713,13 +1714,13 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1713,13 +1714,13 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return rc; return rc;
} }
if (copy_to_user((int *)arg, &count, sizeof(int))) if (copy_to_user((int __user *)arg, &count, sizeof(int)))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
case LL_IOC_PATH2FID: case LL_IOC_PATH2FID:
if (copy_to_user((void *)arg, ll_inode2fid(inode), if (copy_to_user((void __user *)arg, ll_inode2fid(inode),
sizeof(struct lu_fid))) sizeof(struct lu_fid)))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -1732,7 +1733,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1732,7 +1733,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
if (!capable(CFS_CAP_SYS_ADMIN)) if (!capable(CFS_CAP_SYS_ADMIN))
return -EPERM; return -EPERM;
rc = copy_and_ioctl(cmd, sbi->ll_md_exp, (void *)arg, rc = copy_and_ioctl(cmd, sbi->ll_md_exp, (void __user *)arg,
sizeof(struct ioc_changelog)); sizeof(struct ioc_changelog));
return rc; return rc;
case OBD_IOC_FID2PATH: case OBD_IOC_FID2PATH:
...@@ -1741,7 +1742,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1741,7 +1742,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct hsm_user_request *hur; struct hsm_user_request *hur;
ssize_t totalsize; ssize_t totalsize;
hur = memdup_user((void *)arg, sizeof(*hur)); hur = memdup_user((void __user *)arg, sizeof(*hur));
if (IS_ERR(hur)) if (IS_ERR(hur))
return PTR_ERR(hur); return PTR_ERR(hur);
...@@ -1760,7 +1761,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1760,7 +1761,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return -ENOMEM; return -ENOMEM;
/* Copy the whole struct */ /* Copy the whole struct */
if (copy_from_user(hur, (void *)arg, totalsize)) { if (copy_from_user(hur, (void __user *)arg, totalsize)) {
kvfree(hur); kvfree(hur);
return -EFAULT; return -EFAULT;
} }
...@@ -1796,7 +1797,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1796,7 +1797,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct hsm_progress_kernel hpk; struct hsm_progress_kernel hpk;
struct hsm_progress hp; struct hsm_progress hp;
if (copy_from_user(&hp, (void *)arg, sizeof(hp))) if (copy_from_user(&hp, (void __user *)arg, sizeof(hp)))
return -EFAULT; return -EFAULT;
hpk.hpk_fid = hp.hp_fid; hpk.hpk_fid = hp.hp_fid;
...@@ -1813,7 +1814,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1813,7 +1814,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return rc; return rc;
} }
case LL_IOC_HSM_CT_START: case LL_IOC_HSM_CT_START:
rc = copy_and_ioctl(cmd, sbi->ll_md_exp, (void *)arg, rc = copy_and_ioctl(cmd, sbi->ll_md_exp, (void __user *)arg,
sizeof(struct lustre_kernelcomm)); sizeof(struct lustre_kernelcomm));
return rc; return rc;
...@@ -1821,12 +1822,12 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1821,12 +1822,12 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct hsm_copy *copy; struct hsm_copy *copy;
int rc; int rc;
copy = memdup_user((char *)arg, sizeof(*copy)); copy = memdup_user((char __user *)arg, sizeof(*copy));
if (IS_ERR(copy)) if (IS_ERR(copy))
return PTR_ERR(copy); return PTR_ERR(copy);
rc = ll_ioc_copy_start(inode->i_sb, copy); rc = ll_ioc_copy_start(inode->i_sb, copy);
if (copy_to_user((char *)arg, copy, sizeof(*copy))) if (copy_to_user((char __user *)arg, copy, sizeof(*copy)))
rc = -EFAULT; rc = -EFAULT;
kfree(copy); kfree(copy);
...@@ -1836,12 +1837,12 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -1836,12 +1837,12 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct hsm_copy *copy; struct hsm_copy *copy;
int rc; int rc;
copy = memdup_user((char *)arg, sizeof(*copy)); copy = memdup_user((char __user *)arg, sizeof(*copy));
if (IS_ERR(copy)) if (IS_ERR(copy))
return PTR_ERR(copy); return PTR_ERR(copy);
rc = ll_ioc_copy_end(inode->i_sb, copy); rc = ll_ioc_copy_end(inode->i_sb, copy);
if (copy_to_user((char *)arg, copy, sizeof(*copy))) if (copy_to_user((char __user *)arg, copy, sizeof(*copy)))
rc = -EFAULT; rc = -EFAULT;
kfree(copy); kfree(copy);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment