diff options
| -rw-r--r-- | MAINTAINERS | 2 | ||||
| -rw-r--r-- | fs/squashfs/block.c | 2 | ||||
| -rw-r--r-- | fs/squashfs/cache.c | 31 | ||||
| -rw-r--r-- | fs/squashfs/decompressor.c | 2 | ||||
| -rw-r--r-- | fs/squashfs/decompressor.h | 2 | ||||
| -rw-r--r-- | fs/squashfs/dir.c | 2 | ||||
| -rw-r--r-- | fs/squashfs/export.c | 42 | ||||
| -rw-r--r-- | fs/squashfs/file.c | 2 | ||||
| -rw-r--r-- | fs/squashfs/fragment.c | 37 | ||||
| -rw-r--r-- | fs/squashfs/id.c | 42 | ||||
| -rw-r--r-- | fs/squashfs/inode.c | 2 | ||||
| -rw-r--r-- | fs/squashfs/namei.c | 2 | ||||
| -rw-r--r-- | fs/squashfs/squashfs.h | 10 | ||||
| -rw-r--r-- | fs/squashfs/squashfs_fs.h | 2 | ||||
| -rw-r--r-- | fs/squashfs/squashfs_fs_i.h | 2 | ||||
| -rw-r--r-- | fs/squashfs/squashfs_fs_sb.h | 2 | ||||
| -rw-r--r-- | fs/squashfs/super.c | 112 | ||||
| -rw-r--r-- | fs/squashfs/symlink.c | 2 | ||||
| -rw-r--r-- | fs/squashfs/xattr.c | 2 | ||||
| -rw-r--r-- | fs/squashfs/xattr.h | 3 | ||||
| -rw-r--r-- | fs/squashfs/xattr_id.c | 47 | ||||
| -rw-r--r-- | fs/squashfs/xz_wrapper.c | 2 | ||||
| -rw-r--r-- | fs/squashfs/zlib_wrapper.c | 2 |
23 files changed, 203 insertions, 151 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index d1a1465bec02..c4fc1daddcb6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -6001,7 +6001,7 @@ F: Documentation/filesystems/spufs.txt | |||
| 6001 | F: arch/powerpc/platforms/cell/spufs/ | 6001 | F: arch/powerpc/platforms/cell/spufs/ |
| 6002 | 6002 | ||
| 6003 | SQUASHFS FILE SYSTEM | 6003 | SQUASHFS FILE SYSTEM |
| 6004 | M: Phillip Lougher <phillip@lougher.demon.co.uk> | 6004 | M: Phillip Lougher <phillip@squashfs.org.uk> |
| 6005 | L: squashfs-devel@lists.sourceforge.net (subscribers-only) | 6005 | L: squashfs-devel@lists.sourceforge.net (subscribers-only) |
| 6006 | W: http://squashfs.org.uk | 6006 | W: http://squashfs.org.uk |
| 6007 | S: Maintained | 6007 | S: Maintained |
diff --git a/fs/squashfs/block.c b/fs/squashfs/block.c index 8ab48bc2fa7d..ed0eb2a921f4 100644 --- a/fs/squashfs/block.c +++ b/fs/squashfs/block.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
| 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
diff --git a/fs/squashfs/cache.c b/fs/squashfs/cache.c index 4b5a3fbb1f1f..f744be98cd5a 100644 --- a/fs/squashfs/cache.c +++ b/fs/squashfs/cache.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
| 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
| @@ -393,19 +393,36 @@ struct squashfs_cache_entry *squashfs_get_datablock(struct super_block *sb, | |||
| 393 | /* | 393 | /* |
| 394 | * Read a filesystem table (uncompressed sequence of bytes) from disk | 394 | * Read a filesystem table (uncompressed sequence of bytes) from disk |
| 395 | */ | 395 | */ |
| 396 | int squashfs_read_table(struct super_block *sb, void *buffer, u64 block, | 396 | void *squashfs_read_table(struct super_block *sb, u64 block, int length) |
| 397 | int length) | ||
| 398 | { | 397 | { |
| 399 | int pages = (length + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; | 398 | int pages = (length + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT; |
| 400 | int i, res; | 399 | int i, res; |
| 401 | void **data = kcalloc(pages, sizeof(void *), GFP_KERNEL); | 400 | void *table, *buffer, **data; |
| 402 | if (data == NULL) | 401 | |
| 403 | return -ENOMEM; | 402 | table = buffer = kmalloc(length, GFP_KERNEL); |
| 403 | if (table == NULL) | ||
| 404 | return ERR_PTR(-ENOMEM); | ||
| 405 | |||
| 406 | data = kcalloc(pages, sizeof(void *), GFP_KERNEL); | ||
| 407 | if (data == NULL) { | ||
| 408 | res = -ENOMEM; | ||
| 409 | goto failed; | ||
| 410 | } | ||
| 404 | 411 | ||
| 405 | for (i = 0; i < pages; i++, buffer += PAGE_CACHE_SIZE) | 412 | for (i = 0; i < pages; i++, buffer += PAGE_CACHE_SIZE) |
| 406 | data[i] = buffer; | 413 | data[i] = buffer; |
| 414 | |||
| 407 | res = squashfs_read_data(sb, data, block, length | | 415 | res = squashfs_read_data(sb, data, block, length | |
| 408 | SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, length, pages); | 416 | SQUASHFS_COMPRESSED_BIT_BLOCK, NULL, length, pages); |
| 417 | |||
| 409 | kfree(data); | 418 | kfree(data); |
| 410 | return res; | 419 | |
| 420 | if (res < 0) | ||
| 421 | goto failed; | ||
| 422 | |||
| 423 | return table; | ||
| 424 | |||
| 425 | failed: | ||
| 426 | kfree(table); | ||
| 427 | return ERR_PTR(res); | ||
| 411 | } | 428 | } |
diff --git a/fs/squashfs/decompressor.c b/fs/squashfs/decompressor.c index e921bd213738..9f1b0bb96f13 100644 --- a/fs/squashfs/decompressor.c +++ b/fs/squashfs/decompressor.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 | 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
| 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
diff --git a/fs/squashfs/decompressor.h b/fs/squashfs/decompressor.h index 099745ad5691..8ba70cff09a6 100644 --- a/fs/squashfs/decompressor.h +++ b/fs/squashfs/decompressor.h | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | * Squashfs - a compressed read only filesystem for Linux | 4 | * Squashfs - a compressed read only filesystem for Linux |
| 5 | * | 5 | * |
| 6 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 | 6 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
| 7 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 7 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 8 | * | 8 | * |
| 9 | * This program is free software; you can redistribute it and/or | 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License | 10 | * modify it under the terms of the GNU General Public License |
diff --git a/fs/squashfs/dir.c b/fs/squashfs/dir.c index 3f79cd1d0c19..9dfe2ce0fb70 100644 --- a/fs/squashfs/dir.c +++ b/fs/squashfs/dir.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
| 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
diff --git a/fs/squashfs/export.c b/fs/squashfs/export.c index 7f93d5a9ee05..730c56248c9b 100644 --- a/fs/squashfs/export.c +++ b/fs/squashfs/export.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
| 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
| @@ -121,30 +121,38 @@ static struct dentry *squashfs_get_parent(struct dentry *child) | |||
| 121 | * Read uncompressed inode lookup table indexes off disk into memory | 121 | * Read uncompressed inode lookup table indexes off disk into memory |
| 122 | */ | 122 | */ |
| 123 | __le64 *squashfs_read_inode_lookup_table(struct super_block *sb, | 123 | __le64 *squashfs_read_inode_lookup_table(struct super_block *sb, |
| 124 | u64 lookup_table_start, unsigned int inodes) | 124 | u64 lookup_table_start, u64 next_table, unsigned int inodes) |
| 125 | { | 125 | { |
| 126 | unsigned int length = SQUASHFS_LOOKUP_BLOCK_BYTES(inodes); | 126 | unsigned int length = SQUASHFS_LOOKUP_BLOCK_BYTES(inodes); |
| 127 | __le64 *inode_lookup_table; | 127 | __le64 *table; |
| 128 | int err; | ||
| 129 | 128 | ||
| 130 | TRACE("In read_inode_lookup_table, length %d\n", length); | 129 | TRACE("In read_inode_lookup_table, length %d\n", length); |
| 131 | 130 | ||
| 132 | /* Allocate inode lookup table indexes */ | 131 | /* Sanity check values */ |
| 133 | inode_lookup_table = kmalloc(length, GFP_KERNEL); | 132 | |
| 134 | if (inode_lookup_table == NULL) { | 133 | /* there should always be at least one inode */ |
| 135 | ERROR("Failed to allocate inode lookup table\n"); | 134 | if (inodes == 0) |
| 136 | return ERR_PTR(-ENOMEM); | 135 | return ERR_PTR(-EINVAL); |
| 137 | } | 136 | |
| 137 | /* length bytes should not extend into the next table - this check | ||
| 138 | * also traps instances where lookup_table_start is incorrectly larger | ||
| 139 | * than the next table start | ||
| 140 | */ | ||
| 141 | if (lookup_table_start + length > next_table) | ||
| 142 | return ERR_PTR(-EINVAL); | ||
| 143 | |||
| 144 | table = squashfs_read_table(sb, lookup_table_start, length); | ||
| 138 | 145 | ||
| 139 | err = squashfs_read_table(sb, inode_lookup_table, lookup_table_start, | 146 | /* |
| 140 | length); | 147 | * table[0] points to the first inode lookup table metadata block, |
| 141 | if (err < 0) { | 148 | * this should be less than lookup_table_start |
| 142 | ERROR("unable to read inode lookup table\n"); | 149 | */ |
| 143 | kfree(inode_lookup_table); | 150 | if (!IS_ERR(table) && table[0] >= lookup_table_start) { |
| 144 | return ERR_PTR(err); | 151 | kfree(table); |
| 152 | return ERR_PTR(-EINVAL); | ||
| 145 | } | 153 | } |
| 146 | 154 | ||
| 147 | return inode_lookup_table; | 155 | return table; |
| 148 | } | 156 | } |
| 149 | 157 | ||
| 150 | 158 | ||
diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c index a25c5060bdcb..38bb1c640559 100644 --- a/fs/squashfs/file.c +++ b/fs/squashfs/file.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
| 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
diff --git a/fs/squashfs/fragment.c b/fs/squashfs/fragment.c index 7eef571443c6..1516a6490bfb 100644 --- a/fs/squashfs/fragment.c +++ b/fs/squashfs/fragment.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
| 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
| @@ -71,26 +71,29 @@ int squashfs_frag_lookup(struct super_block *sb, unsigned int fragment, | |||
| 71 | * Read the uncompressed fragment lookup table indexes off disk into memory | 71 | * Read the uncompressed fragment lookup table indexes off disk into memory |
| 72 | */ | 72 | */ |
| 73 | __le64 *squashfs_read_fragment_index_table(struct super_block *sb, | 73 | __le64 *squashfs_read_fragment_index_table(struct super_block *sb, |
| 74 | u64 fragment_table_start, unsigned int fragments) | 74 | u64 fragment_table_start, u64 next_table, unsigned int fragments) |
| 75 | { | 75 | { |
| 76 | unsigned int length = SQUASHFS_FRAGMENT_INDEX_BYTES(fragments); | 76 | unsigned int length = SQUASHFS_FRAGMENT_INDEX_BYTES(fragments); |
| 77 | __le64 *fragment_index; | 77 | __le64 *table; |
| 78 | int err; | ||
| 79 | 78 | ||
| 80 | /* Allocate fragment lookup table indexes */ | 79 | /* |
| 81 | fragment_index = kmalloc(length, GFP_KERNEL); | 80 | * Sanity check, length bytes should not extend into the next table - |
| 82 | if (fragment_index == NULL) { | 81 | * this check also traps instances where fragment_table_start is |
| 83 | ERROR("Failed to allocate fragment index table\n"); | 82 | * incorrectly larger than the next table start |
| 84 | return ERR_PTR(-ENOMEM); | 83 | */ |
| 85 | } | 84 | if (fragment_table_start + length > next_table) |
| 85 | return ERR_PTR(-EINVAL); | ||
| 86 | |||
| 87 | table = squashfs_read_table(sb, fragment_table_start, length); | ||
| 86 | 88 | ||
| 87 | err = squashfs_read_table(sb, fragment_index, fragment_table_start, | 89 | /* |
| 88 | length); | 90 | * table[0] points to the first fragment table metadata block, this |
| 89 | if (err < 0) { | 91 | * should be less than fragment_table_start |
| 90 | ERROR("unable to read fragment index table\n"); | 92 | */ |
| 91 | kfree(fragment_index); | 93 | if (!IS_ERR(table) && table[0] >= fragment_table_start) { |
| 92 | return ERR_PTR(err); | 94 | kfree(table); |
| 95 | return ERR_PTR(-EINVAL); | ||
| 93 | } | 96 | } |
| 94 | 97 | ||
| 95 | return fragment_index; | 98 | return table; |
| 96 | } | 99 | } |
diff --git a/fs/squashfs/id.c b/fs/squashfs/id.c index d8f32452638e..a70858e0fb44 100644 --- a/fs/squashfs/id.c +++ b/fs/squashfs/id.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
| 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
| @@ -66,27 +66,37 @@ int squashfs_get_id(struct super_block *sb, unsigned int index, | |||
| 66 | * Read uncompressed id lookup table indexes from disk into memory | 66 | * Read uncompressed id lookup table indexes from disk into memory |
| 67 | */ | 67 | */ |
| 68 | __le64 *squashfs_read_id_index_table(struct super_block *sb, | 68 | __le64 *squashfs_read_id_index_table(struct super_block *sb, |
| 69 | u64 id_table_start, unsigned short no_ids) | 69 | u64 id_table_start, u64 next_table, unsigned short no_ids) |
| 70 | { | 70 | { |
| 71 | unsigned int length = SQUASHFS_ID_BLOCK_BYTES(no_ids); | 71 | unsigned int length = SQUASHFS_ID_BLOCK_BYTES(no_ids); |
| 72 | __le64 *id_table; | 72 | __le64 *table; |
| 73 | int err; | ||
| 74 | 73 | ||
| 75 | TRACE("In read_id_index_table, length %d\n", length); | 74 | TRACE("In read_id_index_table, length %d\n", length); |
| 76 | 75 | ||
| 77 | /* Allocate id lookup table indexes */ | 76 | /* Sanity check values */ |
| 78 | id_table = kmalloc(length, GFP_KERNEL); | 77 | |
| 79 | if (id_table == NULL) { | 78 | /* there should always be at least one id */ |
| 80 | ERROR("Failed to allocate id index table\n"); | 79 | if (no_ids == 0) |
| 81 | return ERR_PTR(-ENOMEM); | 80 | return ERR_PTR(-EINVAL); |
| 82 | } | 81 | |
| 82 | /* | ||
| 83 | * length bytes should not extend into the next table - this check | ||
| 84 | * also traps instances where id_table_start is incorrectly larger | ||
| 85 | * than the next table start | ||
| 86 | */ | ||
| 87 | if (id_table_start + length > next_table) | ||
| 88 | return ERR_PTR(-EINVAL); | ||
| 89 | |||
| 90 | table = squashfs_read_table(sb, id_table_start, length); | ||
| 83 | 91 | ||
| 84 | err = squashfs_read_table(sb, id_table, id_table_start, length); | 92 | /* |
| 85 | if (err < 0) { | 93 | * table[0] points to the first id lookup table metadata block, this |
| 86 | ERROR("unable to read id index table\n"); | 94 | * should be less than id_table_start |
| 87 | kfree(id_table); | 95 | */ |
| 88 | return ERR_PTR(err); | 96 | if (!IS_ERR(table) && table[0] >= id_table_start) { |
| 97 | kfree(table); | ||
| 98 | return ERR_PTR(-EINVAL); | ||
| 89 | } | 99 | } |
| 90 | 100 | ||
| 91 | return id_table; | 101 | return table; |
| 92 | } | 102 | } |
diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c index 62e63ad25075..04bebcaa2373 100644 --- a/fs/squashfs/inode.c +++ b/fs/squashfs/inode.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
| 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
diff --git a/fs/squashfs/namei.c b/fs/squashfs/namei.c index 5d922a6701ab..4bc63ac64bc0 100644 --- a/fs/squashfs/namei.c +++ b/fs/squashfs/namei.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
| 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
diff --git a/fs/squashfs/squashfs.h b/fs/squashfs/squashfs.h index 1f2e608b8785..e3be6a71cfa7 100644 --- a/fs/squashfs/squashfs.h +++ b/fs/squashfs/squashfs.h | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
| 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
| @@ -44,24 +44,24 @@ extern struct squashfs_cache_entry *squashfs_get_fragment(struct super_block *, | |||
| 44 | u64, int); | 44 | u64, int); |
| 45 | extern struct squashfs_cache_entry *squashfs_get_datablock(struct super_block *, | 45 | extern struct squashfs_cache_entry *squashfs_get_datablock(struct super_block *, |
| 46 | u64, int); | 46 | u64, int); |
| 47 | extern int squashfs_read_table(struct super_block *, void *, u64, int); | 47 | extern void *squashfs_read_table(struct super_block *, u64, int); |
| 48 | 48 | ||
| 49 | /* decompressor.c */ | 49 | /* decompressor.c */ |
| 50 | extern const struct squashfs_decompressor *squashfs_lookup_decompressor(int); | 50 | extern const struct squashfs_decompressor *squashfs_lookup_decompressor(int); |
| 51 | extern void *squashfs_decompressor_init(struct super_block *, unsigned short); | 51 | extern void *squashfs_decompressor_init(struct super_block *, unsigned short); |
| 52 | 52 | ||
| 53 | /* export.c */ | 53 | /* export.c */ |
| 54 | extern __le64 *squashfs_read_inode_lookup_table(struct super_block *, u64, | 54 | extern __le64 *squashfs_read_inode_lookup_table(struct super_block *, u64, u64, |
| 55 | unsigned int); | 55 | unsigned int); |
| 56 | 56 | ||
| 57 | /* fragment.c */ | 57 | /* fragment.c */ |
| 58 | extern int squashfs_frag_lookup(struct super_block *, unsigned int, u64 *); | 58 | extern int squashfs_frag_lookup(struct super_block *, unsigned int, u64 *); |
| 59 | extern __le64 *squashfs_read_fragment_index_table(struct super_block *, | 59 | extern __le64 *squashfs_read_fragment_index_table(struct super_block *, |
| 60 | u64, unsigned int); | 60 | u64, u64, unsigned int); |
| 61 | 61 | ||
| 62 | /* id.c */ | 62 | /* id.c */ |
| 63 | extern int squashfs_get_id(struct super_block *, unsigned int, unsigned int *); | 63 | extern int squashfs_get_id(struct super_block *, unsigned int, unsigned int *); |
| 64 | extern __le64 *squashfs_read_id_index_table(struct super_block *, u64, | 64 | extern __le64 *squashfs_read_id_index_table(struct super_block *, u64, u64, |
| 65 | unsigned short); | 65 | unsigned short); |
| 66 | 66 | ||
| 67 | /* inode.c */ | 67 | /* inode.c */ |
diff --git a/fs/squashfs/squashfs_fs.h b/fs/squashfs/squashfs_fs.h index 4582c568ef4d..b4a4e539a08c 100644 --- a/fs/squashfs/squashfs_fs.h +++ b/fs/squashfs/squashfs_fs.h | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | * Squashfs | 4 | * Squashfs |
| 5 | * | 5 | * |
| 6 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 6 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
| 7 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 7 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 8 | * | 8 | * |
| 9 | * This program is free software; you can redistribute it and/or | 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License | 10 | * modify it under the terms of the GNU General Public License |
diff --git a/fs/squashfs/squashfs_fs_i.h b/fs/squashfs/squashfs_fs_i.h index 359baefc01fc..73588e7700ed 100644 --- a/fs/squashfs/squashfs_fs_i.h +++ b/fs/squashfs/squashfs_fs_i.h | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | * Squashfs | 4 | * Squashfs |
| 5 | * | 5 | * |
| 6 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 6 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
| 7 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 7 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 8 | * | 8 | * |
| 9 | * This program is free software; you can redistribute it and/or | 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License | 10 | * modify it under the terms of the GNU General Public License |
diff --git a/fs/squashfs/squashfs_fs_sb.h b/fs/squashfs/squashfs_fs_sb.h index d9037a5215f0..651f0b31d296 100644 --- a/fs/squashfs/squashfs_fs_sb.h +++ b/fs/squashfs/squashfs_fs_sb.h | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | * Squashfs | 4 | * Squashfs |
| 5 | * | 5 | * |
| 6 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 6 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
| 7 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 7 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 8 | * | 8 | * |
| 9 | * This program is free software; you can redistribute it and/or | 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License | 10 | * modify it under the terms of the GNU General Public License |
diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c index 5c8184c061a4..6f26abee3597 100644 --- a/fs/squashfs/super.c +++ b/fs/squashfs/super.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
| 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
| @@ -83,7 +83,7 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 83 | long long root_inode; | 83 | long long root_inode; |
| 84 | unsigned short flags; | 84 | unsigned short flags; |
| 85 | unsigned int fragments; | 85 | unsigned int fragments; |
| 86 | u64 lookup_table_start, xattr_id_table_start; | 86 | u64 lookup_table_start, xattr_id_table_start, next_table; |
| 87 | int err; | 87 | int err; |
| 88 | 88 | ||
| 89 | TRACE("Entered squashfs_fill_superblock\n"); | 89 | TRACE("Entered squashfs_fill_superblock\n"); |
| @@ -95,12 +95,6 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 95 | } | 95 | } |
| 96 | msblk = sb->s_fs_info; | 96 | msblk = sb->s_fs_info; |
| 97 | 97 | ||
| 98 | sblk = kzalloc(sizeof(*sblk), GFP_KERNEL); | ||
| 99 | if (sblk == NULL) { | ||
| 100 | ERROR("Failed to allocate squashfs_super_block\n"); | ||
| 101 | goto failure; | ||
| 102 | } | ||
| 103 | |||
| 104 | msblk->devblksize = sb_min_blocksize(sb, BLOCK_SIZE); | 98 | msblk->devblksize = sb_min_blocksize(sb, BLOCK_SIZE); |
| 105 | msblk->devblksize_log2 = ffz(~msblk->devblksize); | 99 | msblk->devblksize_log2 = ffz(~msblk->devblksize); |
| 106 | 100 | ||
| @@ -114,10 +108,12 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 114 | * of bytes_used) we need to set it to an initial sensible dummy value | 108 | * of bytes_used) we need to set it to an initial sensible dummy value |
| 115 | */ | 109 | */ |
| 116 | msblk->bytes_used = sizeof(*sblk); | 110 | msblk->bytes_used = sizeof(*sblk); |
| 117 | err = squashfs_read_table(sb, sblk, SQUASHFS_START, sizeof(*sblk)); | 111 | sblk = squashfs_read_table(sb, SQUASHFS_START, sizeof(*sblk)); |
| 118 | 112 | ||
| 119 | if (err < 0) { | 113 | if (IS_ERR(sblk)) { |
| 120 | ERROR("unable to read squashfs_super_block\n"); | 114 | ERROR("unable to read squashfs_super_block\n"); |
| 115 | err = PTR_ERR(sblk); | ||
| 116 | sblk = NULL; | ||
| 121 | goto failed_mount; | 117 | goto failed_mount; |
| 122 | } | 118 | } |
| 123 | 119 | ||
| @@ -218,18 +214,61 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 218 | goto failed_mount; | 214 | goto failed_mount; |
| 219 | } | 215 | } |
| 220 | 216 | ||
| 217 | /* Handle xattrs */ | ||
| 218 | sb->s_xattr = squashfs_xattr_handlers; | ||
| 219 | xattr_id_table_start = le64_to_cpu(sblk->xattr_id_table_start); | ||
| 220 | if (xattr_id_table_start == SQUASHFS_INVALID_BLK) { | ||
| 221 | next_table = msblk->bytes_used; | ||
| 222 | goto allocate_id_index_table; | ||
| 223 | } | ||
| 224 | |||
| 225 | /* Allocate and read xattr id lookup table */ | ||
| 226 | msblk->xattr_id_table = squashfs_read_xattr_id_table(sb, | ||
| 227 | xattr_id_table_start, &msblk->xattr_table, &msblk->xattr_ids); | ||
| 228 | if (IS_ERR(msblk->xattr_id_table)) { | ||
| 229 | ERROR("unable to read xattr id index table\n"); | ||
| 230 | err = PTR_ERR(msblk->xattr_id_table); | ||
| 231 | msblk->xattr_id_table = NULL; | ||
| 232 | if (err != -ENOTSUPP) | ||
| 233 | goto failed_mount; | ||
| 234 | } | ||
| 235 | next_table = msblk->xattr_table; | ||
| 236 | |||
| 237 | allocate_id_index_table: | ||
| 221 | /* Allocate and read id index table */ | 238 | /* Allocate and read id index table */ |
| 222 | msblk->id_table = squashfs_read_id_index_table(sb, | 239 | msblk->id_table = squashfs_read_id_index_table(sb, |
| 223 | le64_to_cpu(sblk->id_table_start), le16_to_cpu(sblk->no_ids)); | 240 | le64_to_cpu(sblk->id_table_start), next_table, |
| 241 | le16_to_cpu(sblk->no_ids)); | ||
| 224 | if (IS_ERR(msblk->id_table)) { | 242 | if (IS_ERR(msblk->id_table)) { |
| 243 | ERROR("unable to read id index table\n"); | ||
| 225 | err = PTR_ERR(msblk->id_table); | 244 | err = PTR_ERR(msblk->id_table); |
| 226 | msblk->id_table = NULL; | 245 | msblk->id_table = NULL; |
| 227 | goto failed_mount; | 246 | goto failed_mount; |
| 228 | } | 247 | } |
| 248 | next_table = msblk->id_table[0]; | ||
| 249 | |||
| 250 | /* Handle inode lookup table */ | ||
| 251 | lookup_table_start = le64_to_cpu(sblk->lookup_table_start); | ||
| 252 | if (lookup_table_start == SQUASHFS_INVALID_BLK) | ||
| 253 | goto handle_fragments; | ||
| 254 | |||
| 255 | /* Allocate and read inode lookup table */ | ||
| 256 | msblk->inode_lookup_table = squashfs_read_inode_lookup_table(sb, | ||
| 257 | lookup_table_start, next_table, msblk->inodes); | ||
| 258 | if (IS_ERR(msblk->inode_lookup_table)) { | ||
| 259 | ERROR("unable to read inode lookup table\n"); | ||
| 260 | err = PTR_ERR(msblk->inode_lookup_table); | ||
| 261 | msblk->inode_lookup_table = NULL; | ||
| 262 | goto failed_mount; | ||
| 263 | } | ||
| 264 | next_table = msblk->inode_lookup_table[0]; | ||
| 229 | 265 | ||
| 266 | sb->s_export_op = &squashfs_export_ops; | ||
| 267 | |||
| 268 | handle_fragments: | ||
| 230 | fragments = le32_to_cpu(sblk->fragments); | 269 | fragments = le32_to_cpu(sblk->fragments); |
| 231 | if (fragments == 0) | 270 | if (fragments == 0) |
| 232 | goto allocate_lookup_table; | 271 | goto check_directory_table; |
| 233 | 272 | ||
| 234 | msblk->fragment_cache = squashfs_cache_init("fragment", | 273 | msblk->fragment_cache = squashfs_cache_init("fragment", |
| 235 | SQUASHFS_CACHED_FRAGMENTS, msblk->block_size); | 274 | SQUASHFS_CACHED_FRAGMENTS, msblk->block_size); |
| @@ -240,45 +279,29 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent) | |||
| 240 | 279 | ||
| 241 | /* Allocate and read fragment index table */ | 280 | /* Allocate and read fragment index table */ |
| 242 | msblk->fragment_index = squashfs_read_fragment_index_table(sb, | 281 | msblk->fragment_index = squashfs_read_fragment_index_table(sb, |
| 243 | le64_to_cpu(sblk->fragment_table_start), fragments); | 282 | le64_to_cpu(sblk->fragment_table_start), next_table, fragments); |
| 244 | if (IS_ERR(msblk->fragment_index)) { | 283 | if (IS_ERR(msblk->fragment_index)) { |
| 284 | ERROR("unable to read fragment index table\n"); | ||
| 245 | err = PTR_ERR(msblk->fragment_index); | 285 | err = PTR_ERR(msblk->fragment_index); |
| 246 | msblk->fragment_index = NULL; | 286 | msblk->fragment_index = NULL; |
| 247 | goto failed_mount; | 287 | goto failed_mount; |
| 248 | } | 288 | } |
| 289 | next_table = msblk->fragment_index[0]; | ||
| 249 | 290 | ||
| 250 | allocate_lookup_table: | 291 | check_directory_table: |
| 251 | lookup_table_start = le64_to_cpu(sblk->lookup_table_start); | 292 | /* Sanity check directory_table */ |
| 252 | if (lookup_table_start == SQUASHFS_INVALID_BLK) | 293 | if (msblk->directory_table >= next_table) { |
| 253 | goto allocate_xattr_table; | 294 | err = -EINVAL; |
| 254 | |||
| 255 | /* Allocate and read inode lookup table */ | ||
| 256 | msblk->inode_lookup_table = squashfs_read_inode_lookup_table(sb, | ||
| 257 | lookup_table_start, msblk->inodes); | ||
| 258 | if (IS_ERR(msblk->inode_lookup_table)) { | ||
| 259 | err = PTR_ERR(msblk->inode_lookup_table); | ||
| 260 | msblk->inode_lookup_table = NULL; | ||
| 261 | goto failed_mount; | 295 | goto failed_mount; |
| 262 | } | 296 | } |
| 263 | 297 | ||
| 264 | sb->s_export_op = &squashfs_export_ops; | 298 | /* Sanity check inode_table */ |
| 265 | 299 | if (msblk->inode_table >= msblk->directory_table) { | |
| 266 | allocate_xattr_table: | 300 | err = -EINVAL; |
| 267 | sb->s_xattr = squashfs_xattr_handlers; | 301 | goto failed_mount; |
| 268 | xattr_id_table_start = le64_to_cpu(sblk->xattr_id_table_start); | ||
| 269 | if (xattr_id_table_start == SQUASHFS_INVALID_BLK) | ||
| 270 | goto allocate_root; | ||
| 271 | |||
| 272 | /* Allocate and read xattr id lookup table */ | ||
| 273 | msblk->xattr_id_table = squashfs_read_xattr_id_table(sb, | ||
| 274 | xattr_id_table_start, &msblk->xattr_table, &msblk->xattr_ids); | ||
| 275 | if (IS_ERR(msblk->xattr_id_table)) { | ||
| 276 | err = PTR_ERR(msblk->xattr_id_table); | ||
| 277 | msblk->xattr_id_table = NULL; | ||
| 278 | if (err != -ENOTSUPP) | ||
| 279 | goto failed_mount; | ||
| 280 | } | 302 | } |
| 281 | allocate_root: | 303 | |
| 304 | /* allocate root */ | ||
| 282 | root = new_inode(sb); | 305 | root = new_inode(sb); |
| 283 | if (!root) { | 306 | if (!root) { |
| 284 | err = -ENOMEM; | 307 | err = -ENOMEM; |
| @@ -318,11 +341,6 @@ failed_mount: | |||
| 318 | sb->s_fs_info = NULL; | 341 | sb->s_fs_info = NULL; |
| 319 | kfree(sblk); | 342 | kfree(sblk); |
| 320 | return err; | 343 | return err; |
| 321 | |||
| 322 | failure: | ||
| 323 | kfree(sb->s_fs_info); | ||
| 324 | sb->s_fs_info = NULL; | ||
| 325 | return -ENOMEM; | ||
| 326 | } | 344 | } |
| 327 | 345 | ||
| 328 | 346 | ||
| @@ -475,5 +493,5 @@ static const struct super_operations squashfs_super_ops = { | |||
| 475 | module_init(init_squashfs_fs); | 493 | module_init(init_squashfs_fs); |
| 476 | module_exit(exit_squashfs_fs); | 494 | module_exit(exit_squashfs_fs); |
| 477 | MODULE_DESCRIPTION("squashfs 4.0, a compressed read-only filesystem"); | 495 | MODULE_DESCRIPTION("squashfs 4.0, a compressed read-only filesystem"); |
| 478 | MODULE_AUTHOR("Phillip Lougher <phillip@lougher.demon.co.uk>"); | 496 | MODULE_AUTHOR("Phillip Lougher <phillip@squashfs.org.uk>"); |
| 479 | MODULE_LICENSE("GPL"); | 497 | MODULE_LICENSE("GPL"); |
diff --git a/fs/squashfs/symlink.c b/fs/squashfs/symlink.c index ec86434921e1..1191817264cc 100644 --- a/fs/squashfs/symlink.c +++ b/fs/squashfs/symlink.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
| 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
diff --git a/fs/squashfs/xattr.c b/fs/squashfs/xattr.c index 3876c36699a1..92fcde7b4d61 100644 --- a/fs/squashfs/xattr.c +++ b/fs/squashfs/xattr.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2010 | 4 | * Copyright (c) 2010 |
| 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
diff --git a/fs/squashfs/xattr.h b/fs/squashfs/xattr.h index b634efce4bde..c83f5d9ec125 100644 --- a/fs/squashfs/xattr.h +++ b/fs/squashfs/xattr.h | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2010 | 4 | * Copyright (c) 2010 |
| 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
| @@ -31,6 +31,7 @@ static inline __le64 *squashfs_read_xattr_id_table(struct super_block *sb, | |||
| 31 | u64 start, u64 *xattr_table_start, int *xattr_ids) | 31 | u64 start, u64 *xattr_table_start, int *xattr_ids) |
| 32 | { | 32 | { |
| 33 | ERROR("Xattrs in filesystem, these will be ignored\n"); | 33 | ERROR("Xattrs in filesystem, these will be ignored\n"); |
| 34 | *xattr_table_start = start; | ||
| 34 | return ERR_PTR(-ENOTSUPP); | 35 | return ERR_PTR(-ENOTSUPP); |
| 35 | } | 36 | } |
| 36 | 37 | ||
diff --git a/fs/squashfs/xattr_id.c b/fs/squashfs/xattr_id.c index 05385dbe1465..c89607d690c4 100644 --- a/fs/squashfs/xattr_id.c +++ b/fs/squashfs/xattr_id.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2010 | 4 | * Copyright (c) 2010 |
| 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
| @@ -67,34 +67,29 @@ __le64 *squashfs_read_xattr_id_table(struct super_block *sb, u64 start, | |||
| 67 | u64 *xattr_table_start, int *xattr_ids) | 67 | u64 *xattr_table_start, int *xattr_ids) |
| 68 | { | 68 | { |
| 69 | unsigned int len; | 69 | unsigned int len; |
| 70 | __le64 *xid_table; | 70 | struct squashfs_xattr_id_table *id_table; |
| 71 | struct squashfs_xattr_id_table id_table; | 71 | |
| 72 | int err; | 72 | id_table = squashfs_read_table(sb, start, sizeof(*id_table)); |
| 73 | if (IS_ERR(id_table)) | ||
| 74 | return (__le64 *) id_table; | ||
| 75 | |||
| 76 | *xattr_table_start = le64_to_cpu(id_table->xattr_table_start); | ||
| 77 | *xattr_ids = le32_to_cpu(id_table->xattr_ids); | ||
| 78 | kfree(id_table); | ||
| 79 | |||
| 80 | /* Sanity check values */ | ||
| 81 | |||
| 82 | /* there is always at least one xattr id */ | ||
| 83 | if (*xattr_ids == 0) | ||
| 84 | return ERR_PTR(-EINVAL); | ||
| 85 | |||
| 86 | /* xattr_table should be less than start */ | ||
| 87 | if (*xattr_table_start >= start) | ||
| 88 | return ERR_PTR(-EINVAL); | ||
| 73 | 89 | ||
| 74 | err = squashfs_read_table(sb, &id_table, start, sizeof(id_table)); | ||
| 75 | if (err < 0) { | ||
| 76 | ERROR("unable to read xattr id table\n"); | ||
| 77 | return ERR_PTR(err); | ||
| 78 | } | ||
| 79 | *xattr_table_start = le64_to_cpu(id_table.xattr_table_start); | ||
| 80 | *xattr_ids = le32_to_cpu(id_table.xattr_ids); | ||
| 81 | len = SQUASHFS_XATTR_BLOCK_BYTES(*xattr_ids); | 90 | len = SQUASHFS_XATTR_BLOCK_BYTES(*xattr_ids); |
| 82 | 91 | ||
| 83 | TRACE("In read_xattr_index_table, length %d\n", len); | 92 | TRACE("In read_xattr_index_table, length %d\n", len); |
| 84 | 93 | ||
| 85 | /* Allocate xattr id lookup table indexes */ | 94 | return squashfs_read_table(sb, start + sizeof(*id_table), len); |
| 86 | xid_table = kmalloc(len, GFP_KERNEL); | ||
| 87 | if (xid_table == NULL) { | ||
| 88 | ERROR("Failed to allocate xattr id index table\n"); | ||
| 89 | return ERR_PTR(-ENOMEM); | ||
| 90 | } | ||
| 91 | |||
| 92 | err = squashfs_read_table(sb, xid_table, start + sizeof(id_table), len); | ||
| 93 | if (err < 0) { | ||
| 94 | ERROR("unable to read xattr id index table\n"); | ||
| 95 | kfree(xid_table); | ||
| 96 | return ERR_PTR(err); | ||
| 97 | } | ||
| 98 | |||
| 99 | return xid_table; | ||
| 100 | } | 95 | } |
diff --git a/fs/squashfs/xz_wrapper.c b/fs/squashfs/xz_wrapper.c index aa47a286d1f8..1760b7d108f6 100644 --- a/fs/squashfs/xz_wrapper.c +++ b/fs/squashfs/xz_wrapper.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 | 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
| 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
diff --git a/fs/squashfs/zlib_wrapper.c b/fs/squashfs/zlib_wrapper.c index 517688b32ffa..55d918fd2d86 100644 --- a/fs/squashfs/zlib_wrapper.c +++ b/fs/squashfs/zlib_wrapper.c | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | * Squashfs - a compressed read only filesystem for Linux | 2 | * Squashfs - a compressed read only filesystem for Linux |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 | 4 | * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
| 5 | * Phillip Lougher <phillip@lougher.demon.co.uk> | 5 | * Phillip Lougher <phillip@squashfs.org.uk> |
| 6 | * | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License | 8 | * modify it under the terms of the GNU General Public License |
