aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAdrian Hunter <ext-adrian.hunter@nokia.com>2008-09-05 09:17:42 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-09-30 04:12:57 -0400
commited382d5898ccfc3d7ba775be2f1596f6a1547935 (patch)
tree20738a804f51086e94f6c76c689b929582b7c415 /fs
parent2094c334fdebbcceddf21f97cb16b144707af56e (diff)
UBIFS: ensure data read beyond i_size is zeroed out correctly
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ubifs/file.c10
-rw-r--r--fs/ubifs/ubifs-media.h1
2 files changed, 8 insertions, 3 deletions
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index cdcfe95cbfb4..2f20a49ba34e 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -147,6 +147,12 @@ static int do_readpage(struct page *page)
147 err = ret; 147 err = ret;
148 if (err != -ENOENT) 148 if (err != -ENOENT)
149 break; 149 break;
150 } else if (block + 1 == beyond) {
151 int dlen = le32_to_cpu(dn->size);
152 int ilen = i_size & (UBIFS_BLOCK_SIZE - 1);
153
154 if (ilen && ilen < dlen)
155 memset(addr + ilen, 0, dlen - ilen);
150 } 156 }
151 } 157 }
152 if (++i >= UBIFS_BLOCKS_PER_PAGE) 158 if (++i >= UBIFS_BLOCKS_PER_PAGE)
@@ -601,7 +607,7 @@ static int populate_page(struct ubifs_info *c, struct page *page,
601 607
602 addr = zaddr = kmap(page); 608 addr = zaddr = kmap(page);
603 609
604 end_index = (i_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; 610 end_index = (i_size - 1) >> PAGE_CACHE_SHIFT;
605 if (!i_size || page->index > end_index) { 611 if (!i_size || page->index > end_index) {
606 memset(addr, 0, PAGE_CACHE_SIZE); 612 memset(addr, 0, PAGE_CACHE_SIZE);
607 goto out_hole; 613 goto out_hole;
@@ -649,7 +655,7 @@ static int populate_page(struct ubifs_info *c, struct page *page,
649 if (end_index == page->index) { 655 if (end_index == page->index) {
650 int len = i_size & (PAGE_CACHE_SIZE - 1); 656 int len = i_size & (PAGE_CACHE_SIZE - 1);
651 657
652 if (len < read) 658 if (len && len < read)
653 memset(zaddr + len, 0, read - len); 659 memset(zaddr + len, 0, read - len);
654 } 660 }
655 661
diff --git a/fs/ubifs/ubifs-media.h b/fs/ubifs/ubifs-media.h
index a9ecbd9af20d..0b378042a3a2 100644
--- a/fs/ubifs/ubifs-media.h
+++ b/fs/ubifs/ubifs-media.h
@@ -75,7 +75,6 @@
75 */ 75 */
76#define UBIFS_BLOCK_SIZE 4096 76#define UBIFS_BLOCK_SIZE 4096
77#define UBIFS_BLOCK_SHIFT 12 77#define UBIFS_BLOCK_SHIFT 12
78#define UBIFS_BLOCK_MASK 0x00000FFF
79 78
80/* UBIFS padding byte pattern (must not be first or last byte of node magic) */ 79/* UBIFS padding byte pattern (must not be first or last byte of node magic) */
81#define UBIFS_PADDING_BYTE 0xCE 80#define UBIFS_PADDING_BYTE 0xCE