]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ext2: Fix fs corruption in ext2_get_xip_mem()
authorJan Kara <jack@suse.cz>
Tue, 5 Nov 2013 00:15:38 +0000 (01:15 +0100)
committerJiri Slaby <jslaby@suse.cz>
Fri, 31 Oct 2014 14:11:34 +0000 (15:11 +0100)
commit08f5fb0099a95c28676f8afe36e1d83f8234d002
treee5ec5bd60639afd5e65ad79eceb02017d58c79c8
parent19911e16366f1a6ac8dc4ac7d4709c133e165638
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 <andiry.xu@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
fs/ext2/inode.c
fs/ext2/xip.c