aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorNick Piggin <npiggin@suse.de>2007-07-20 03:31:45 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-20 11:44:19 -0400
commit1833633803c7ef4d8f09877d3f1549cbd252f477 (patch)
treece69505de705701f838bd77c6b6b6bc18529bed0 /fs
parente228929bc257b963523ed75aa60d2ad77ece2189 (diff)
fix some conversion overflows
Fix page index to offset conversion overflows in buffer layer, ecryptfs, and ocfs2. It would be nice to convert the whole tree to page_offset, but for now just fix the bugs. Signed-off-by: Nick Piggin <npiggin@suse.de> Cc: Michael Halcrow <mhalcrow@us.ibm.com> Cc: Mark Fasheh <mark.fasheh@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/buffer.c2
-rw-r--r--fs/ecryptfs/mmap.c5
-rw-r--r--fs/ocfs2/mmap.c2
3 files changed, 4 insertions, 5 deletions
diff --git a/fs/buffer.c b/fs/buffer.c
index 02ebb1f1d3b..0e5ec371ce7 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -2221,7 +2221,7 @@ block_page_mkwrite(struct vm_area_struct *vma, struct page *page,
2221 lock_page(page); 2221 lock_page(page);
2222 size = i_size_read(inode); 2222 size = i_size_read(inode);
2223 if ((page->mapping != inode->i_mapping) || 2223 if ((page->mapping != inode->i_mapping) ||
2224 ((page->index << PAGE_CACHE_SHIFT) > size)) { 2224 (page_offset(page) > size)) {
2225 /* page got truncated out from underneath us */ 2225 /* page got truncated out from underneath us */
2226 goto out_unlock; 2226 goto out_unlock;
2227 } 2227 }
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index 7d5a43cb0d5..e4ab7bc14ef 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -409,8 +409,7 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page,
409 if (!PageUptodate(page)) 409 if (!PageUptodate(page))
410 rc = ecryptfs_do_readpage(file, page, page->index); 410 rc = ecryptfs_do_readpage(file, page, page->index);
411 if (page->index != 0) { 411 if (page->index != 0) {
412 loff_t end_of_prev_pg_pos = 412 loff_t end_of_prev_pg_pos = page_offset(page) - 1;
413 (((loff_t)page->index << PAGE_CACHE_SHIFT) - 1);
414 413
415 if (end_of_prev_pg_pos > i_size_read(page->mapping->host)) { 414 if (end_of_prev_pg_pos > i_size_read(page->mapping->host)) {
416 rc = ecryptfs_truncate(file->f_path.dentry, 415 rc = ecryptfs_truncate(file->f_path.dentry,
@@ -736,7 +735,7 @@ static int ecryptfs_commit_write(struct file *file, struct page *page,
736 goto out; 735 goto out;
737 } 736 }
738 inode->i_blocks = lower_inode->i_blocks; 737 inode->i_blocks = lower_inode->i_blocks;
739 pos = (page->index << PAGE_CACHE_SHIFT) + to; 738 pos = page_offset(page) + to;
740 if (pos > i_size_read(inode)) { 739 if (pos > i_size_read(inode)) {
741 i_size_write(inode, pos); 740 i_size_write(inode, pos);
742 ecryptfs_printk(KERN_DEBUG, "Expanded file size to " 741 ecryptfs_printk(KERN_DEBUG, "Expanded file size to "
diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c
index ee64749e2ee..98756156d29 100644
--- a/fs/ocfs2/mmap.c
+++ b/fs/ocfs2/mmap.c
@@ -89,7 +89,7 @@ static int __ocfs2_page_mkwrite(struct inode *inode, struct buffer_head *di_bh,
89{ 89{
90 int ret; 90 int ret;
91 struct address_space *mapping = inode->i_mapping; 91 struct address_space *mapping = inode->i_mapping;
92 loff_t pos = page->index << PAGE_CACHE_SHIFT; 92 loff_t pos = page_offset(page);
93 unsigned int len = PAGE_CACHE_SIZE; 93 unsigned int len = PAGE_CACHE_SIZE;
94 pgoff_t last_index; 94 pgoff_t last_index;
95 struct page *locked_page = NULL; 95 struct page *locked_page = NULL;