FSTests Archive on lore.kernel.org
 help / color / Atom feed
From: Filipe Manana <fdmanana@gmail.com>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs <linux-btrfs@vger.kernel.org>,
	fstests <fstests@vger.kernel.org>
Subject: Re: [PATCH] btrfs: Add a test for leaking root crash at unmount time
Date: Wed, 20 May 2020 10:25:43 +0100
Message-ID: <CAL3q7H6GqgL9wAmgdUtHBWN8ex1r-BdRT9uuodEDXTrQn7OJqA@mail.gmail.com> (raw)
In-Reply-To: <20200519021331.14028-1-wqu@suse.com>

On Tue, May 19, 2020 at 3:14 AM Qu Wenruo <wqu@suse.com> wrote:
>
> Test if canceled balance could lead to root leakage.
> If the kernel has CONFIG_BTRFS_DEBUG compiled, unmount time root leakge
> check would detect it, and cause NULL pointer dereference as the pages
> of the leaked root is already freed.

is -> are

>
> The fix is titled "btrfs: relocation: Fix reloc root leakage and the NULL
>  pointer reference caused by the leakage".
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>  tests/btrfs/212     | 85 +++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/212.out |  2 ++
>  tests/btrfs/group   |  1 +
>  3 files changed, 88 insertions(+)
>  create mode 100755 tests/btrfs/212
>  create mode 100644 tests/btrfs/212.out
>
> diff --git a/tests/btrfs/212 b/tests/btrfs/212
> new file mode 100755
> index 00000000..4f4e177b
> --- /dev/null
> +++ b/tests/btrfs/212
> @@ -0,0 +1,85 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
> +#
> +# FS QA Test 212
> +#
> +# Test if unmounting a fs with balance canceled can lead to crash.
> +# This needs CONFIG_BTRFS_DEBUG compiled, which includes extra unmount time self-test

includes -> adds

> +#
> +seq=`basename $0`
> +seqres=$RESULT_DIR/$seq
> +echo "QA output created by $seq"
> +
> +here=`pwd`
> +tmp=/tmp/$$
> +status=1       # failure is the default!
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +_cleanup()
> +{
> +       cd /
> +       rm -f $tmp.*
> +       kill $balance_pid &> /dev/null
> +       kill $cancel_pid &> /dev/null
> +       "$KILLALL_PROG" -q $FSSTRESS_PROG &> /dev/null
> +       $BTRFS_UTIL_PROG balance cancel $SCRATCH_MNT &> /dev/null
> +       wait
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# remove previous $seqres.full before test
> +rm -f $seqres.full
> +
> +# real QA test starts here
> +
> +# Modify as appropriate.
> +_supported_fs btrfs
> +_supported_os Linux
> +_require_scratch
> +_require_command "$KILLALL_PROG" killall
> +
> +_scratch_mkfs >> $seqres.full
> +_scratch_mount
> +
> +runtime=15
> +
> +balance_workload()
> +{
> +       trap "wait; exit" SIGTERM
> +       while true; do
> +               $BTRFS_UTIL_PROG balance start -f --full $SCRATCH_MNT &> /dev/null

Please use the helper _run_btrfs_balance_start(), it will
automatically add --full-balance if the installed btrfs-progs version
requires it.

After that you can add:

Reviewed-by: Filipe Manana <fdmanana@suse.com>

> +       done
> +}
> +
> +cancel_workload()
> +{
> +       trap "wait; exit" SIGTERM
> +       while true; do
> +               $BTRFS_UTIL_PROG balance cancel $SCRATCH_MNT &> /dev/null
> +               sleep 2
> +       done
> +}
> +
> +$FSSTRESS_PROG -d $SCRATCH_MNT -w -n 100000  >> $seqres.full 2>/dev/null &
> +balance_workload &
> +balance_pid=$!
> +
> +cancel_workload &
> +cancel_pid=$!
> +
> +sleep $runtime
> +
> +kill $balance_pid
> +kill $cancel_pid
> +"$KILLALL_PROG" -q $FSSTRESS_PROG &> /dev/null
> +$BTRFS_UTIL_PROG balance cancel $SCRATCH_MNT &> /dev/null
> +wait
> +
> +echo "Silence is golden"
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/btrfs/212.out b/tests/btrfs/212.out
> new file mode 100644
> index 00000000..32d11390
> --- /dev/null
> +++ b/tests/btrfs/212.out
> @@ -0,0 +1,2 @@
> +QA output created by 212
> +Silence is golden
> diff --git a/tests/btrfs/group b/tests/btrfs/group
> index 66b1beac..8d65bddd 100644
> --- a/tests/btrfs/group
> +++ b/tests/btrfs/group
> @@ -214,3 +214,4 @@
>  209 auto quick log
>  210 auto quick qgroup snapshot
>  211 auto quick log prealloc
> +212 auto balance dangerous
> --
> 2.26.2
>


-- 
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”

      reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19  2:13 Qu Wenruo
2020-05-20  9:25 ` Filipe Manana [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAL3q7H6GqgL9wAmgdUtHBWN8ex1r-BdRT9uuodEDXTrQn7OJqA@mail.gmail.com \
    --to=fdmanana@gmail.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

FSTests Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/fstests/0 fstests/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 fstests fstests/ https://lore.kernel.org/fstests \
		fstests@vger.kernel.org
	public-inbox-index fstests

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.fstests


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git