mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
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]> Cc: Michael Halcrow <[email protected]> Cc: Mark Fasheh <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
e228929bc2
commit
1833633803
3 changed files with 4 additions and 5 deletions
|
|
@ -409,8 +409,7 @@ static int ecryptfs_prepare_write(struct file *file, struct page *page,
|
|||
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 file *file, struct page *page,
|
|||
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 "
|
||||
|
|
|
|||
Loading…
Reference in a new issue