summaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/cpfile.c
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 /fs/nilfs2/cpfile.c
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 'fs/nilfs2/cpfile.c')
-rw-r--r--fs/nilfs2/cpfile.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c
index deaa3d33a0aa..0d58075f34e2 100644
--- a/fs/nilfs2/cpfile.c
+++ b/fs/nilfs2/cpfile.c
@@ -942,6 +942,18 @@ int nilfs_cpfile_read(struct super_block *sb, size_t cpsize,
942 struct inode *cpfile; 942 struct inode *cpfile;
943 int err; 943 int err;
944 944
945 if (cpsize > sb->s_blocksize) {
946 printk(KERN_ERR
947 "NILFS: too large checkpoint size: %zu bytes.\n",
948 cpsize);
949 return -EINVAL;
950 } else if (cpsize < NILFS_MIN_CHECKPOINT_SIZE) {
951 printk(KERN_ERR
952 "NILFS: too small checkpoint size: %zu bytes.\n",
953 cpsize);
954 return -EINVAL;
955 }
956
945 cpfile = nilfs_iget_locked(sb, NULL, NILFS_CPFILE_INO); 957 cpfile = nilfs_iget_locked(sb, NULL, NILFS_CPFILE_INO);
946 if (unlikely(!cpfile)) 958 if (unlikely(!cpfile))
947 return -ENOMEM; 959 return -ENOMEM;