summaryrefslogtreecommitdiffstats
path: root/fs/bfs
diff options
context:
space:
mode:
authorEric Sesterhenn <snakebyte@gmx.de>2009-01-06 14:43:13 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-06 15:59:31 -0800
commit50682bb4de35544466c264c017030de826614367 (patch)
tree9e5fc77230deaa459ea4c12fdc3241ad991117e7 /fs/bfs
parente1f89ec95bd28b0927e76c46a7cc0927b7521c1d (diff)
downloadop-kernel-dev-50682bb4de35544466c264c017030de826614367.zip
op-kernel-dev-50682bb4de35544466c264c017030de826614367.tar.gz
bfs: check that filesystem fits on the blockdevice
Since all sanity checks rely on the validity of s_start which gets only checked to be smaller than s_end, we should also check if s_end is sane. Now we also try to retrieve the last block of the filesystem, which is computed by s_end. If this fails, something is bogus. Signed-off-by: Eric Sesterhenn <snakebyte@gmx.de> Acked-by: Tigran Aivazian <tigran@aivazian.fsnet.co.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/bfs')
-rw-r--r--fs/bfs/inode.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c
index 1d2bfaf..cc4062d 100644
--- a/fs/bfs/inode.c
+++ b/fs/bfs/inode.c
@@ -390,6 +390,18 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent)
- le32_to_cpu(bfs_sb->s_start)) >> BFS_BSIZE_BITS;
info->si_freei = 0;
info->si_lf_eblk = 0;
+
+ /* can we read the last block? */
+ bh = sb_bread(s, info->si_blocks - 1);
+ if (!bh) {
+ printf("Last block not available: %lu\n", info->si_blocks - 1);
+ iput(inode);
+ ret = -EIO;
+ kfree(info->si_imap);
+ goto out;
+ }
+ brelse(bh);
+
bh = NULL;
for (i = BFS_ROOT_INO; i <= info->si_lasti; i++) {
struct bfs_inode *di;
OpenPOWER on IntegriCloud