Return-Path: Received: from mail-pl1-f195.google.com ([209.85.214.195]:42454 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727504AbeJEAsT (ORCPT ); Thu, 4 Oct 2018 20:48:19 -0400 Received: by mail-pl1-f195.google.com with SMTP id c8-v6so5544084plo.9 for ; Thu, 04 Oct 2018 10:53:59 -0700 (PDT) From: Greg Hackmann To: stable@vger.kernel.org Cc: Theodore Ts'o , Ben Hutchings , Greg Hackmann Subject: [PATCH 3.18.y 09/10] jbd2: don't mark block as modified if the handle is out of credits Date: Thu, 4 Oct 2018 10:53:19 -0700 Message-Id: <20181004175320.181881-10-ghackmann@google.com> In-Reply-To: <20181004175320.181881-1-ghackmann@google.com> References: <20181004175320.181881-1-ghackmann@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: From: Theodore Ts'o commit e09463f220ca9a1a1ecfda84fcda658f99a1f12a upstream. Do not set the b_modified flag in block's journal head should not until after we're sure that jbd2_journal_dirty_metadat() will not abort with an error due to there not being enough space reserved in the jbd2 handle. Otherwise, future attempts to modify the buffer may lead a large number of spurious errors and warnings. This addresses CVE-2018-10883. https://bugzilla.kernel.org/show_bug.cgi?id=200071 Signed-off-by: Theodore Ts'o [bwh: Backported to 3.16: Drop the added logging statement, as it's on a code path that doesn't exist here] Signed-off-by: Ben Hutchings Signed-off-by: Greg Hackmann --- 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 f3818e7cfa60..ab034f48ffe4 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -1283,11 +1283,11 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) * of the transaction. This needs to be done * once a transaction -bzzz */ - jh->b_modified = 1; if (handle->h_buffer_credits <= 0) { ret = -ENOSPC; goto out_unlock_bh; } + jh->b_modified = 1; handle->h_buffer_credits--; } -- 2.19.0.605.g01d371f741-goog