Skip to contentSkip to conversation

fs: update len properly when search range exceeds isize

PATCH In review Fan Li 2 participants 2 messages Jan 11, 2016

Subsystems (2)
lore
Share & tools
lore

Fan Li

author
#0 lore raw

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

__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.

---
 fs/ioctl.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
fs/ioctl.c +5 -2
index 41c352e..13a3e96 100644
@@ -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;
 	}
 
 	/*
Signature · 1 line
1.7.9.5
Reviewed-by on v1 1/3
#1 lore raw

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

Quoted 20 lines · Fan Li

__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.

---
fs/ioctl.c | 7 +++++--

1 file changed, 5 insertions(+), 2 deletions(-)
fs/ioctl.c +0 -1
index 41c352e..13a3e96 100644
@@ -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) {

fs/ioctl.c int __generic_block_fiemap(struct inode *inode, · line 279

Quoted 10 lines
fs/ioctl.c +5 -1
+	if (start >= isize)
+		return 0;
+
+	if (start + len > isize) {
 		whole_file = true;
-		len = isize;
+		len = isize - start;
 	}
 
 	/*

Cheers, Andreas