From 656f31fab89b0b04c4b7ba2ab0824731e7838dd9 Mon Sep 17 00:00:00 2001 From: Anton Altaparmakov Date: Sat, 3 Nov 2007 07:38:59 +0000 Subject: [PATCH] --- yaml --- r: 73039 b: refs/heads/master c: ebab89909e0dc716282d5e7f6e73a3155fe66d4a h: refs/heads/master i: 73037: 08ded1d2135cd9ccbc63e0dd239f244614199aa0 73035: db63121fed1222f60c33398a503e022f529dc97c 73031: e003c6a5aeabe603bf92249e02b66766e9b98d11 73023: 120930f6940bc741c7859e44ef6dcee068a8ee9e v: v3 --- [refs] | 2 +- trunk/fs/ntfs/aops.c | 10 +++++++++- trunk/fs/ntfs/attrib.c | 5 +---- trunk/fs/ntfs/compress.c | 10 ++++++++++ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/[refs] b/[refs] index c1e16d3740ec..aadad26589ba 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 74521c28e550c4ec265cda14114bd9b908e9de34 +refs/heads/master: ebab89909e0dc716282d5e7f6e73a3155fe66d4a diff --git a/trunk/fs/ntfs/aops.c b/trunk/fs/ntfs/aops.c index cfdc7900d271..ad87cb01299b 100644 --- a/trunk/fs/ntfs/aops.c +++ b/trunk/fs/ntfs/aops.c @@ -405,6 +405,15 @@ static int ntfs_readpage(struct file *file, struct page *page) retry_readpage: BUG_ON(!PageLocked(page)); + vi = page->mapping->host; + i_size = i_size_read(vi); + /* Is the page fully outside i_size? (truncate in progress) */ + if (unlikely(page->index >= (i_size + PAGE_CACHE_SIZE - 1) >> + PAGE_CACHE_SHIFT)) { + zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0); + ntfs_debug("Read outside i_size - truncated?"); + goto done; + } /* * This can potentially happen because we clear PageUptodate() during * ntfs_writepage() of MstProtected() attributes. @@ -413,7 +422,6 @@ static int ntfs_readpage(struct file *file, struct page *page) unlock_page(page); return 0; } - vi = page->mapping->host; ni = NTFS_I(vi); /* * Only $DATA attributes can be encrypted and only unnamed $DATA diff --git a/trunk/fs/ntfs/attrib.c b/trunk/fs/ntfs/attrib.c index 92dabdcf2b80..50d3b0c258e3 100644 --- a/trunk/fs/ntfs/attrib.c +++ b/trunk/fs/ntfs/attrib.c @@ -179,10 +179,7 @@ int ntfs_map_runlist_nolock(ntfs_inode *ni, VCN vcn, ntfs_attr_search_ctx *ctx) * ntfs_mapping_pairs_decompress() fails. */ end_vcn = sle64_to_cpu(a->data.non_resident.highest_vcn) + 1; - if (!a->data.non_resident.lowest_vcn && end_vcn == 1) - end_vcn = sle64_to_cpu(a->data.non_resident.allocated_size) >> - ni->vol->cluster_size_bits; - if (unlikely(vcn >= end_vcn)) { + if (unlikely(vcn && vcn >= end_vcn)) { err = -ENOENT; goto err_out; } diff --git a/trunk/fs/ntfs/compress.c b/trunk/fs/ntfs/compress.c index d98daf59e0b6..d1619d05eb23 100644 --- a/trunk/fs/ntfs/compress.c +++ b/trunk/fs/ntfs/compress.c @@ -561,6 +561,16 @@ int ntfs_read_compressed_block(struct page *page) read_unlock_irqrestore(&ni->size_lock, flags); max_page = ((i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT) - offset; + /* Is the page fully outside i_size? (truncate in progress) */ + if (xpage >= max_page) { + kfree(bhs); + kfree(pages); + zero_user_page(page, 0, PAGE_CACHE_SIZE, KM_USER0); + ntfs_debug("Compressed read outside i_size - truncated?"); + SetPageUptodate(page); + unlock_page(page); + return 0; + } if (nr_pages < max_page) max_page = nr_pages; for (i = 0; i < max_page; i++, offset++) {