From: James Simmons Date: Thu, 7 May 2015 22:23:05 +0000 (-0400) Subject: LU-6302 lov: copy_to_user uses wrong casting X-Git-Tag: 2.7.55~42 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=99393dc16a663fcf028b49353333a24f1dd3bb1c;p=fs%2Flustre-release.git LU-6302 lov: copy_to_user uses wrong casting 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 Reviewed-on: http://review.whamcloud.com/14613 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: frank zago Reviewed-by: Dmitry Eremin Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index fcdfbca..bea5c2b 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -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;