From 99393dc16a663fcf028b49353333a24f1dd3bb1c Mon Sep 17 00:00:00 2001 From: James Simmons Date: Thu, 7 May 2015 18:23:05 -0400 Subject: [PATCH 1/1] 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 --- lustre/lov/lov_obd.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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; -- 1.8.3.1