diff options
author | Fabian Frederick <fabf@skynet.be> | 2014-08-08 17:20:31 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-08 18:57:20 -0400 |
commit | 8e19189ef8d1fce44f3acdf0fe9846cff9b37c78 (patch) | |
tree | 0c4af0f63e37fa6353cf71002a4e500d5c5a0365 /fs | |
parent | 6d6747f85314687f72012ae85cde401db531e130 (diff) |
fs/befs/linuxvfs.c: check superblock before dump operation
befs_dump_super_block was called between befs_load_sb and befs_check_sb.
It has been reported to crash (5/900) with null block testing.
This patch loads, checks and only dump superblock if it's a valid one
then brelse bh.
(befs_dump_super_block uses disk_sb (bh->b_data) so it seems we need to
call it before brelse(bh) but I don't know why befs_check_sb was called
after brelse. Another thing I don't understand is why this problem
appears now).
Signed-off-by: Fabian Frederick <fabf@skynet.be>
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/befs/linuxvfs.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 0d6c07cc1149..4cf61ec6b7a8 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c | |||
@@ -832,16 +832,14 @@ befs_fill_super(struct super_block *sb, void *data, int silent) | |||
832 | (befs_super_block *) ((void *) bh->b_data + x86_sb_off); | 832 | (befs_super_block *) ((void *) bh->b_data + x86_sb_off); |
833 | } | 833 | } |
834 | 834 | ||
835 | if (befs_load_sb(sb, disk_sb) != BEFS_OK) | 835 | if ((befs_load_sb(sb, disk_sb) != BEFS_OK) || |
836 | (befs_check_sb(sb) != BEFS_OK)) | ||
836 | goto unacquire_bh; | 837 | goto unacquire_bh; |
837 | 838 | ||
838 | befs_dump_super_block(sb, disk_sb); | 839 | befs_dump_super_block(sb, disk_sb); |
839 | 840 | ||
840 | brelse(bh); | 841 | brelse(bh); |
841 | 842 | ||
842 | if (befs_check_sb(sb) != BEFS_OK) | ||
843 | goto unacquire_priv_sbp; | ||
844 | |||
845 | if( befs_sb->num_blocks > ~((sector_t)0) ) { | 843 | if( befs_sb->num_blocks > ~((sector_t)0) ) { |
846 | befs_error(sb, "blocks count: %llu " | 844 | befs_error(sb, "blocks count: %llu " |
847 | "is larger than the host can use", | 845 | "is larger than the host can use", |