jbd2: Avoid possible NULL dereference in jbd2_journal_begin_ordered_truncate()
authorJan Kara <jack@suse.cz>
Tue, 24 Feb 2009 21:13:18 +0000 (16:13 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 17 Mar 2009 00:53:04 +0000 (17:53 -0700)
commitfb05f46cabf4c96f5f8648c6a85d897ed57b1c94
treec556c02fd18094d39ab1982142a42b56534cced2
parent5328f9688e849b1c06d0433424a6c1387a9ade04
jbd2: Avoid possible NULL dereference in jbd2_journal_begin_ordered_truncate()

(cherry picked from commit 7f5aa215088b817add9c71914b83650bdd49f8a9)

If we race with commit code setting i_transaction to NULL, we could
possibly dereference it.  Proper locking requires the journal pointer
(to access journal->j_list_lock), which we don't have.  So we have to
change the prototype of the function so that filesystem passes us the
journal pointer.  Also add a more detailed comment about why the
function jbd2_journal_begin_ordered_truncate() does what it does and
how it should be used.

Thanks to Dan Carpenter <error27@gmail.com> for pointing to the
suspitious code.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Acked-by: Joel Becker <joel.becker@oracle.com>
CC: linux-ext4@vger.kernel.org
CC: mfasheh@suse.de
CC: Dan Carpenter <error27@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/ext4/inode.c
fs/jbd2/transaction.c
include/linux/jbd2.h