[PATCH 1/3] fs: update len properly when search range exceeds isize

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



__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@xxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux