jbd2: Fix possible overflow in jbd2_log_space_left()
authorJan Kara <jack@suse.cz>
Tue, 5 Nov 2019 16:44:07 +0000 (17:44 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 13 Dec 2019 07:42:53 +0000 (08:42 +0100)
commit1a6a96e0ff4681e579c98ed0fd16aff5f1ffadbf
tree0edc624577a17ec9a7575960327a8803db394ed8
parent01e7ab5b9b0549f249c854e6783a3d0618cd825e
jbd2: Fix possible overflow in jbd2_log_space_left()

commit add3efdd78b8a0478ce423bb9d4df6bd95e8b335 upstream.

When number of free space in the journal is very low, the arithmetic in
jbd2_log_space_left() could underflow resulting in very high number of
free blocks and thus triggering assertion failure in transaction commit
code complaining there's not enough space in the journal:

J_ASSERT(journal->j_free > 1);

Properly check for the low number of free blocks.

CC: stable@vger.kernel.org
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20191105164437.32602-1-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/jbd2.h