From nobody Wed Sep 3 06:41:50 2025 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 9BCA3C38A2D for ; Mon, 24 Oct 2022 12:55:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234759AbiJXMzK (ORCPT ); Mon, 24 Oct 2022 08:55:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234946AbiJXMyW (ORCPT ); Mon, 24 Oct 2022 08:54:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB20D14D2E; Mon, 24 Oct 2022 05:14:49 -0700 (PDT) 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 23004612B3; Mon, 24 Oct 2022 11:56:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 348DFC433D6; Mon, 24 Oct 2022 11:56:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612606; bh=5/+T7+Hbc+gs+Q2MxLjLyv7qCijM55C8bgamH/I/2XQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ge9O/pTENp2klJzHO4VlyiHqLK3YDCVeS45Wt6/+sEumoQ9FwY/Wg56ridGV1/G+B 6Msr6nl1wtyO74eKN4IaF+8t4f1W2tXpWGcC5dCHDKrJJ09l9leMmGfOZ1rOd0YHim 7stdK2V+zCQxH6F652gIUO24ZIId/IZkx15uLxpk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ryusuke Konishi , syzbot+fbb3e0b24e8dae5a16ee@syzkaller.appspotmail.com, Andrew Morton Subject: [PATCH 4.19 020/229] nilfs2: replace WARN_ONs by nilfs_error for checkpoint acquisition failure Date: Mon, 24 Oct 2022 13:28:59 +0200 Message-Id: <20221024112959.796764482@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Ryusuke Konishi commit 723ac751208f6d6540191689cfbf6c77135a7a1b upstream. If creation or finalization of a checkpoint fails due to anomalies in the checkpoint metadata on disk, a kernel warning is generated. This patch replaces the WARN_ONs by nilfs_error, so that a kernel, booted with panic_on_warn, does not panic. A nilfs_error is appropriate here to handle the abnormal filesystem condition. This also replaces the detected error codes with an I/O error so that neither of the internal error codes is returned to callers. Link: https://lkml.kernel.org/r/20220929123330.19658-1-konishi.ryusuke@gmai= l.com Signed-off-by: Ryusuke Konishi Reported-by: syzbot+fbb3e0b24e8dae5a16ee@syzkaller.appspotmail.com Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- fs/nilfs2/segment.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -880,9 +880,11 @@ static int nilfs_segctor_create_checkpoi nilfs_mdt_mark_dirty(nilfs->ns_cpfile); nilfs_cpfile_put_checkpoint( nilfs->ns_cpfile, nilfs->ns_cno, bh_cp); - } else - WARN_ON(err =3D=3D -EINVAL || err =3D=3D -ENOENT); - + } else if (err =3D=3D -EINVAL || err =3D=3D -ENOENT) { + nilfs_error(sci->sc_super, + "checkpoint creation failed due to metadata corruption."); + err =3D -EIO; + } return err; } =20 @@ -896,7 +898,11 @@ static int nilfs_segctor_fill_in_checkpo err =3D nilfs_cpfile_get_checkpoint(nilfs->ns_cpfile, nilfs->ns_cno, 0, &raw_cp, &bh_cp); if (unlikely(err)) { - WARN_ON(err =3D=3D -EINVAL || err =3D=3D -ENOENT); + if (err =3D=3D -EINVAL || err =3D=3D -ENOENT) { + nilfs_error(sci->sc_super, + "checkpoint finalization failed due to metadata corruption."); + err =3D -EIO; + } goto failed_ibh; } raw_cp->cp_snapshot_list.ssl_next =3D 0;