linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Harsh Bora <harsh@linux.vnet.ibm.com>
To: viro@ZenIV.linux.org.uk
Cc: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>,
	linux-fsdevel@vger.kernel.org, fengguang.wu@intel.com,
	kamezawa.hiroyu@jp.fujitsu.com, aneesh.kumar@linux.vnet.ibm.com,
	jvrao@linux.vnet.ibm.com
Subject: Re: [PATCH] Typecasting required for comparing unlike datatypes
Date: Fri, 10 Dec 2010 00:02:03 +0530	[thread overview]
Message-ID: <4D0120A3.2040301@linux.vnet.ibm.com> (raw)
In-Reply-To: <1291812900-18311-1-git-send-email-harsh@linux.vnet.ibm.com>

Hi Al,
Any comments?

On 12/08/2010 06:25 PM, 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<harsh@linux.vnet.ibm.com>
> ---
>   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;


  reply	other threads:[~2010-12-09 18:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-08 12:55 [PATCH] Typecasting required for comparing unlike datatypes Harsh Prateek Bora
2010-12-09 18:32 ` Harsh Bora [this message]
2010-12-10  0:06   ` KAMEZAWA Hiroyuki
2010-12-10  0:53 ` KAMEZAWA Hiroyuki
2010-12-10  6:39   ` Harsh Bora
2010-12-10  7:01     ` KAMEZAWA Hiroyuki
2010-12-10  7:18       ` Harsh Bora
2010-12-10  7:59         ` KAMEZAWA Hiroyuki
2010-12-10  8:13           ` Harsh Bora
2010-12-10  8:20             ` KAMEZAWA Hiroyuki
2010-12-10  8:18 ` KAMEZAWA Hiroyuki
2010-12-10  8:31   ` Harsh Bora
2010-12-15  9:50   ` Al Viro
2010-12-16  0:24     ` KAMEZAWA Hiroyuki
2010-12-19  7:02       ` Harsh Bora

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D0120A3.2040301@linux.vnet.ibm.com \
    --to=harsh@linux.vnet.ibm.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=fengguang.wu@intel.com \
    --cc=jvrao@linux.vnet.ibm.com \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).