All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Boris Burkov <boris@bur.io>
Cc: fstests@vger.kernel.org, linux-fscrypt@vger.kernel.org,
	linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH v7 3/5] generic/574: corrupt btrfs merkle tree data
Date: Wed, 16 Mar 2022 17:29:22 +0000	[thread overview]
Message-ID: <YjIecjyuXQNedRF7@gmail.com> (raw)
In-Reply-To: <6d08195d452509ebf0f8724fd3c25a7cd2079232.1647382272.git.boris@bur.io>

On Tue, Mar 15, 2022 at 03:15:59PM -0700, Boris Burkov wrote:
> generic/574 has tests for corrupting the merkle tree data stored by the
> filesystem. Since btrfs uses a different scheme for storing this data,
> the existing logic for corrupting it doesn't work out of the box. Adapt
> it to properly corrupt btrfs merkle items.
> 
> This test relies on the btrfs implementation of fsverity in the patch:
> btrfs: initial fsverity support
> 
> and on btrfs-corrupt-block for corruption in the patches titled:
> btrfs-progs: corrupt generic item data with btrfs-corrupt-block
> btrfs-progs: expand corrupt_file_extent in btrfs-corrupt-block
> 
> Signed-off-by: Boris Burkov <boris@bur.io>
> ---
>  common/verity     | 15 +++++++++++++++
>  tests/generic/574 |  1 +
>  2 files changed, 16 insertions(+)
> 
> diff --git a/common/verity b/common/verity
> index 77766fca..db03510e 100644
> --- a/common/verity
> +++ b/common/verity
> @@ -328,6 +328,21 @@ _fsv_scratch_corrupt_merkle_tree()
>  		(( offset += ($(_get_filesize $file) + 65535) & ~65535 ))
>  		_fsv_scratch_corrupt_bytes $file $offset
>  		;;
> +	btrfs)
> +		local ino=$(stat -c '%i' $file)
> +		_scratch_unmount
> +		local byte=""
> +		while read -n 1 byte; do
> +			local ascii=$(printf "%d" "'$byte'")
> +			# This command will find a Merkle tree item for the inode (-I $ino,37,0)
> +			# in the default filesystem tree (-r 5) and corrupt one byte (-b 1) at
> +			# $offset (-o $offset) with the ascii representation of the byte we read
> +			# (-v $ascii)
> +			$BTRFS_CORRUPT_BLOCK_PROG -r 5 -I $ino,37,0 -v $ascii -o $offset -b 1 $SCRATCH_DEV
> +			(( offset += 1 ))
> +		done
> +		_scratch_mount
> +		;;
>  	*)
>  		_fail "_fsv_scratch_corrupt_merkle_tree() unimplemented on $FSTYP"
>  		;;
> diff --git a/tests/generic/574 b/tests/generic/574
> index 17fdea52..18810ab2 100755
> --- a/tests/generic/574
> +++ b/tests/generic/574
> @@ -27,6 +27,7 @@ _cleanup()
>  # real QA test starts here
>  _supported_fs generic
>  _require_scratch_verity
> +_require_fsverity_corruption
>  _disable_fsverity_signatures
>  _require_fsverity_corruption
>  

_require_fsverity_corruption is already present above.

That would mean this patch should only change common/verity, and its subject
should have "common/verity", not "generic/574".

- Eric

  reply	other threads:[~2022-03-16 17:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-15 22:15 [PATCH v7 0/5] tests for btrfs fsverity Boris Burkov
2022-03-15 22:15 ` [PATCH v7 1/5] verity: require corruption functionality Boris Burkov
2022-03-16 17:21   ` Eric Biggers
2022-03-15 22:15 ` [PATCH v7 2/5] btrfs: test btrfs specific fsverity corruption Boris Burkov
2022-03-16 17:26   ` Eric Biggers
2022-03-16 17:36     ` Boris Burkov
2022-03-15 22:15 ` [PATCH v7 3/5] generic/574: corrupt btrfs merkle tree data Boris Burkov
2022-03-16 17:29   ` Eric Biggers [this message]
2022-03-15 22:16 ` [PATCH v7 4/5] btrfs: test verity orphans with dmlogwrites Boris Burkov
2022-03-15 22:16 ` [PATCH v7 5/5] generic: test fs-verity EFBIG scenarios Boris Burkov
2022-03-16 17:30   ` Eric Biggers

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=YjIecjyuXQNedRF7@gmail.com \
    --to=ebiggers@kernel.org \
    --cc=boris@bur.io \
    --cc=fstests@vger.kernel.org \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fscrypt@vger.kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.