Skip to contentSkip to conversation

fs: Do to trim high file position bits in iomap_page_mkwrite_actor

PATCH In review Jan Kara 3 participants 3 messages Oct 20, 2016 – Oct 24, 2016 VFS

lore
Share & tools
lore

Jan Kara

author reviewer
#0 lore raw

PATCH 1/1 fs: Do to trim high file position bits in iomap_page_mkwrite_actor

iomap_page_mkwrite_actor() calls __block_write_begin_int() with position masked as pos & ~PAGE_MASK which is equivalent to pos & (PAGE_SIZE-1). Thus it masks off high bits of file position. However __block_write_begin_int() expects full file position on input. This does not cause any visible issues because all __block_write_begin_int() really cares about are low file position bits but still it is a bug waiting to happen.

---
 fs/iomap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/iomap.c +1 -2
index 013d1d36fbbf..3341907eefc7 100644
@@ -433,8 +433,7 @@ iomap_page_mkwrite_actor(struct inode *inode, loff_t pos, loff_t length,
 	struct page *page = data;
 	int ret;
 
-	ret = __block_write_begin_int(page, pos & ~PAGE_MASK, length,
-			NULL, iomap);
+	ret = __block_write_begin_int(page, pos, length, NULL, iomap);
 	if (ret)
 		return ret;
 
Signature · 1 line
2.6.6
#2 lore raw
In reply to Jan Kara
Quoted 18 lines · Jan Kara

iomap_page_mkwrite_actor() calls __block_write_begin_int() with position masked as pos & ~PAGE_MASK which is equivalent to pos & (PAGE_SIZE-1). Thus it masks off high bits of file position. However __block_write_begin_int() expects full file position on input. This does not cause any visible issues because all __block_write_begin_int() really cares about are low file position bits but still it is a bug waiting to happen.

---
 fs/iomap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/iomap.c +0 -0
index 013d1d36fbbf..3341907eefc7 100644

fs/iomap.c iomap_page_mkwrite_actor(struct inode *inode, loff_t pos, loff_t length, · line 438

Quoted 8 lines
fs/iomap.c +1 -2
@@ -433,8 +433,7 @@ iomap_page_mkwrite_actor(struct inode *inode, loff_t pos, loff_t length,
 	struct page *page = data;
 	int ret;
 
-	ret = __block_write_begin_int(page, pos & ~PAGE_MASK, length,
-			NULL, iomap);
+	ret = __block_write_begin_int(page, pos, length, NULL, iomap);
 	if (ret)
 		return ret;

Looks good. I've added it to my -rc3 fixes series.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]