fstests.vger.kernel.org archive mirror
 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 v6 2/4] generic/574: corrupt btrfs merkle tree data
Date: Tue, 15 Mar 2022 00:00:41 +0000	[thread overview]
Message-ID: <Yi/XKWg9BWzmUGRy@gmail.com> (raw)
In-Reply-To: <93f40b68c7beafb546e3cda328a78b2ab088d85c.1644883592.git.boris@bur.io>

On Mon, Feb 14, 2022 at 04:09:56PM -0800, 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     | 18 ++++++++++++++++++
>  tests/generic/574 |  1 +
>  2 files changed, 19 insertions(+)
> 
> diff --git a/common/verity b/common/verity
> index eec8ae72..07d9d3fe 100644
> --- a/common/verity
> +++ b/common/verity
> @@ -322,6 +322,24 @@ _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
> +			if [ -z $byte ]; then
> +				break
> +			fi

'[ -z $byte ]' could use quotes around $byte.  But isn't that check unneeded at
all, given that 'read' will fail when EOF is reached?

- Eric

  reply	other threads:[~2022-03-15  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-15  0:09 [PATCH v6 0/4] tests for btrfs fsverity Boris Burkov
2022-02-15  0:09 ` [PATCH v6 1/4] btrfs: test btrfs specific fsverity corruption Boris Burkov
2022-03-14 23:58   ` Eric Biggers
2022-03-15 22:02     ` Boris Burkov
2022-02-15  0:09 ` [PATCH v6 2/4] generic/574: corrupt btrfs merkle tree data Boris Burkov
2022-03-15  0:00   ` Eric Biggers [this message]
2022-02-15  0:09 ` [PATCH v6 3/4] btrfs: test verity orphans with dmlogwrites Boris Burkov
2022-02-15  0:09 ` [PATCH v6 4/4] generic: test fs-verity EFBIG scenarios Boris Burkov
2022-03-15  2:16   ` Eric Biggers
2022-03-15 22:06     ` Boris Burkov

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=Yi/XKWg9BWzmUGRy@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).