Whamcloud - gitweb
LU-6302 lov: copy_to_user uses wrong casting 13/14613/6
authorJames Simmons <uja.ornl@yahoo.com>
Thu, 7 May 2015 22:23:05 +0000 (18:23 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 28 May 2015 22:28:18 +0000 (22:28 +0000)
While testing on newer kernels lov_obd.c failes to compile
with the following warning.

In function copy_to_user,
inlined from lov_iocontrol at
lustre-2.7.52/lustre/lov/lov_obd.c:1168:
./arch/x86/include/asm/uaccess.h:735: error: call to
__copy_to_user_overflow declared with attribute warning:
copy_to_user() buffer size is not probably correct

In lov_iocontrol the data was being casted to int instead
of the required unsigned long. This patch changes the cast
to what is needed for copy_to_user.

Change-Id: I75b9f4f935d57dc3df56a2c0869c7d2506217d39
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: http://review.whamcloud.com/14613
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: frank zago <fzago@cray.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lov/lov_obd.c

index fcdfbca..bea5c2b 100644 (file)
@@ -1141,9 +1141,9 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 
                 /* copy UUID */
                if (copy_to_user(data->ioc_pbuf2, obd2cli_tgt(osc_obd),
-                                min((int)data->ioc_plen2,
-                                    (int)sizeof(struct obd_uuid))))
-                        RETURN(-EFAULT);
+                                min_t(unsigned long, data->ioc_plen2,
+                                      sizeof(struct obd_uuid))))
+                       RETURN(-EFAULT);
 
                flags = uarg ? *(__u32 __user *)uarg : 0;
                 /* got statfs data */
@@ -1153,10 +1153,10 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                 if (rc)
                         RETURN(rc);
                if (copy_to_user(data->ioc_pbuf1, &stat_buf,
-                                     min((int) data->ioc_plen1,
-                                         (int) sizeof(stat_buf))))
-                        RETURN(-EFAULT);
-                break;
+                                min_t(unsigned long, data->ioc_plen1,
+                                      sizeof(struct obd_statfs))))
+                       RETURN(-EFAULT);
+               break;
         }
         case OBD_IOC_LOV_GET_CONFIG: {
                 struct obd_ioctl_data *data;