From: Jan Kara Date: Tue, 5 Nov 2013 00:15:38 +0000 (+0100) Subject: ext2: Fix fs corruption in ext2_get_xip_mem() X-Git-Tag: v3.2.64~7 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b808fd2ef61f6d8bdaabe30b67da3f5ea9948bf;p=pandora-kernel.git ext2: Fix fs corruption in ext2_get_xip_mem() commit 7ba3ec5749ddb61f79f7be17b5fd7720eebc52de upstream. Commit 8e3dffc651cb "Ext2: mark inode dirty after the function dquot_free_block_nodirty is called" unveiled a bug in __ext2_get_block() called from ext2_get_xip_mem(). That function called ext2_get_block() mistakenly asking it to map 0 blocks while 1 was intended. Before the above mentioned commit things worked out fine by luck but after that commit we started returning that we allocated 0 blocks while we in fact allocated 1 block and thus allocation was looping until all blocks in the filesystem were exhausted. Fix the problem by properly asking for one block and also add assertion in ext2_get_blocks() to catch similar problems. Reported-and-tested-by: Andiry Xu Signed-off-by: Jan Kara Signed-off-by: Ben Hutchings --- diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 91a6945af6d8..5a45b8fef4e6 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -619,6 +619,8 @@ static int ext2_get_blocks(struct inode *inode, int count = 0; ext2_fsblk_t first_block = 0; + BUG_ON(maxblocks == 0); + depth = ext2_block_to_path(inode,iblock,offsets,&blocks_to_boundary); if (depth == 0) Reading git-diff-tree failed