From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5ED37C3B1A1 for ; Fri, 14 Feb 2020 16:56:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2CFE2206CC for ; Fri, 14 Feb 2020 16:56:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581699368; bh=hGJH4e4WHh4KiOewsd+q2tpBo8BfWBTTPipxQ1Ov9MM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=CgQFydd80q1BJPMt810W3WiRXCyyF22RRvvJ2oRjAwf0LTOdIEIC2W4Lx8Nzh/yzh 8BV1XJ/Nd4W2K7BXpAoOKdFma78qwwPoUeq0vf6ZRJWNcq+5jDq5U51ASMr4X5KVZ3 gW+8knOWq7saj9TKoLsq2gfQPQvA2GaLywkzM7v0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394261AbgBNQ4H (ORCPT ); Fri, 14 Feb 2020 11:56:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:49870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388980AbgBNQSG (ORCPT ); Fri, 14 Feb 2020 11:18:06 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 62DDF24701; Fri, 14 Feb 2020 16:18:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581697086; bh=hGJH4e4WHh4KiOewsd+q2tpBo8BfWBTTPipxQ1Ov9MM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kTgfxCWdL4LgzlL3LUaY10UupM+wiDCe6Jqs6mkdNyOWlX9DdH+qu1KaMBYTrKHPW EMWtSHOV8q7sBzJbS5+raitnQaJQupCIvkRYKh24mbczhXq58l8L9sEKhsRja7KJnu Dg0svjPHSkVXpxdi/Ge8LApZ3oJvzkG5tUtM3P8U= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "zhangyi (F)" , Jan Kara , Theodore Ts'o , Sasha Levin , linux-ext4@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 039/186] ext4, jbd2: ensure panic when aborting with zero errno Date: Fri, 14 Feb 2020 11:14:48 -0500 Message-Id: <20200214161715.18113-39-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214161715.18113-1-sashal@kernel.org> References: <20200214161715.18113-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: "zhangyi (F)" [ Upstream commit 51f57b01e4a3c7d7bdceffd84de35144e8c538e7 ] JBD2_REC_ERR flag used to indicate the errno has been updated when jbd2 aborted, and then __ext4_abort() and ext4_handle_error() can invoke panic if ERRORS_PANIC is specified. But if the journal has been aborted with zero errno, jbd2_journal_abort() didn't set this flag so we can no longer panic. Fix this by always record the proper errno in the journal superblock. Fixes: 4327ba52afd03 ("ext4, jbd2: ensure entering into panic after recording an error in superblock") Signed-off-by: zhangyi (F) Reviewed-by: Jan Kara Link: https://lore.kernel.org/r/20191204124614.45424-3-yi.zhang@huawei.com Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/jbd2/checkpoint.c | 2 +- fs/jbd2/journal.c | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c index fe4fe155b7fbe..15d129b7494b0 100644 --- a/fs/jbd2/checkpoint.c +++ b/fs/jbd2/checkpoint.c @@ -168,7 +168,7 @@ void __jbd2_log_wait_for_space(journal_t *journal) "journal space in %s\n", __func__, journal->j_devname); WARN_ON(1); - jbd2_journal_abort(journal, 0); + jbd2_journal_abort(journal, -EIO); } write_lock(&journal->j_state_lock); } else { diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index b72be822f04f2..eae9ced846d51 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -2128,12 +2128,10 @@ static void __journal_abort_soft (journal_t *journal, int errno) __jbd2_journal_abort_hard(journal); - if (errno) { - jbd2_journal_update_sb_errno(journal); - write_lock(&journal->j_state_lock); - journal->j_flags |= JBD2_REC_ERR; - write_unlock(&journal->j_state_lock); - } + jbd2_journal_update_sb_errno(journal); + write_lock(&journal->j_state_lock); + journal->j_flags |= JBD2_REC_ERR; + write_unlock(&journal->j_state_lock); } /** @@ -2175,11 +2173,6 @@ static void __journal_abort_soft (journal_t *journal, int errno) * failure to disk. ext3_error, for example, now uses this * functionality. * - * Errors which originate from within the journaling layer will NOT - * supply an errno; a null errno implies that absolutely no further - * writes are done to the journal (unless there are any already in - * progress). - * */ void jbd2_journal_abort(journal_t *journal, int errno) -- 2.20.1