* [PATCH 7/7] Squashfs: add extra sanity checks at mount time
@ 2011-05-25 3:23 Phillip Lougher
0 siblings, 0 replies; only message in thread
From: Phillip Lougher @ 2011-05-25 3:23 UTC (permalink / raw)
To: linux-fsdevel; +Cc: linux-kernel
Add some extra sanity checks of the inode and directory structures.
Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>
---
fs/squashfs/super.c | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c
index efa8118..984d6c8 100644
--- a/fs/squashfs/super.c
+++ b/fs/squashfs/super.c
@@ -268,7 +268,7 @@ allocate_id_index_table:
handle_fragments:
fragments = le32_to_cpu(sblk->fragments);
if (fragments == 0)
- goto allocate_root;
+ goto check_directory_table;
msblk->fragment_cache = squashfs_cache_init("fragment",
SQUASHFS_CACHED_FRAGMENTS, msblk->block_size);
@@ -286,8 +286,22 @@ handle_fragments:
msblk->fragment_index = NULL;
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);
if (!root) {
err = -ENOMEM;
--
1.7.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2011-05-25 3:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-25 3:23 [PATCH 7/7] Squashfs: add extra sanity checks at mount time Phillip Lougher
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.