From patchwork Mon Oct 24 11:29:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8407 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp400040wru; Mon, 24 Oct 2022 04:46:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6RK7YkF+o17+YKH4/gXVOH45Oly6xc9AthtiF0bxCdR8BqH491eh5GQSFYM+dKAtt6GsYP X-Received: by 2002:a17:907:2d29:b0:78d:cf5c:5774 with SMTP id gs41-20020a1709072d2900b0078dcf5c5774mr26245504ejc.213.1666611970703; Mon, 24 Oct 2022 04:46:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666611970; cv=none; d=google.com; s=arc-20160816; b=LTOF1AQKxFI4Atl5FjiAQbVh3m/9jvcmI0ztCoeJSL7NlXgj2Bsq3UWsA+0ZRQk4/t 6tLaDzWeF3DctA6/R+bz80qtFMjFfiZ95A21A5ept1RdbfI+2FLTozvCjGIid7hEWR9I 1Exq1C01p3voQ6ZAtZJJSxXLfAZgKYVVyD5uGSFUH4S1dV/nD/RG4o39J2TdIjDfw9Hk DeodcIzLU0UYOuYGlV3hBh5KdlmPn2T6wy4fBolKfndGbuwWAUTT9g6Pgwk3wjKF4FfI /+wrX1KgRffCLHkyeCLicQvRzZ6j9gh6W34AplB7263WTHji6F4O/kxP1V4DxAFLO1db NzOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Cirgn2uDs8omIoQR3VIPYlKIGZOLtmjP7GIEQC3QhKo=; b=XucLGbRpcqAPZkMJfjmPwCb6DnFp5H8vgY0SAQB9paHXSR/eV3UcCI+YdDhkss+Y6Y Gtcbe+abFxkkQXghMvRhZbI23EH35KbXsx7NEs6CmUyWvdbFWjUTbVPWal51d5AD+axR CuCegmftt/tbgCIH7PYETLypzf9bX1yVetCT2sK+iEL42JhVXhdIsW1aNvvcdk2YtFf8 NzVgBagorjSxg6Hv8kxgsGiH9UtIg695GFiB4OTuQAHhiMZViD0yL7opmCUZydV01978 JtgOQx51nbbX9rr/oR7iLzD9pYLn3eKqDy7YW+ZLmpTNNFwx0OMFlKC2ScXA2TXj5iqO G8Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xfhQVnzE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r10-20020a1709060d4a00b007878144285csi24136918ejh.314.2022.10.24.04.45.46; Mon, 24 Oct 2022 04:46:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xfhQVnzE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231440AbiJXLpQ (ORCPT + 99 others); Mon, 24 Oct 2022 07:45:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231564AbiJXLoB (ORCPT ); Mon, 24 Oct 2022 07:44:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C042768CF7; Mon, 24 Oct 2022 04:41:24 -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 ams.source.kernel.org (Postfix) with ESMTPS id B06EDB81150; Mon, 24 Oct 2022 11:39:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 184EDC433D6; Mon, 24 Oct 2022 11:39:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666611569; bh=3rqP5LXx8iCKKFP0uEtu58VISbcDiA86syfPiL3kk3k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xfhQVnzEkycKeezRKh4AqiOuhQDubS4eYeiZDZvfIXWeblIENC/2gkhG+KN2EqT3b rm55KKltpmWvnkOZv/3EQa1+qE3Tp1McZp8ZX+SS6AKX/9Vefz3PeDGyguc+G/UHzv AH2XR/m+pOpFyRKAgPHO6p2zxq5h+5Lt2A3smPlo= 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.9 029/159] nilfs2: replace WARN_ONs by nilfs_error for checkpoint acquisition failure Date: Mon, 24 Oct 2022 13:29:43 +0200 Message-Id: <20221024112950.485039215@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112949.358278806@linuxfoundation.org> References: <20221024112949.358278806@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747569313839461450?= X-GMAIL-MSGID: =?utf-8?q?1747569313839461450?= 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@gmail.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 @@ -888,9 +888,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 == -EINVAL || err == -ENOENT); - + } else if (err == -EINVAL || err == -ENOENT) { + nilfs_error(sci->sc_super, + "checkpoint creation failed due to metadata corruption."); + err = -EIO; + } return err; } @@ -904,7 +906,11 @@ static int nilfs_segctor_fill_in_checkpo err = nilfs_cpfile_get_checkpoint(nilfs->ns_cpfile, nilfs->ns_cno, 0, &raw_cp, &bh_cp); if (unlikely(err)) { - WARN_ON(err == -EINVAL || err == -ENOENT); + if (err == -EINVAL || err == -ENOENT) { + nilfs_error(sci->sc_super, + "checkpoint finalization failed due to metadata corruption."); + err = -EIO; + } goto failed_ibh; } raw_cp->cp_snapshot_list.ssl_next = 0;