Commit 1094a4a6 authored by Phillip Lougher's avatar Phillip Lougher

Squashfs: add extra sanity checks at mount time

Add some extra sanity checks of the inode and directory structures.
Signed-off-by: default avatarPhillip Lougher <phillip@lougher.demon.co.uk>
parent 1cac63cc
...@@ -268,7 +268,7 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -268,7 +268,7 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent)
handle_fragments: handle_fragments:
fragments = le32_to_cpu(sblk->fragments); fragments = le32_to_cpu(sblk->fragments);
if (fragments == 0) if (fragments == 0)
goto allocate_root; goto check_directory_table;
msblk->fragment_cache = squashfs_cache_init("fragment", msblk->fragment_cache = squashfs_cache_init("fragment",
SQUASHFS_CACHED_FRAGMENTS, msblk->block_size); SQUASHFS_CACHED_FRAGMENTS, msblk->block_size);
...@@ -286,8 +286,22 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -286,8 +286,22 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent)
msblk->fragment_index = NULL; msblk->fragment_index = NULL;
goto failed_mount; goto failed_mount;
} }
next_table = msblk->fragment_index[0];
allocate_root: check_directory_table:
/* Sanity check directory_table */
if (msblk->directory_table >= next_table) {
err = -EINVAL;
goto failed_mount;
}
/* Sanity check inode_table */
if (msblk->inode_table >= msblk->directory_table) {
err = -EINVAL;
goto failed_mount;
}
/* allocate root */
root = new_inode(sb); root = new_inode(sb);
if (!root) { if (!root) {
err = -ENOMEM; err = -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment