linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: miaoxie@huawei.com, Gao Xiang <hsiangkao@aol.com>,
	"Darrick J. Wong" <darrick.wong@oracle.com>
Cc: Jan Kara <jack@suse.cz>, Christoph Hellwig <hch@infradead.org>,
	Amir Goldstein <amir73il@gmail.com>,
	Dave Chinner <david@fromorbit.com>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	devel <devel@driverdev.osuosl.org>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Richard Weinberger <richard@nod.at>,
	Eric Biggers <ebiggers@kernel.org>,
	linux-erofs <linux-erofs@lists.ozlabs.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Jaegeuk Kim <jaegeuk@kernel.org>,
	"Theodore Y. Ts'o" <tytso@mit.edu>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	David Sterba <dsterba@suse.cz>, Pavel Machek <pavel@denx.de>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] erofs: move erofs out of staging
Date: Tue, 20 Aug 2019 14:04:46 +0800	[thread overview]
Message-ID: <301ccbea-4140-3816-a1b3-5018ffb4036c@gmx.com> (raw)
In-Reply-To: <698e2fa6-956b-b367-6f6a-3e6b09bfef5f@huawei.com>


[-- Attachment #1.1: Type: text/plain, Size: 4557 bytes --]

[...]
>> The same tool exists for btrfs, although lacks the write ability, but
>> that dump is more comprehensive and a great tool to learn the on-disk
>> format.
>>
>>
>> And for the fuzzing defending part, just a few kernel releases ago,
>> there is none for btrfs, and now we have a full static verification
>> layer to cover (almost) all on-disk data at read and write time.
>> (Along with enhanced runtime check)
>>
>> We have covered from vague values inside tree blocks and invalid/missing
>> cross-ref find at runtime.
>>
>> Currently the two layered check works pretty fine (well, sometimes too
>> good to detect older, improper behaved kernel).
>> - Tree blocks with vague data just get rejected by verification layer
>>   So that all members should fit on-disk format, from alignment to
>>   generation to inode mode.
>>
>>   The error will trigger a good enough (TM) error message for developer
>>   to read, and if we have other copies, we retry other copies just as
>>   we hit a bad copy.
>>
>> - At runtime, we have much less to check
>>   Only cross-ref related things can be wrong now. since everything
>>   inside a single tree block has already be checked.
>>
>> In fact, from my respect of view, such read time check should be there
>> from the very beginning.
>> It acts kinda of a on-disk format spec. (In fact, by implementing the
>> verification layer itself, it already exposes a lot of btrfs design
>> trade-offs)
>>
>> Even for a fs as complex (buggy) as btrfs, we only take 1K lines to
>> implement the verification layer.
>> So I'd like to see every new mainlined fs to have such ability.
> 
> It is a good idea. In fact, we already have a verification layer which was implemented
> as a device mapper sub-module. I think it is enough for a read-only filesystem because
> it is simple, flexible and independent(we can modify the filesystem layout without
> verification module modification).

If you're talking about dm-verity, then IMHO they are with completely
different objective.

For dm-verity it's more like authentication. Without proper key
(authentication), no one can modify the data without being caught.
That's why I hate such thing, it's not open at all, *as bad as locked
bootloader*.

While the tree-checker (the layer in btrfs) is more like a sensitive and
sometimes overreacting detector, find anything wrong, then reject the
offending tree block.

The original objective of tree-checker is to free coder from defensive
coding, providing a centralized verification service, thus we don't need
to verify tree blocks randomly using ugly BUG_ON()s.
(But unfortunately, a lot of BUG_ON()s are still kept as is, as it takes
more time to persuade reviewers that those BUG_ON()s are impossible to
hit anymore)

Tree-checker can not only detect suspicious metadata (either caused by
mem bit flip or poorly crafted image), but also bad *kernel* behavior or
even runtime bitflip. (Well, it only works for RW fs, so not really
helpful for a RO fs).

And performance is another point.
That tree-checker in btrfs is as fast/slow as CRC32.
Not sure how it would be for dm-verity, but I guess it's slower than
CRC32 if using any strong hash.

Anyway, for a RO fs, if it's relying on dm-verify then that's OK for
real-world usage.
But as a standalone fs, even it's RO, a verification layer would be a
great plus.

At least when new student developers try fuzzed images on the fs, it
would be a good surprise other than tons of new bug reports.

> 
>  
>>>
[...]
>>>
>>> Yes, we will do such a debugging tool of course. Actually Li Guifu is now
>>> developping a erofs-fuse to support old linux versions or other OSes for
>>> archiveing only use, we will base on that code to develop a better fuzzer
>>> tool as well.
>>
>> Personally speaking, debugging tool is way more important than a running
>> kernel module/fuse.
>> It's human trying to write the code, most of time is spent educating
>> code readers, thus debugging tool is way more important than dead cold code.
> 
> Agree, Xiang and I have no time to developing this feature now, we are glad very much if you could help
> us to do it ;)

In fact, since the fs is a RO fs, it could be pretty good educational
example for any fs newbies. Thus a debug tool which can show the full
metadata of the fs can really be helpful.

In fact, btrfs-debug-tree (now "btrfs ins dump-tree") leads my way to
btrfs, and still one of my favourite tool to debug.

