staging: lustre: llite: Add __user annotations
PATCH v2 1/1 staging: lustre: llite: Add __user annotations
This patch fixes the following multiple sparse warnings by adding __user annotations:
warning: incorrect type in argument 1 (different address spaces) expected void [noderef] <asn:1>*to got char *<noident>
warning: incorrect type in argument 1 (different address spaces) expected void [noderef] <asn:1>*to got int *<noident>
warning: incorrect type in argument 1 (different address spaces) expected void [noderef] <asn:1>*to got void *<noident>
---
Changes in v2:
-Fixed commit message
drivers/staging/lustre/lustre/llite/file.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/staging/lustre/lustre/llite/file.c +8 -8
@@ -2245,7 +2245,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)struct file *file2;struct lustre_swap_layouts lsl; -if (copy_from_user (&lsl, (char *)arg, +if (copy_from_user (&lsl, (char __user *)arg,sizeof (struct lustre_swap_layouts )))return -EFAULT ;
@@ -2292,7 +2292,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case LL_IOC_FLUSHCTX :return ll_flush_ctx (inode);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 )))return -EFAULT ;
@@ -2304,13 +2304,13 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)struct ioc_data_version idv;int rc; -if (copy_from_user (&idv, (char *)arg,sizeof (idv))) +if (copy_from_user (&idv, (char __user *)arg,sizeof (idv)))return -EFAULT ; rc =ll_data_version (inode, &idv.idv_version, !(idv.idv_flags &LL_DV_NOFLUSH )); -if (rc ==0 &©_to_user ((char *) arg, &idv,sizeof (idv))) +if (rc ==0 &©_to_user ((char __user *) arg, &idv,sizeof (idv)))return -EFAULT ;return rc;
@@ -2323,7 +2323,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)if (mdtidx <0 )return mdtidx; -if (put_user ((int )mdtidx, (int *)arg)) +if (put_user ((int )mdtidx, (int __user *)arg))return -EFAULT ;return 0 ;
@@ -2350,7 +2350,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc =obd_iocontrol (cmd,ll_i2mdexp (inode),sizeof (*op_data), op_data,NULL ); -if (copy_to_user ((void *)arg, hus,sizeof (*hus))) +if (copy_to_user ((void __user *)arg, hus,sizeof (*hus))) rc = -EFAULT ;ll_finish_md_op_data (op_data);
@@ -2361,7 +2361,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)struct hsm_state_set *hss;int rc; - hss =memdup_user ((char *)arg,sizeof (*hss)); + hss =memdup_user ((char __user *)arg,sizeof (*hss));if (IS_ERR (hss))return PTR_ERR (hss);
@@ -2389,7 +2389,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc =obd_iocontrol (cmd,ll_i2mdexp (inode),sizeof (*op_data), op_data,NULL ); -if (copy_to_user ((char *)arg, hca,sizeof (*hca))) +if (copy_to_user ((char __user *)arg, hca,sizeof (*hca))) rc = -EFAULT ;ll_finish_md_op_data (op_data);
Signature · 1 line
1.9.1
drivers/staging/lustre/lustre/llite/file.c ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 2251
Quoted 10 lines · On Friday 30 October 2015 21:56:58 Amitoj Kaur Chawla wrote:
drivers/staging/lustre/lustre/llite/file.c +1
-1@@ -2245,7 +2245,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)struct file *file2;struct lustre_swap_layouts lsl; -if (copy_from_user (&lsl, (char *)arg, +if (copy_from_user (&lsl, (char __user *)arg,sizeof (struct lustre_swap_layouts )))return -EFAULT ;
The same comment that I made for "staging: lustre: llite: dir: Add __user annotations" also applies here: when you add a temporary variable at the start of the function, you can replace all those casts from arg to various function calls with just one cast.
Arnd
Quoted 17 lines · Arnd Bergmann
drivers/staging/lustre/lustre/llite/file.c ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) · line 2251
Quoted 10 lines · On Friday 30 October 2015 21:56:58 Amitoj Kaur Chawla wrote:
drivers/staging/lustre/lustre/llite/file.c +1
-1@@ -2245,7 +2245,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)struct file *file2;struct lustre_swap_layouts lsl; -if (copy_from_user (&lsl, (char *)arg, +if (copy_from_user (&lsl, (char __user *)arg,sizeof (struct lustre_swap_layouts )))return -EFAULT ;The same comment that I made for "staging: lustre: llite: dir: Add
__userannotations" also applies here: when you add a temporary variable at the start of the function, you can replace all those casts from arg to various function calls with just one cast.
Quoted 1 line
Arnd
Okay, then I'll redo the whole thing and send it as one patch.
Signature · 1 line
Amitoj