Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BB03C7EE23 for ; Mon, 27 Feb 2023 02:11:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230167AbjB0CLs (ORCPT ); Sun, 26 Feb 2023 21:11:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230464AbjB0CLW (ORCPT ); Sun, 26 Feb 2023 21:11:22 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00D411ACE5; Sun, 26 Feb 2023 18:09:43 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D15AE60D27; Mon, 27 Feb 2023 02:09:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DC58C4339B; Mon, 27 Feb 2023 02:09:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677463783; bh=ZJrjEmnYn8UAt5+dZT4FL+asRnsFUcIwm0R2ipWI+bY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MtMTm7SsaDjI8j2otWBRdbhtjUvX3K0LsveJF5jb2pOHnrle1V2l+zdPjflRCcgI1 Pxxaxru8NOd0+x9uHMl8gXmTi8oCv/2CKZUOdLk/Xe9an4NTmYsYdLVHEyf+Nqbu9o riay7g1G3MWqtziPUo7+U+/4CpLXEF06N71zG74kRuyUBEQI1yiEUmXVUMCoje72Hl RU/2dYTnINW3jhtyrtUR+S5TxoOsusw0TdLiCstfBhdDmMeO9IKHHubLT33KlIHbqm H5AfELvGCTNaksoUIMswPnh026rDi1AP7WIK14UPukDIsLqASX+5eQ9PVmk7HlCh69 c+SO1HGqgMw/Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andreas Gruenbacher , Tetsuo Handa , syzbot+f51cb4b9afbd87ec06f2@syzkaller.appspotmail.com, Sasha Levin , rpeterso@redhat.com, cluster-devel@redhat.com Subject: [PATCH AUTOSEL 5.15 17/25] gfs2: Improve gfs2_make_fs_rw error handling Date: Sun, 26 Feb 2023 21:08:40 -0500 Message-Id: <20230227020855.1051605-17-sashal@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230227020855.1051605-1-sashal@kernel.org> References: <20230227020855.1051605-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andreas Gruenbacher [ Upstream commit b66f723bb552ad59c2acb5d45ea45c890f84498b ] In gfs2_make_fs_rw(), make sure to call gfs2_consist() to report an inconsistency and mark the filesystem as withdrawn when gfs2_find_jhead() fails. At the end of gfs2_make_fs_rw(), when we discover that the filesystem has been withdrawn, make sure we report an error. This also replaces the gfs2_withdrawn() check after gfs2_find_jhead(). Reported-by: Tetsuo Handa Cc: syzbot+f51cb4b9afbd87ec06f2@syzkaller.appspotmail.com Signed-off-by: Andreas Gruenbacher Signed-off-by: Sasha Levin --- fs/gfs2/super.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index d615974ce4183..775ac3fb10c67 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -138,8 +138,10 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp) return -EIO; error = gfs2_find_jhead(sdp->sd_jdesc, &head, false); - if (error || gfs2_withdrawn(sdp)) + if (error) { + gfs2_consist(sdp); return error; + } if (!(head.lh_flags & GFS2_LOG_HEAD_UNMOUNT)) { gfs2_consist(sdp); @@ -151,7 +153,9 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp) gfs2_log_pointers_init(sdp, head.lh_blkno); error = gfs2_quota_init(sdp); - if (!error && !gfs2_withdrawn(sdp)) + if (!error && gfs2_withdrawn(sdp)) + error = -EIO; + if (!error) set_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags); return error; } -- 2.39.0