Thanks,
Qu



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2019-08-20  6:06 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-17  8:23 [PATCH] erofs: move erofs out of staging Gao Xiang
2019-08-17 21:19 ` Richard Weinberger
2019-08-17 22:07   ` Gao Xiang
2019-08-17 23:25     ` Richard Weinberger
2019-08-17 23:38       ` Gao Xiang
2019-08-18  0:04         ` Gao Xiang
2019-08-18  0:52           ` Gao Xiang
2019-08-18  8:16         ` Richard Weinberger
2019-08-18  8:45           ` Gao Xiang
2019-08-18  9:03             ` Richard Weinberger
2019-08-18  9:09               ` Greg Kroah-Hartman
2019-08-18  9:21                 ` Richard Weinberger
2019-08-18 10:12                   ` Chao Yu
2019-08-18 15:11                   ` Theodore Y. Ts'o
2019-08-18 15:58                     ` Christoph Hellwig
2019-08-18 16:16                       ` Eric Biggers
2019-08-18 16:22                         ` Christoph Hellwig
2019-08-18 16:33                           ` Gao Xiang
2019-08-18 17:29                           ` Eric Biggers
2019-08-18 17:47                             ` Christoph Hellwig
2019-08-18 18:16                               ` Gao Xiang
2019-08-18 20:14                                 ` Gao Xiang
2019-08-19  7:35                                   ` Richard Weinberger
2019-08-19  8:02                                     ` Gao Xiang
2019-08-19 10:34                                       ` [PATCH 0/6] staging: erofs: first stage of corrupted compressed images Gao Xiang
2019-08-19 10:34                                         ` [PATCH 1/6] staging: erofs: some compressed cluster should be submitted for corrupted images Gao Xiang
2019-08-19 14:36                                           ` Chao Yu
2019-08-19 14:36                                             ` Chao Yu
2019-08-19 14:39                                           ` Chao Yu
2019-08-19 14:39                                             ` Chao Yu
2019-08-19 10:34                                         ` [PATCH 2/6] staging: erofs: cannot set EROFS_V_Z_INITED_BIT if fill_inode_lazy fails Gao Xiang
2019-08-19 14:43                                           ` Chao Yu
2019-08-19 14:43                                             ` Chao Yu
2019-08-19 10:34                                         ` [PATCH 3/6] staging: erofs: add two missing erofs_workgroup_put for corrupted images Gao Xiang
2019-08-19 14:40                                           ` Chao Yu
2019-08-19 14:40                                             ` Chao Yu
2019-08-19 10:34                                         ` [PATCH 4/6] staging: erofs: avoid loop in submit chains Gao Xiang
2019-08-19 14:50                                           ` Chao Yu
2019-08-19 14:50                                             ` Chao Yu
2019-08-19 10:34                                         ` [PATCH 5/6] staging: erofs: detect potential multiref due to corrupted images Gao Xiang
2019-08-19 14:57                                           ` Chao Yu
2019-08-19 14:57                                             ` Chao Yu
2019-08-21  2:19                                             ` Greg Kroah-Hartman
2019-08-21 14:01                                               ` [PATCH v2 " Gao Xiang
2019-08-21 14:24                                                 ` Chao Yu
2019-08-19 10:34                                         ` [PATCH 6/6] staging: erofs: avoid endless loop of invalid lookback distance 0 Gao Xiang
2019-08-19 14:58                                           ` Chao Yu
2019-08-19 14:58                                             ` Chao Yu
2019-08-19 16:09                                   ` [PATCH] erofs: move erofs out of staging Darrick J. Wong
2019-08-19 20:30                                     ` Gao Xiang via Linux-erofs
2019-08-20  0:55                                       ` Qu Wenruo
2019-08-20  1:55                                         ` Gao Xiang
2019-08-20  2:24                                         ` Chao Yu
2019-08-20  2:38                                           ` Qu Wenruo
2019-08-20  7:15                                             ` Chao Yu
2019-08-20  8:46                                               ` Qu Wenruo
2019-08-21  2:12                                                 ` Chao Yu
2019-08-20 15:56                                           ` Theodore Y. Ts'o
2019-08-20 16:35                                             ` Gao Xiang via Linux-erofs
2019-08-21  0:51                                               ` Theodore Y. Ts'o
2019-08-21  1:34                                             ` Chao Yu
2019-08-21  1:48                                               ` Darrick J. Wong
2019-08-21  1:57                                                 ` Chao Yu
2019-08-20  3:33                                         ` Miao Xie
2019-08-20  3:46                                           ` Gao Xiang
2019-08-20  6:04                                           ` Qu Wenruo [this message]
2019-08-20  6:22                                             ` Gao Xiang
2019-08-19  7:37                               ` Richard Weinberger
2019-08-18 17:43                       ` Theodore Y. Ts'o
2019-08-18 16:03                     ` Gao Xiang
2019-08-18 17:06                     ` Richard Weinberger
2019-08-18 17:46                       ` Theodore Y. Ts'o
2019-08-18 18:00                         ` Richard Weinberger
2019-08-18 18:31                           ` Gao Xiang
2019-08-18  9:28               ` Gao Xiang
2019-08-19  5:28                 ` [PATCH] erofs: Use common kernel logging style Joe Perches
2019-08-19  5:52                   ` Gao Xiang
2019-08-19  5:47                     ` Joe Perches
2019-08-19  6:08                       ` Gao Xiang

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=301ccbea-4140-3816-a1b3-5018ffb4036c@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=akpm@linux-foundation.org \
    --cc=amir73il@gmail.com \
    --cc=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=dsterba@suse.cz \
    --cc=ebiggers@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@infradead.org \
    --cc=hsiangkao@aol.com \
    --cc=jack@suse.cz \
    --cc=jaegeuk@kernel.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miaoxie@huawei.com \
    --cc=pavel@denx.de \
    --cc=richard@nod.at \
    --cc=sfr@canb.auug.org.au \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    /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).