Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2090314rwb; Thu, 29 Sep 2022 06:12:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7sMRvN2RqtX3JFw3Quj15O2fFWLbQ9h+O4U2FtMbYOPYKuiYnMeOoI3OldjzaT4a4h5Krv X-Received: by 2002:a17:906:dac9:b0:780:ab6f:591f with SMTP id xi9-20020a170906dac900b00780ab6f591fmr2680645ejb.77.1664457121703; Thu, 29 Sep 2022 06:12:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664457121; cv=none; d=google.com; s=arc-20160816; b=B+0kXvtVAytE4u7cHch2IK0zVwSetusDd4hbSCwRbFsuHvngQdHmy1tG2lMEMyJOvo Ne2Nt6A8BAjpn7vvTtOL3cuVOf/RVIV7SP/iANb4MG9BAkcM8HLaITFBtqgGDd76BPXk I2bz8+2OPOgCafORC5eFNiM2gQPoPwNgDZ6kE/b7+RGzJR7Mw+aNugvhRs/FEf9UsPA6 plgo9m7okiZXYmZilEo0P6Dsewu4DnnQEUoXgB0jVVP/tjqPvIJiHy0EBFj+Md0Ci3Pe CgpF+NLJDCezr9J+PWD4YlpDwmfFlx06yAIp4jNB6MsEAKkMLHYyHpqeAyJVPJXrFQld n2hQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2J8dEhSi4LoVFaaTjvQBUI0DFYA9A2JG/Zfec+eIbxg=; b=mfBXZYu1WK+MTmecg4bF8X1mt/sP/5b1HLVZsKzrhSpcZtU69AmdRj4QDnWTrxhxZ8 DlO5pGLdeSZXhYsBCW3qyS6A/8wOGavuKTDbAyM1eQSstN4yod24oUD+1kP96KBQBsIB N2GHumnTJxNDzagErhA6YOGeZl6ja2gxvlRJlmr0ghxoX74o5yMThb3OkpdEtaIl9LDt 13FqJtNivfqY+vN7B00XFb6qvMTKQmLKcyK4QUv2ISDRaUHLYUCuIEvzpFbsHjJQMP0y 3pgd1fJyFbRythdsJH1zvFfbM1kzC2FXwpcT7wC2MZOk0XpmvvOHG4xm0fXQnwS4Hout xVWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bKErUGlt; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w14-20020a17090649ce00b007386f4ab2a2si6889470ejv.638.2022.09.29.06.11.36; Thu, 29 Sep 2022 06:12:01 -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=@gmail.com header.s=20210112 header.b=bKErUGlt; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234996AbiI2Mdl (ORCPT + 99 others); Thu, 29 Sep 2022 08:33:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235236AbiI2Mdh (ORCPT ); Thu, 29 Sep 2022 08:33:37 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FFF91559FE; Thu, 29 Sep 2022 05:33:36 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id 129so1327015pgc.5; Thu, 29 Sep 2022 05:33:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=2J8dEhSi4LoVFaaTjvQBUI0DFYA9A2JG/Zfec+eIbxg=; b=bKErUGltahBAoxoud23nWtqed2bGUwNz4MKypA7BMv/noAxOXYQQeV6vkmMSwI5TDW XYCs64b6Swl4ARcHgtCb38nZ8e6UGSpwfqZCsaV40h9MWaFVJ6CT/sFSGtbri2ry2oOC Qschv+0chd6XnFFtyqCVlS/wfllaKWp72zAmD8/O8pf4HnDRCsOAQg4Px7ZKsusZ9ObE wVvvLXFrIY2WyrnOomyXmYynnqOfyjaNlamIstOdvju5NA8QbAkcm59znDusT6JJfNkE xuQzYRFnvfp846BkJ/jOXSWiRfwEi1PrF/4bzA1vqjdzz9brvAywLKMXVeGoHKjTXDU+ X+aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=2J8dEhSi4LoVFaaTjvQBUI0DFYA9A2JG/Zfec+eIbxg=; b=EjJteMPq02S2jLPxpY3a0hKSpIIOG0tqTJS0VJt7G0NKtTvV6VYX59kWBFSZNKHTUx mt6AZPO3S6rSM0gOLl50huIZjYLKhvKeNmC2ZeSSoFCaCgDMWzcUZ7OavKZdKgXbB4Aw 4lK4UuorHUi8eZCLp5y07bdgN2RP0n0Kh7HnQS0DxGhcd/uJJ8jHVvo1xe+I2Id6QymD 9jdUgwsQh0d0XF4lJWa67InBo9RfyodV+d4n7F10HhOrQYqUic1N19hqBEdHQJPHf1zj 6FCa2qIZBu3tGrtXvc2FRyNfIklNTCwMJhK/5fwTQEjjkxshwHF2hnGOyo1QgAmuAY7g 4d2w== X-Gm-Message-State: ACrzQf1NMPSDtCvmAm9oC69tAw+54fbqb+ZYPTkVDuvfIH0S+iIuHzWc WnlINLNwknv7NOGcaurK41g= X-Received: by 2002:a65:5a4b:0:b0:43c:c168:b00b with SMTP id z11-20020a655a4b000000b0043cc168b00bmr2748383pgs.357.1664454815370; Thu, 29 Sep 2022 05:33:35 -0700 (PDT) Received: from carrot.. (i220-109-170-101.s42.a014.ap.plala.or.jp. [220.109.170.101]) by smtp.gmail.com with ESMTPSA id e3-20020a17090301c300b00172cb8b97a8sm5873884plh.5.2022.09.29.05.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Sep 2022 05:33:34 -0700 (PDT) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs , syzbot , syzkaller-bugs@googlegroups.com, LKML Subject: [PATCH] nilfs2: replace WARN_ONs by nilfs_error for checkpoint acquisition failure Date: Thu, 29 Sep 2022 21:33:30 +0900 Message-Id: <20220929123330.19658-1-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <0000000000001a6b6705e9b3533d@google.com> References: <0000000000001a6b6705e9b3533d@google.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 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. Reported-by: syzbot+fbb3e0b24e8dae5a16ee@syzkaller.appspotmail.com Signed-off-by: Ryusuke Konishi --- fs/nilfs2/segment.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c index 0afe0832c754..25c56ea779ea 100644 --- a/fs/nilfs2/segment.c +++ b/fs/nilfs2/segment.c @@ -875,9 +875,11 @@ static int nilfs_segctor_create_checkpoint(struct nilfs_sc_info *sci) 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; } @@ -891,7 +893,11 @@ static int nilfs_segctor_fill_in_checkpoint(struct nilfs_sc_info *sci) 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; -- 2.34.1