Skip to contentSkip to conversation

staging: lustre: llite: dir: Add __user annotations

PATCH In review Amitoj Kaur Chawla 2 participants 2 messages Oct 30, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: lustre: llite: dir: Add __user annotations

This patch fixes the following multiple sparse warnings by adding __user annotations in multiple places including struct declarations:

warning: incorrect type in argument 2 (different address spaces) expected void const [noderef] <asn:1>*from got struct lov_user_md_v3

warning: incorrect type in argument 2 (different address spaces) expected void const [noderef] <asn:1>*from got struct lov_user_md_v1

warning: incorrect type in argument 2 (different address spaces) expected void const [noderef] <asn:1>*from got struct lov_user_md

warning: incorrect type in argument 2 (different address spaces) expected void const [noderef] <asn:1>*from got const char

warning: incorrect type in argument 1 (different address spaces) expected void const [noderef] <asn:1>*to got struct lov_user_md_v

---
Note:
This patch is in continuation to a previous patch that fixed sparse warnings in this file. Now, this file does not give any further sparse warnings.

 drivers/staging/lustre/lustre/llite/dir.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)
drivers/staging/lustre/lustre/llite/dir.c +17 -14
index 6a20e61..72900ea 100644
@@ -1370,8 +1370,10 @@ lmv_out_free:
 	case LL_IOC_LOV_SETSTRIPE: {
 		struct lov_user_md_v3 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_v3 *lumv3p = (struct lov_user_md_v3 *)arg;
+		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;
 
 		int set_default = 0;
 
@@ -1396,7 +1398,8 @@ lmv_out_free:
 		return rc;
 	}
 	case LL_IOC_LMV_GETSTRIPE: {
-		struct lmv_user_md *lump = (struct lmv_user_md *)arg;
+		struct lmv_user_md __user *lump =
+					(struct lmv_user_md __user *)arg;
 		struct lmv_user_md lum;
 		struct lmv_user_md *tmp;
 		int lum_size;
@@ -1446,7 +1449,7 @@ free_lmv:
 	case IOC_MDC_GETFILEINFO:
 	case IOC_MDC_GETFILESTRIPE: {
 		struct ptlrpc_request *request = NULL;
-		struct lov_user_md *lump;
+		struct lov_user_md __user *lump;
 		struct lov_mds_md *lmm = NULL;
 		struct mdt_body *body;
 		char *filename = NULL;
@@ -1454,7 +1457,7 @@ free_lmv:
 
 		if (cmd == IOC_MDC_GETFILEINFO ||
 		    cmd == IOC_MDC_GETFILESTRIPE) {
-			filename = ll_getname((const char *)arg);
+			filename = ll_getname((const char __user *)arg);
 			if (IS_ERR(filename))
 				return PTR_ERR(filename);
 
@@ -1483,11 +1486,11 @@ free_lmv:
 
 		if (cmd == IOC_MDC_GETFILESTRIPE ||
 		    cmd == LL_IOC_LOV_GETSTRIPE) {
-			lump = (struct lov_user_md *)arg;
+			lump = (struct lov_user_md __user *)arg;
 		} 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;
 		}
 		if (copy_to_user(lump, lmm, lmmsize)) {
@@ -1499,7 +1502,7 @@ free_lmv:
 		}
 skip_lmm:
 		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 };
 
 			st.st_dev     = inode->i_sb->s_dev;
@@ -1516,7 +1519,7 @@ skip_lmm:
 			st.st_ctime   = body->ctime;
 			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))) {
 				rc = -EFAULT;
 				goto out_req;
@@ -1530,14 +1533,14 @@ out_req:
 		return rc;
 	}
 	case IOC_LOV_GETINFO: {
-		struct lov_user_mds_data *lumd;
+		struct lov_user_mds_data __user *lumd;
 		struct lov_stripe_md *lsm;
-		struct lov_user_md *lum;
+		struct lov_user_md __user *lum;
 		struct lov_mds_md *lmm;
 		int lmmsize;
 		lstat_t st;
 
-		lumd = (struct lov_user_mds_data *)arg;
+		lumd = (struct lov_user_mds_data __user *)arg;
 		lum = &lumd->lmd_lmm;
 
 		rc = ll_get_max_mdsize(sbi, &lmmsize);
@@ -1818,7 +1821,7 @@ out_quotactl:
 		return rc;
 	}
 	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));
 		return rc;
 
Signature · 1 line
1.9.1
#1 lore raw

drivers/staging/lustre/lustre/llite/dir.c lmv_out_free: · line 1376

Quoted 11 lines · On Saturday 31 October 2015 00:42:14 Amitoj Kaur Chawla wrote:
        case LL_IOC_LOV_SETSTRIPE: {
                struct lov_user_md_v3 lumv3;
                struct lov_user_md_v1 *lumv1 = (struct lov_user_md_v1 *)&lumv3;
drivers/staging/lustre/lustre/llite/dir.c +4 -2
-               struct lov_user_md_v1 *lumv1p = (struct lov_user_md_v1 *)arg;
-               struct lov_user_md_v3 *lumv3p = (struct lov_user_md_v3 *)arg;
+               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;

A nicer way to do this is to only have a single cast at the start of the function, like

	void __iomem *argp = (void __iomem *)arg;

and then using normal assignments from that to the specific structures.

Arnd