From 31b0cfeaaca3cdc7aef12a0123ed772081d8e2dd Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Thu, 20 Feb 2020 15:19:25 +0800 Subject: [PATCH] jbd2: Make credit checking more strict mainline inclusion from mainline-5.5-rc1 commit d090707edab59cb07047d6d7e138ffcc3bdc42be category: bugfix bugzilla: 25031 CVE: NA --------------------------- Make checking of available credits in jbd2_journal_dirty_metadata() more strict. There should be always enough credits in the handle to write all potential revoke descriptors. Also we warn in case there are not enough credits since this is a bug in the filesystem. Reviewed-by: Theodore Ts'o Signed-off-by: Jan Kara Link: https://lore.kernel.org/r/20191105164437.32602-22-jack@suse.cz Signed-off-by: Theodore Ts'o Signed-off-by: zhangyi (F) Reviewed-by: Yang Erkun Signed-off-by: Yang Yingliang --- fs/jbd2/transaction.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index 45f9f06c3e68..247f61fc6bfe 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -1443,7 +1443,7 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) * of the transaction. This needs to be done * once a transaction -bzzz */ - if (handle->h_total_credits <= 0) { + if (WARN_ON_ONCE(jbd2_handle_buffer_credits(handle) <= 0)) { ret = -ENOSPC; goto out_unlock_bh; } -- GitLab