Re: [patch] fix some conversion overflows
On Fri, Jul 20, 2007 at 07:40:04AM +0200, Nick Piggin wrote: > 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. Yup, that's part of the clean-ups in Christoph Lameter's variable order page cache patch set. i.e.: http://marc.info/?l=linux-kernel=118236497117452=2 and friends like: http://marc.info/?l=linux-kernel=118236459007960=2 http://marc.info/?l=linux-kernel=118236495712004=2 Cheers, Dave. -- Dave Chinner Principal Engineer SGI Australian Software Group - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [patch] fix some conversion overflows
On Fri, Jul 20, 2007 at 07:40:04AM +0200, Nick Piggin wrote: 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. Yup, that's part of the clean-ups in Christoph Lameter's variable order page cache patch set. i.e.: http://marc.info/?l=linux-kernelm=118236497117452w=2 and friends like: http://marc.info/?l=linux-kernelm=118236459007960w=2 http://marc.info/?l=linux-kernelm=118236495712004w=2 Cheers, Dave. -- Dave Chinner Principal Engineer SGI Australian Software Group - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[patch] 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 <[EMAIL PROTECTED]> --- diff --git a/fs/buffer.c b/fs/buffer.c index 02ebb1f..0e5ec37 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2221,7 +2221,7 @@ block_page_mkwrite(struct vm_area_struct lock_page(page); size = i_size_read(inode); if ((page->mapping != inode->i_mapping) || - ((page->index << PAGE_CACHE_SHIFT) > size)) { + (page_offset(page) > size)) { /* page got truncated out from underneath us */ goto out_unlock; } diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c index 7d5a43c..e4ab7bc 100644 --- a/fs/ecryptfs/mmap.c +++ b/fs/ecryptfs/mmap.c @@ -409,8 +409,7 @@ static int ecryptfs_prepare_write(struct if (!PageUptodate(page)) rc = ecryptfs_do_readpage(file, page, page->index); if (page->index != 0) { - loff_t end_of_prev_pg_pos = - (((loff_t)page->index << PAGE_CACHE_SHIFT) - 1); + loff_t end_of_prev_pg_pos = page_offset(page) - 1; if (end_of_prev_pg_pos > i_size_read(page->mapping->host)) { rc = ecryptfs_truncate(file->f_path.dentry, @@ -736,7 +735,7 @@ static int ecryptfs_commit_write(struct goto out; } inode->i_blocks = lower_inode->i_blocks; - pos = (page->index << PAGE_CACHE_SHIFT) + to; + pos = page_offset(page) + to; if (pos > i_size_read(inode)) { i_size_write(inode, pos); ecryptfs_printk(KERN_DEBUG, "Expanded file size to " diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c index ee64749..9875615 100644 --- a/fs/ocfs2/mmap.c +++ b/fs/ocfs2/mmap.c @@ -89,7 +89,7 @@ static int __ocfs2_page_mkwrite(struct i { int ret; struct address_space *mapping = inode->i_mapping; - loff_t pos = page->index << PAGE_CACHE_SHIFT; + loff_t pos = page_offset(page); unsigned int len = PAGE_CACHE_SIZE; pgoff_t last_index; struct page *locked_page = NULL; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[patch] 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 [EMAIL PROTECTED] --- diff --git a/fs/buffer.c b/fs/buffer.c index 02ebb1f..0e5ec37 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -2221,7 +2221,7 @@ block_page_mkwrite(struct vm_area_struct lock_page(page); size = i_size_read(inode); if ((page-mapping != inode-i_mapping) || - ((page-index PAGE_CACHE_SHIFT) size)) { + (page_offset(page) size)) { /* page got truncated out from underneath us */ goto out_unlock; } diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c index 7d5a43c..e4ab7bc 100644 --- a/fs/ecryptfs/mmap.c +++ b/fs/ecryptfs/mmap.c @@ -409,8 +409,7 @@ static int ecryptfs_prepare_write(struct if (!PageUptodate(page)) rc = ecryptfs_do_readpage(file, page, page-index); if (page-index != 0) { - loff_t end_of_prev_pg_pos = - (((loff_t)page-index PAGE_CACHE_SHIFT) - 1); + loff_t end_of_prev_pg_pos = page_offset(page) - 1; if (end_of_prev_pg_pos i_size_read(page-mapping-host)) { rc = ecryptfs_truncate(file-f_path.dentry, @@ -736,7 +735,7 @@ static int ecryptfs_commit_write(struct goto out; } inode-i_blocks = lower_inode-i_blocks; - pos = (page-index PAGE_CACHE_SHIFT) + to; + pos = page_offset(page) + to; if (pos i_size_read(inode)) { i_size_write(inode, pos); ecryptfs_printk(KERN_DEBUG, Expanded file size to diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c index ee64749..9875615 100644 --- a/fs/ocfs2/mmap.c +++ b/fs/ocfs2/mmap.c @@ -89,7 +89,7 @@ static int __ocfs2_page_mkwrite(struct i { int ret; struct address_space *mapping = inode-i_mapping; - loff_t pos = page-index PAGE_CACHE_SHIFT; + loff_t pos = page_offset(page); unsigned int len = PAGE_CACHE_SIZE; pgoff_t last_index; struct page *locked_page = NULL; - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/