From mboxrd@z Thu Jan 1 00:00:00 1970 From: Harsh Bora Subject: Re: [PATCH] Typecasting required for comparing unlike datatypes Date: Fri, 10 Dec 2010 14:01:49 +0530 Message-ID: <4D01E575.1000909@linux.vnet.ibm.com> References: <1291812900-18311-1-git-send-email-harsh@linux.vnet.ibm.com> <20101210171851.8f83f485.kamezawa.hiroyu@jp.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org, fengguang.wu@intel.com, aneesh.kumar@linux.vnet.ibm.com, jvrao@linux.vnet.ibm.com, "M. Mohan Kumar" To: KAMEZAWA Hiroyuki Return-path: Received: from e23smtp06.au.ibm.com ([202.81.31.148]:47978 "EHLO e23smtp06.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754579Ab0LJIby (ORCPT ); Fri, 10 Dec 2010 03:31:54 -0500 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [202.81.31.246]) by e23smtp06.au.ibm.com (8.14.4/8.13.1) with ESMTP id oBA8VgDa031913 for ; Fri, 10 Dec 2010 19:31:42 +1100 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oBA8VqrH1736876 for ; Fri, 10 Dec 2010 19:31:52 +1100 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id oBA8VqaN010210 for ; Fri, 10 Dec 2010 19:31:52 +1100 In-Reply-To: <20101210171851.8f83f485.kamezawa.hiroyu@jp.fujitsu.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On 12/10/2010 01:48 PM, KAMEZAWA Hiroyuki wrote: > On Wed, 8 Dec 2010 18:25:00 +0530 > Harsh Prateek Bora wrote: > >> The existing code causes the if condition to pass when it should fail >> on a *64-bit kernel* because of implicit data type conversions. It can >> be observed by passing pos = -1 and count = some positive number. >> This results in function returning EOVERFLOW instead of EINVAL. >> >> With this patch, the function returns EINVAL when pos is -1 and count >> is a positive number. This can be tested by calling sendfile with >> offset = -1 and count = some positive number on a 64-bit kernel. >> >> Signed-off-by: Harsh Prateek Bora > > Acked-by: KAMEZAWA Hiroyuki > > I'm sorry for annoying you. > Oh, but I am not annoyed, .. Thanks for the ack though ! :) >> --- >> fs/read_write.c | 2 +- >> 1 files changed, 1 insertions(+), 1 deletions(-) >> >> diff --git a/fs/read_write.c b/fs/read_write.c >> index 431a0ed..a8eabd4 100644 >> --- a/fs/read_write.c >> +++ b/fs/read_write.c >> @@ -38,7 +38,7 @@ __negative_fpos_check(struct file *file, loff_t pos, size_t count) >> * pos or pos+count is negative here, check overflow. >> * too big "count" will be caught in rw_verify_area(). >> */ >> - if ((pos< 0)&& (pos + count< pos)) >> + if ((pos< 0)&& ( (loff_t) (pos + count)< pos)) >> return -EOVERFLOW; >> if (file->f_mode& FMODE_UNSIGNED_OFFSET) >> return 0; >> -- >> 1.7.1.1 >> >> >