Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1586545ybv; Thu, 20 Feb 2020 23:47:51 -0800 (PST) X-Google-Smtp-Source: APXvYqx58pgePGdxF0xn/+iQpI9XwuBUI+O6FlVCwsBy7ubI57/iCtrXjvmIZoza2fECRaUBw8Pu X-Received: by 2002:a9d:6c58:: with SMTP id g24mr28461790otq.229.1582271271470; Thu, 20 Feb 2020 23:47:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582271271; cv=none; d=google.com; s=arc-20160816; b=TlAj2ABFFr3YQm1tjwHKbEbXh9QAL3+EnG8xrz8MMULoolbDKMd6xzSeVsBliBrVn6 bF27F0FzPjk2h0NliLXtBKjA0iI7OaWJq7+9ERMfdkdRrMbP8wTN1ZNKe7+8PkQ4OnwZ ClOQYVEYF/F+CGyEuisvl8xF+W9ZiD0VQHFSfR95OVKQe9dPBWZ6QyI8XTNuc2p2QxX0 d2xIC7CtQlYrTSrIDomigPsid3dCkV46yIyzsJWxBcb5RJwbaHB9XXTSl5DqtBhu70RK 59uOa2yyDTMPRGBJbIrbKbuH67fQjHgv9RW4xik00TZfhV7IkTBzqln8/FNgDxBpr1R1 aVuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PJ6V67zRYtmwKNxLuIkQBMWC33cHfSzvE3xu34ZJhE8=; b=gECquu57Vr5onZ4aTO6HnYcQVMZ/v4y0NAwSd/qbJqTwfY54WwAawXbYam1V5sZRPT /Y2ooH6416fPeNNKCpZBJvwAgg47enC72w08uTQMjcUP+9PRBOjk/NviAoRzcstvT5HX hvwqPoi4iS9GCFXotj65kc7kC6LpolV0e1CUcLJv62ChJ4zfdVp/m36ogzhGcDjEh1Fb Wpr4j4dSqMXmtwV8DIiLaB+MeNiTt4Z6+SJHYD034ohJ8HZ6SOFXJNOM8sf9QhKOeld5 peKM2KyMABgJML0TlSkiTgCRtwUF2VhVIK1MRx8ByFF+NbQx0/yBGv79C2DhsuZcML8i sxTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XceSzoiA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v3si1154745otn.140.2020.02.20.23.47.39; Thu, 20 Feb 2020 23:47:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XceSzoiA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728868AbgBUHrK (ORCPT + 99 others); Fri, 21 Feb 2020 02:47:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:42824 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728327AbgBUHrE (ORCPT ); Fri, 21 Feb 2020 02:47:04 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A151224673; Fri, 21 Feb 2020 07:47:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582271224; bh=pRskqeaNfrHsjSKu/BICCOe1KcKWegziRhTbDGCm92Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XceSzoiA2abMsevzDSv3BG8dRxlME5H0pNFcGK9UHUKvjdKutIK1j3ZYVhTawI96U r5Jgf4S5YNOMSuYrpx1NeEJrGMkG6oGQ5CCEjJ9/uSGYWd0CSIQU9fJZu8a6DB12ZF QQ57GfaZSEPcTRgGtFBljhnzfhwpIklfFxfZnFNQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "zhangyi (F)" , Jan Kara , Theodore Tso , Sasha Levin Subject: [PATCH 5.5 086/399] ext4, jbd2: ensure panic when aborting with zero errno Date: Fri, 21 Feb 2020 08:36:51 +0100 Message-Id: <20200221072410.685318711@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072402.315346745@linuxfoundation.org> References: <20200221072402.315346745@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 8fff6677a5da4..96bf33986d030 100644 --- a/fs/jbd2/checkpoint.c +++ b/fs/jbd2/checkpoint.c @@ -164,7 +164,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 6847b18455068..8479e84159675 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -2156,12 +2156,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); } /** @@ -2203,11 +2201,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