From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B15C1EE7C6 for ; Mon, 1 Sep 2025 02:03:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756692223; cv=none; b=JP1I89olNbIZVeTp41/H+RVqDjZiI+EvBtrwGsSu5dWvpZDXRn4aok16teZhxWbyG1GeFOofhsvRgLjqxSFCrTAsS+z63gIjubi78qI3HnMYPI2Wt7jBZeW7EIWXy50H80Tx5CwiWq6Tea3Tn1pRI3vNXxm9pXNhpHhQYqC5Z/g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756692223; c=relaxed/simple; bh=PTR9olxR+6Cv0v/ngn9kPVgymR2ombpHO6ievh61MH4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b7/iLrTZDhoKChUsP02GaDvzxkXnzK82rWMSNhjE8ba1xRi3RspxbtaXAwBYi8WyxL7FRTLVfFd4b6MkVlO0GwYVYUjZi7swbNF9iMOsqB89HkhYkRqC0IMXGFIxC26IhZRWN04IMo9tzcFLRwY4jvlyeyakbR/rGUuNBbRtbro= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YGddBssW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YGddBssW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FFBEC4CEF6; Mon, 1 Sep 2025 02:03:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756692222; bh=PTR9olxR+6Cv0v/ngn9kPVgymR2ombpHO6ievh61MH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YGddBssWWAimjHdH4jnAkHd72XGEkdSP/98dCqxbUjV9+0btGK2cldnWqbI2qenl2 EZBaJSR5dR4A4DUkucubgWfSiQy4Goq/upg161vULmG4gRaBwXpXl1KadvFpakg2Zv oZqzAMxyfJhFynkR3+VEsVdlCRsXUfb8JdTLK9K5eqaNBAd6a1Lg+9LBGz709ySj4i i2YTiOSGP3vZ4HbSTN119oZBSgnHNw9dmilA2cYj2nZfmWzGa+k2F5oqIszijozus5 TMPmuJjmXbkeuWOuaxrT2hAB0zCFKR6mCbbQcASKQf5Stp48qZXmnNXE+KDzRx60wm qI3XwJDZFIFAQ== From: Chao Yu To: Zorro Lang , fstests@vger.kernel.org Cc: jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net, Chao Yu Subject: [PATCH 2/2] f2fs/022: do sanity check on footer of non inode dnode Date: Mon, 1 Sep 2025 10:03:31 +0800 Message-ID: <20250901020331.2171502-2-chao@kernel.org> X-Mailer: git-send-email 2.51.0.338.gd7d06c2dae-goog In-Reply-To: <20250901020331.2171502-1-chao@kernel.org> References: <20250901020331.2171502-1-chao@kernel.org> Precedence: bulk X-Mailing-List: fstests@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This is a regression test: 1. create foo & bar 2. write 8M data to foo 3. use inject.f2fs to inject i_nid[0] of foo w/ ino of bar 4. fpunch in foo w/ specified range If we haven't applied kernel patch ("f2fs: fix to do sanity check on node footer for non inode dnode"), f2fs may missed to do sanity check on corrupted dnode, result in panic in step 4). Cc: Jaegeuk Kim Signed-off-by: Chao Yu --- tests/f2fs/022 | 52 ++++++++++++++++++++++++++++++++++++++++++++++ tests/f2fs/022.out | 2 ++ 2 files changed, 54 insertions(+) create mode 100755 tests/f2fs/022 create mode 100644 tests/f2fs/022.out diff --git a/tests/f2fs/022 b/tests/f2fs/022 new file mode 100755 index 00000000..a5e19a71 --- /dev/null +++ b/tests/f2fs/022 @@ -0,0 +1,52 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Chao Yu. All Rights Reserved. +# +# FS QA Test No. f2fs/022 +# +# This is a regression test: +# 1. create foo & bar +# 2. write 8M data to foo +# 3. use inject.f2fs to inject i_nid[0] of foo w/ ino of bar +# 4. fpunch in foo w/ specified range +# +. ./common/preamble +_begin_fstest auto quick rw + +. ./common/attr + +_fixed_by_kernel_commit xxxxxxxxxxxx \ + "f2fs: fix to do sanity check on node footer for non inode dnode" + +_require_scratch_nocheck +_require_command "$F2FS_INJECT_PROG" inject.f2fs +_require_xfs_io_command "fpunch" +_require_kernel_config CONFIG_F2FS_CHECK_FS + +# remove all mkfs options to avoid layout change of on-disk inode +export MKFS_OPTIONS="" + +foo_path=$SCRATCH_MNT/foo +bar_path=$SCRATCH_MNT/bar + +_scratch_mkfs >> $seqres.full +_scratch_mount + +touch $foo_path +touch $bar_path +$XFS_IO_PROG $foo_path -c "pwrite 0 8M" >> $seqres.full +sync +foo_ino=`stat -c '%i' $foo_path` +bar_ino=`stat -c '%i' $bar_path` +_scratch_unmount + +# inject foo inode to replace i_nid[0] w/ to bar ino +$F2FS_INJECT_PROG --node --mb i_nid --nid $foo_ino --idx 0 --val $bar_ino $SCRATCH_DEV >> $seqres.full || _fail "failed to inject" + +_scratch_mount +# expect to trigger panic +$XFS_IO_PROG $foo_path -c "fpunch 6984k 4k" +_scratch_unmount + +status=0 +exit diff --git a/tests/f2fs/022.out b/tests/f2fs/022.out new file mode 100644 index 00000000..5307e3d7 --- /dev/null +++ b/tests/f2fs/022.out @@ -0,0 +1,2 @@ +QA output created by 022 +fallocate: Structure needs cleaning -- 2.49.0 From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A7ABCA0FF2 for ; Mon, 1 Sep 2025 02:03:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:MIME-Version:References:In-Reply-To: Message-ID:Date:To:Sender:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YoTAfQfTtHa8OwdWp6JE8jT86Oio6B5rYWgFBIsxouw=; b=diZwkmg+fyTQUJeoi4oAu3actY 84SQ7Sv2xtVmd1mF331WdTryPn3zHphsDvKuUaVEwqGj5cb3spjuJifzPwP26HQeHuKe2SIZ109ve X6wNdYBGETrMZv9C5oKYAcq71YbL4o5PQ9HYa9GRPiLu3Hvlz+ITNymXu4FEaOoC5goI=; Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1usttj-0002iD-7w; Mon, 01 Sep 2025 02:03:55 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1ustti-0002i6-3L for linux-f2fs-devel@lists.sourceforge.net; Mon, 01 Sep 2025 02:03:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=0tf2AOG8h9+PguPubUlZ5ran6QLtp2335yBUKXD0W4k=; b=CTmQ8i9j+1388dOHqFd2aLwFLu hDaEPvwZhIQuosDCOMJbGIkltfGDToUAEBjGOrtrBGtW9Da051XDabM9lgdWidyRKUTZf9sj2jTrU z4514vYvLKUDZjFjqqiqjD0Yo0omkaneNVWkgZDzx/ZUm6Q+UuMe1I3GrYkFzFOdwbho=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=0tf2AOG8h9+PguPubUlZ5ran6QLtp2335yBUKXD0W4k=; b=ezqk23ImEhtpU7NgKP2tAjOq53 RwDlAt4rdkY/kMK5S0pYDSJxpgB8sZUA+VVk2JQUtr9uDWbwcacz1VW77iBHDelHkbD9FHlOd78UF eRwJnmv/Ye1D0KzkmrnBU/JkuNrRyVpQs1sQlyKDRndnJO0HJ7Rwzq8EMwe3RFKC9afI=; Received: from tor.source.kernel.org ([172.105.4.254]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1ustth-0004ry-K8 for linux-f2fs-devel@lists.sourceforge.net; Mon, 01 Sep 2025 02:03:54 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id 15B3B601E5 for ; Mon, 1 Sep 2025 02:03:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FFBEC4CEF6; Mon, 1 Sep 2025 02:03:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1756692222; bh=PTR9olxR+6Cv0v/ngn9kPVgymR2ombpHO6ievh61MH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YGddBssWWAimjHdH4jnAkHd72XGEkdSP/98dCqxbUjV9+0btGK2cldnWqbI2qenl2 EZBaJSR5dR4A4DUkucubgWfSiQy4Goq/upg161vULmG4gRaBwXpXl1KadvFpakg2Zv oZqzAMxyfJhFynkR3+VEsVdlCRsXUfb8JdTLK9K5eqaNBAd6a1Lg+9LBGz709ySj4i i2YTiOSGP3vZ4HbSTN119oZBSgnHNw9dmilA2cYj2nZfmWzGa+k2F5oqIszijozus5 TMPmuJjmXbkeuWOuaxrT2hAB0zCFKR6mCbbQcASKQf5Stp48qZXmnNXE+KDzRx60wm qI3XwJDZFIFAQ== To: Zorro Lang , fstests@vger.kernel.org Date: Mon, 1 Sep 2025 10:03:31 +0800 Message-ID: <20250901020331.2171502-2-chao@kernel.org> X-Mailer: git-send-email 2.51.0.338.gd7d06c2dae-goog In-Reply-To: <20250901020331.2171502-1-chao@kernel.org> References: <20250901020331.2171502-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1ustth-0004ry-K8 Subject: [f2fs-dev] [PATCH 2/2] f2fs/022: do sanity check on footer of non inode dnode X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Chao Yu via Linux-f2fs-devel Reply-To: Chao Yu Cc: jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This is a regression test: 1. create foo & bar 2. write 8M data to foo 3. use inject.f2fs to inject i_nid[0] of foo w/ ino of bar 4. fpunch in foo w/ specified range If we haven't applied kernel patch ("f2fs: fix to do sanity check on node footer for non inode dnode"), f2fs may missed to do sanity check on corrupted dnode, result in panic in step 4). Cc: Jaegeuk Kim Signed-off-by: Chao Yu --- tests/f2fs/022 | 52 ++++++++++++++++++++++++++++++++++++++++++++++ tests/f2fs/022.out | 2 ++ 2 files changed, 54 insertions(+) create mode 100755 tests/f2fs/022 create mode 100644 tests/f2fs/022.out diff --git a/tests/f2fs/022 b/tests/f2fs/022 new file mode 100755 index 00000000..a5e19a71 --- /dev/null +++ b/tests/f2fs/022 @@ -0,0 +1,52 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2025 Chao Yu. All Rights Reserved. +# +# FS QA Test No. f2fs/022 +# +# This is a regression test: +# 1. create foo & bar +# 2. write 8M data to foo +# 3. use inject.f2fs to inject i_nid[0] of foo w/ ino of bar +# 4. fpunch in foo w/ specified range +# +. ./common/preamble +_begin_fstest auto quick rw + +. ./common/attr + +_fixed_by_kernel_commit xxxxxxxxxxxx \ + "f2fs: fix to do sanity check on node footer for non inode dnode" + +_require_scratch_nocheck +_require_command "$F2FS_INJECT_PROG" inject.f2fs +_require_xfs_io_command "fpunch" +_require_kernel_config CONFIG_F2FS_CHECK_FS + +# remove all mkfs options to avoid layout change of on-disk inode +export MKFS_OPTIONS="" + +foo_path=$SCRATCH_MNT/foo +bar_path=$SCRATCH_MNT/bar + +_scratch_mkfs >> $seqres.full +_scratch_mount + +touch $foo_path +touch $bar_path +$XFS_IO_PROG $foo_path -c "pwrite 0 8M" >> $seqres.full +sync +foo_ino=`stat -c '%i' $foo_path` +bar_ino=`stat -c '%i' $bar_path` +_scratch_unmount + +# inject foo inode to replace i_nid[0] w/ to bar ino +$F2FS_INJECT_PROG --node --mb i_nid --nid $foo_ino --idx 0 --val $bar_ino $SCRATCH_DEV >> $seqres.full || _fail "failed to inject" + +_scratch_mount +# expect to trigger panic +$XFS_IO_PROG $foo_path -c "fpunch 6984k 4k" +_scratch_unmount + +status=0 +exit diff --git a/tests/f2fs/022.out b/tests/f2fs/022.out new file mode 100644 index 00000000..5307e3d7 --- /dev/null +++ b/tests/f2fs/022.out @@ -0,0 +1,2 @@ +QA output created by 022 +fallocate: Structure needs cleaning -- 2.49.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel