From 13e11c1ed85b611ac8d51cf37be35d025d6fb6a1 Mon Sep 17 00:00:00 2001 From: frank zago Date: Fri, 29 Aug 2014 18:49:15 -0500 Subject: [PATCH] LU-5396 obd: add sparse annotation __user wherever needed This fixes sparse warnings such as: .../api-ni.c:1639:33: warning: incorrect type in argument 3 (different address spaces) .../api-ni.c:1639:33: expected struct lnet_process_id_t [noderef] [usertype] *ids .../api-ni.c:1639:33: got struct lnet_process_id_t [usertype] * There is no code change. Change-Id: I9040163eedf5ee89be58d78aa7c8d374ed22b981 Signed-off-by: frank zago Reviewed-on: http://review.whamcloud.com/11821 Reviewed-by: Bob Glossman Reviewed-by: Dmitry Eremin Reviewed-by: James Simmons Reviewed-by: John L. Hammond Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/include/lustre_ioctl.h | 4 ++-- lustre/include/obd.h | 2 +- lustre/include/obd_class.h | 2 +- lustre/obdclass/class_obd.c | 14 ++++++++------ lustre/obdclass/linux/linux-module.c | 8 ++++---- lustre/obdecho/echo_client.c | 6 +++--- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/lustre/include/lustre_ioctl.h b/lustre/include/lustre_ioctl.h index 5263e2d..8dbfc8f 100644 --- a/lustre/include/lustre_ioctl.h +++ b/lustre/include/lustre_ioctl.h @@ -202,8 +202,8 @@ static inline int obd_ioctl_is_invalid(struct obd_ioctl_data *data) #ifdef __KERNEL__ -int obd_ioctl_getdata(char **buf, int *len, void *arg); -int obd_ioctl_popdata(void *arg, void *data, int len); +int obd_ioctl_getdata(char **buf, int *len, void __user *arg); +int obd_ioctl_popdata(void __user *arg, void *data, int len); static inline void obd_ioctl_freedata(char *buf, size_t len) { diff --git a/lustre/include/obd.h b/lustre/include/obd.h index b05c726..d28701d 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -878,7 +878,7 @@ struct md_enqueue_info { struct obd_ops { struct module *o_owner; int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len, - void *karg, void *uarg); + void *karg, void __user *uarg); int (*o_get_info)(const struct lu_env *env, struct obd_export *, __u32 keylen, void *key, __u32 *vallen, void *val, struct lov_stripe_md *lsm); diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 71269f6..60cfae5 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -1260,7 +1260,7 @@ static inline int obd_commitrw(const struct lu_env *env, int cmd, } static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp, - int len, void *karg, void *uarg) + int len, void *karg, void __user *uarg) { int rc; ENTRY; diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 0f35a6b1..addd5e5 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -237,7 +237,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) } CDEBUG(D_IOCTL, "cmd = %x\n", cmd); - if (obd_ioctl_getdata(&buf, &len, (void *)arg)) { + if (obd_ioctl_getdata(&buf, &len, (void __user *)arg)) { CERROR("OBD ioctl: data error\n"); RETURN(-EINVAL); } @@ -279,7 +279,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) memcpy(data->ioc_bulk, BUILD_VERSION, strlen(BUILD_VERSION) + 1); - err = obd_ioctl_popdata((void *)arg, data, len); + err = obd_ioctl_popdata((void __user *)arg, data, len); if (err) err = -EFAULT; GOTO(out, err); @@ -296,7 +296,8 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) if (dev < 0) GOTO(out, err = -EINVAL); - err = obd_ioctl_popdata((void *)arg, data, sizeof(*data)); + err = obd_ioctl_popdata((void __user *)arg, data, + sizeof(*data)); if (err) err = -EFAULT; GOTO(out, err); @@ -330,7 +331,8 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) CDEBUG(D_IOCTL, "device name %s, dev %d\n", data->ioc_inlbuf1, dev); - err = obd_ioctl_popdata((void *)arg, data, sizeof(*data)); + err = obd_ioctl_popdata((void __user *)arg, data, + sizeof(*data)); if (err) err = -EFAULT; GOTO(out, err); @@ -366,7 +368,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) (int)index, status, obd->obd_type->typ_name, obd->obd_name, obd->obd_uuid.uuid, atomic_read(&obd->obd_refcount)); - err = obd_ioctl_popdata((void *)arg, data, len); + err = obd_ioctl_popdata((void __user *)arg, data, len); GOTO(out, err = 0); } @@ -414,7 +416,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) if (err) GOTO(out, err); - err = obd_ioctl_popdata((void *)arg, data, len); + err = obd_ioctl_popdata((void __user *)arg, data, len); if (err) err = -EFAULT; GOTO(out, err); diff --git a/lustre/obdclass/linux/linux-module.c b/lustre/obdclass/linux/linux-module.c index 56ee26c..b8b86de 100644 --- a/lustre/obdclass/linux/linux-module.c +++ b/lustre/obdclass/linux/linux-module.c @@ -78,7 +78,7 @@ int proc_version; /* buffer MUST be at least the size of obd_ioctl_hdr */ -int obd_ioctl_getdata(char **buf, int *len, void *arg) +int obd_ioctl_getdata(char **buf, int *len, void __user *arg) { struct obd_ioctl_hdr hdr; struct obd_ioctl_data *data; @@ -86,7 +86,7 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) int offset = 0; ENTRY; - err = copy_from_user(&hdr, (void *)arg, sizeof(hdr)); + err = copy_from_user(&hdr, arg, sizeof(hdr)); if ( err ) RETURN(err); @@ -120,7 +120,7 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) *len = hdr.ioc_len; data = (struct obd_ioctl_data *)*buf; - err = copy_from_user(*buf, (void *)arg, hdr.ioc_len); + err = copy_from_user(*buf, arg, hdr.ioc_len); if ( err ) { OBD_FREE_LARGE(*buf, hdr.ioc_len); RETURN(err); @@ -156,7 +156,7 @@ int obd_ioctl_getdata(char **buf, int *len, void *arg) } EXPORT_SYMBOL(obd_ioctl_getdata); -int obd_ioctl_popdata(void *arg, void *data, int len) +int obd_ioctl_popdata(void __user *arg, void *data, int len) { int err; diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index 638a216..53ffaa2 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -1335,7 +1335,7 @@ static obd_id last_object_id; static int echo_copyin_lsm (struct echo_device *ed, struct lov_stripe_md *lsm, - void *ulsm, int ulsm_nob) + void __user *ulsm, int ulsm_nob) { struct echo_client_obd *ec = ed->ed_ec; int i; @@ -2158,8 +2158,8 @@ out_env: #endif /* HAVE_SERVER_SUPPORT */ static int echo_create_object(const struct lu_env *env, struct echo_device *ed, - int on_target, struct obdo *oa, void *ulsm, - int ulsm_nob, struct obd_trans_info *oti) + int on_target, struct obdo *oa, void __user *ulsm, + int ulsm_nob, struct obd_trans_info *oti) { struct echo_object *eco; struct echo_client_obd *ec = ed->ed_ec; -- 1.8.3.1