Skip to contentSkip to conversation

iomap: fix integer truncation issues in the zeroing and dirtying helpers

PATCH In review Christoph Hellwig 3 participants 8 messages Aug 11, 2017 – Sep 11, 2017 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iomap: fix integer truncation issues in the zeroing and dirtying helpers

Fix the min_t calls in the zeroing and dirtying helpers to perform the comparisms on 64-bit types, which prevents them from incorrectly being truncated, and larger zeroing operations being stuck in a never ending loop.

Special thanks to Markus Stockhausen for spotting the bug.

---
 fs/iomap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/iomap.c +2 -2
index 039266128b7f..59cc98ad7577 100644
@@ -278,7 +278,7 @@ iomap_dirty_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
 		unsigned long bytes;	/* Bytes to write to page */
 
 		offset = (pos & (PAGE_SIZE - 1));
-		bytes = min_t(unsigned long, PAGE_SIZE - offset, length);
+		bytes = min_t(loff_t, PAGE_SIZE - offset, length);
 
 		rpage = __iomap_read_page(inode, pos);
 		if (IS_ERR(rpage))
@@ -373,7 +373,7 @@ iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count,
 		unsigned offset, bytes;
 
 		offset = pos & (PAGE_SIZE - 1); /* Within page */
-		bytes = min_t(unsigned, PAGE_SIZE - offset, count);
+		bytes = min_t(loff_t, PAGE_SIZE - offset, count);
 
 		if (IS_DAX(inode))
 			status = iomap_dax_zero(pos, offset, bytes, iomap);
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Christoph Hellwig

Fix the min_t calls in the zeroing and dirtying helpers to perform the comparisms on 64-bit types, which prevents them from incorrectly being truncated, and larger zeroing operations being stuck in a never ending loop.

Special thanks to Markus Stockhausen for spotting the bug.

Looks fine to me,

(Are you going to push this to Al yourself, or do you want me to drag it through the xfs tree?)

Quoted 33 lines
---
 fs/iomap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/iomap.c +2 -2
index 039266128b7f..59cc98ad7577 100644
@@ -278,7 +278,7 @@ iomap_dirty_actor(struct inode *inode, loff_t pos, loff_t length, void *data,
 		unsigned long bytes;	/* Bytes to write to page */
 
 		offset = (pos & (PAGE_SIZE - 1));
-		bytes = min_t(unsigned long, PAGE_SIZE - offset, length);
+		bytes = min_t(loff_t, PAGE_SIZE - offset, length);
 
 		rpage = __iomap_read_page(inode, pos);
 		if (IS_ERR(rpage))
@@ -373,7 +373,7 @@ iomap_zero_range_actor(struct inode *inode, loff_t pos, loff_t count,
 		unsigned offset, bytes;
 
 		offset = pos & (PAGE_SIZE - 1); /* Within page */
-		bytes = min_t(unsigned, PAGE_SIZE - offset, count);
+		bytes = min_t(loff_t, PAGE_SIZE - offset, count);
 
 		if (IS_DAX(inode))
 			status = iomap_dax_zero(pos, offset, bytes, iomap);
Signature · 6 lines
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 5 lines · Darrick J. Wong

Looks fine to me,

(Are you going to push this to Al yourself, or do you want me to drag it through the xfs tree?)

In general we've maintained iomap.c through the XFS tree so far. I think it's easiest to stick to that.

#3 lore raw
Quoted 9 lines · Christoph Hellwig
Quoted 5 lines · Darrick J. Wong

Looks fine to me,

(Are you going to push this to Al yourself, or do you want me to drag it through the xfs tree?)

In general we've maintained iomap.c through the XFS tree so far. I think it's easiest to stick to that.

Needs signed-off-by. :(

--D

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author Reviewed-by
#4 lore raw
Quoted 5 lines · Darrick J. Wong
Quoted 4 lines · Christoph Hellwig
Quoted 3 lines · Darrick J. Wong

Looks fine to me,

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

(Are you going to push this to Al yourself, or do you want me to drag it through the xfs tree?)

In general we've maintained iomap.c through the XFS tree so far. I think it's easiest to stick to that.

Needs signed-off-by. :(

Feel free to add it:

#5 lore raw
In reply to Christoph Hellwig

Dear Christoph,

Quoted 9 lines · Christoph Hellwig

Fix the min_t calls in the zeroing and dirtying helpers to perform the comparisms on 64-bit types, which prevents them from incorrectly being truncated, and larger zeroing operations being stuck in a never ending loop.

Special thanks to Markus Stockhausen for spotting the bug.

Thank you very much for providing the fix that quickly.

Please don’t forget to tag it for the stable series (4.8+).

Kind regards,

Paul

#6 lore raw

Hi Paul,

I'm overdue doing another XFS stable backport batch, and I will include this patch.

#7 lore raw

Dear Christoph,

Quoted 2 lines · Christoph Hellwig

I'm overdue doing another XFS stable backport batch, and I will include this patch.

If I am not mistaken, this has not been picked up yet for the stable series.

```
$ git tag --contains e28ae8e428fefe2facd72cea9f29906ecb9c861d
v4.13
v4.13-rc6
v4.13-rc7
v4.13.1
$ git log --grep e28ae8e428fefe2facd72cea9f29906ecb9c861d v4.9.48
$
```

Do you want me to submit it for inclusion?

Kind regards,

Paul