All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fan Li <fanofcode.li@samsung.com>
To: linux-fsdevel@vger.kernel.org
Subject: [PATCH 1/3] fs: update len properly when search range exceeds isize
Date: Mon, 11 Jan 2016 14:25:26 +0800	[thread overview]
Message-ID: <001301d14c38$ef2e17f0$cd8a47d0$@samsung.com> (raw)

__generic_block_fiemap() looks up extents within isize, so original
function truncate len to isize if len >= isize, but when start > 0,
start + len would still be greater than isize. 
Update len properly in this patch.

Signed-off-by: Fan Li <fanofcode.li@samsung.com>
---
 fs/ioctl.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/ioctl.c b/fs/ioctl.c
index 41c352e..13a3e96 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -268,9 +268,12 @@ int __generic_block_fiemap(struct inode *inode,
 	 * since we expect isize to not change at all through the duration of
 	 * this call.
 	 */
-	if (len >= isize) {
+	if (start >= isize)
+		return 0;
+
+	if (start + len > isize) {
 		whole_file = true;
-		len = isize;
+		len = isize - start;
 	}
 
 	/*
-- 
1.7.9.5


             reply	other threads:[~2016-01-11  6:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-11  6:25 Fan Li [this message]
2016-01-11 22:25 ` [PATCH 1/3] update len properly when search range exceeds isize Andreas Dilger

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='001301d14c38$ef2e17f0$cd8a47d0$@samsung.com' \
    --to=fanofcode.li@samsung.com \
    --cc=linux-fsdevel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.