aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2014-04-03 17:50:31 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-03 19:21:26 -0400
commit0ec060d1881a24c270fdf0d6616e33e23a209ef2 (patch)
treea4c2d5ca63ffabde64759d2c238773d7114e34b7 /include
parentf9f32c44e7016c61f8c60afbe461fbc7d5a6c7cc (diff)
nilfs2: verify metadata sizes read from disk
Add code to check sizes of on-disk data of metadata files such as inode size, segment usage size, DAT entry size, and checkpoint size. Although these sizes are read from disk, the current implementation doesn't check them. If these sizes are not sane on disk, it can cause out-of-range access to metadata or memory access overrun on metadata block buffers due to overflow in sundry calculations. Both lower limit and upper limit of metadata sizes are verified to prevent these issues. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> Cc: Andreas Rohner <andreas.rohner@gmx.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/nilfs2_fs.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/nilfs2_fs.h b/include/linux/nilfs2_fs.h
index 1fb465f9baf2..ff3fea3194c6 100644
--- a/include/linux/nilfs2_fs.h
+++ b/include/linux/nilfs2_fs.h
@@ -82,6 +82,8 @@ struct nilfs_inode {
82 __le32 i_pad; 82 __le32 i_pad;
83}; 83};
84 84
85#define NILFS_MIN_INODE_SIZE 128
86
85/** 87/**
86 * struct nilfs_super_root - structure of super root 88 * struct nilfs_super_root - structure of super root
87 * @sr_sum: check sum 89 * @sr_sum: check sum
@@ -482,6 +484,8 @@ struct nilfs_dat_entry {
482 __le64 de_rsv; 484 __le64 de_rsv;
483}; 485};
484 486
487#define NILFS_MIN_DAT_ENTRY_SIZE 32
488
485/** 489/**
486 * struct nilfs_snapshot_list - snapshot list 490 * struct nilfs_snapshot_list - snapshot list
487 * @ssl_next: next checkpoint number on snapshot list 491 * @ssl_next: next checkpoint number on snapshot list
@@ -520,6 +524,8 @@ struct nilfs_checkpoint {
520 struct nilfs_inode cp_ifile_inode; 524 struct nilfs_inode cp_ifile_inode;
521}; 525};
522 526
527#define NILFS_MIN_CHECKPOINT_SIZE (64 + NILFS_MIN_INODE_SIZE)
528
523/* checkpoint flags */ 529/* checkpoint flags */
524enum { 530enum {
525 NILFS_CHECKPOINT_SNAPSHOT, 531 NILFS_CHECKPOINT_SNAPSHOT,
@@ -615,6 +621,8 @@ struct nilfs_segment_usage {
615 __le32 su_flags; 621 __le32 su_flags;
616}; 622};
617 623
624#define NILFS_MIN_SEGMENT_USAGE_SIZE 16
625
618/* segment usage flag */ 626/* segment usage flag */
619enum { 627enum {
620 NILFS_SEGMENT_USAGE_ACTIVE, 628 NILFS_SEGMENT_USAGE_ACTIVE,