]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ext4: Fix buffer double free in ext4_alloc_branch()
authorJan Kara <jack@suse.cz>
Mon, 16 Jun 2014 03:46:28 +0000 (23:46 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Jul 2014 18:21:30 +0000 (11:21 -0700)
commit766b962fc5c3599b810776b7c7c79922cd494cbf
treee4e216cf10b22858e6873b21ffaf8afc392a07cf
parent6d70367781d194e87a0f91d8805cfdcd3a417d2f
ext4: Fix buffer double free in ext4_alloc_branch()

commit c5c7b8ddfbf8cb3b2291e515a34ab1b8982f5a2d upstream.

Error recovery in ext4_alloc_branch() calls ext4_forget() even for
buffer corresponding to indirect block it did not allocate. This leads
to brelse() being called twice for that buffer (once from ext4_forget()
and once from cleanup in ext4_ind_map_blocks()) leading to buffer use
count misaccounting. Eventually (but often much later because there
are other users of the buffer) we will see messages like:
VFS: brelse: Trying to free free buffer

Another manifestation of this problem is an error:
JBD2 unexpected failure: jbd2_journal_revoke: !buffer_revoked(bh);
inconsistent data on disk

The fix is easy - don't forget buffer we did not allocate. Also add an
explanatory comment because the indexing at ext4_alloc_branch() is
somewhat subtle.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ext4/indirect.c