From: Eric Biggers <ebiggers@kernel.org>
To: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>
Cc: Johannes Thumshirn <jth@kernel.org>,
David Sterba <dsterba@suse.cz>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>,
Richard Weinberger <richard@nod.at>
Subject: Re: [PATCH v2 1/2] btrfs: add authentication support
Date: Mon, 4 May 2020 13:59:35 -0700 [thread overview]
Message-ID: <20200504205935.GA51650@gmail.com> (raw)
In-Reply-To: <SN4PR0401MB3598198E5FB728B68B39A1589BA60@SN4PR0401MB3598.namprd04.prod.outlook.com>
On Mon, May 04, 2020 at 10:09:44AM +0000, Johannes Thumshirn wrote:
> On 01/05/2020 07:39, Eric Biggers wrote:
> [...]
>
> Thanks for taking the time to look through this.
>
> >
> > This is a good idea, but can you explain exactly what security properties you
> > aim to achieve?
>
> My goal is to protect the file-system against offline modifications.
> Offline in this context means when the filesystem is not mounted.
>
> This could be a switched off laptop in a hotel room or a container
> image, or a powered off embedded system. When the file-system is mounted
> normal read/write access is possible.
But your proposed design doesn't do this completely, since some times of offline
modifications are still possible.
So that's why I'm asking *exactly* what security properties it will provide.
>
> > As far as I can tell, btrfs hashes each data block individually. There's no
> > contextual information about where eaech block is located or which file(s) it
> > belongs to. So, with this proposal, an attacker can still replace any data
> > block with any other data block. Is that what you have in mind? Have you
> > considered including contextual information in the hashes, to prevent this?
> >
> > What about metadata blocks -- how well are they authenticated? Can they be
> > moved around? And does this proposal authenticate *everything* on the
> > filesystem, or is there any part that is missed? What about the superblock?
>
> In btrfs every metadata block is started by a checksum (see struct
> btrfs_header or struct btrfs_super_block). This checksum protects the
> whole meta-data block (minus the checksum field, obviously).
>
> The two main structure of the trees are btrfs_node and btrfs_leaf (both
> started by a btrfs_header). struct btrfs_node holds the generation and
> the block pointers of child nodes (and leafs). Struct btrfs_leaf holds
> the items, which can be inodes, directories, extents, checksums,
> block-groups, etc...
>
> As each FS meta-data item, beginning with the super block, downwards to
> the meta-data items themselves is protected be a checksum, so the FS
> tree (including locations, generation, etc) is protected by a checksum,
> for which the attacker would need to know the key to generate.
>
> The checksum for data blocks is saved in a separate on-disk btree, the
> checksum tree. The structure of the checksum tree consists of
> btrfs_leafs and btrfs_nodes as well, both of which do have a
> btrfs_header and thus are protected by the checksums.
Does this mean that a parent node's checksum doesn't cover the checksum of its
child nodes, but rather only their locations? Doesn't that allow subtrees to be
swapped around without being detected?
>
> >
> > You also mentioned preventing replay of filesystem operations, which suggests
> > you're trying to achieve rollback protection. But actually this scheme doesn't
> > provide rollback protection. For one, an attacker can always just rollback the
> > entire filesystem to a previous state.
>
> You're right, replay is the wrong wording there and it's actually
> harmful in the used context. What I had in mind was, in order to change
> the structure of the filesystem, an attacker would need the key to
> update the checksums, otherwise the next read will detect a corruption.
>
> As for a real replay case, an attacker would need to increase the
> generation of the tree block, in order to roll back to a older state, an
> attacker still would need to modify the super-block's generation, which
> is protected by the checksum as well.
Actually, nothing in the current design prevents the whole filesystem from being
rolled back to an earlier state. So, an attacker can actually both "change the
structure of the filesystem" and "roll back to an earlier state".
It very well might not be practical to provide rollback protection, and this
feature would still be useful without it. But I'm concerned that you're
claiming that this feature provides rollback protection when it doesn't.
> > The hash algorithm needs to be passed as a mount option. Otherwise the attacker
> > gets to choose it for you among all the supported keyed hash algorithms, as soon
> > as support for a second one is added. Maybe use 'auth_hash_name' like UBIFS
> > does?
>
> Can you elaborate a bit more on that? As far as I know, UBIFS doesn't
> save the 'auth_hash_name' on disk, whereas 'BTRFS_CSUM_TYPE_HMAC_SHA256'
> is part of the on-disk format. As soon as we add a 2nd keyed hash, say
> BTRFS_CSUM_TYPE_BLAKE2B_KEYED, this will be in the superblock as well,
> as struct btrfs_super_block::csum_type.
>
The data on disk isn't trusted. Isn't that the whole point? The filesystem
doesn't trust it until it is MAC'ed, and to do that it needs the MAC algorithm.
- Eric
next prev parent reply other threads:[~2020-05-04 20:59 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-28 10:58 [PATCH v2 0/2] Add file-system authentication to BTRFS Johannes Thumshirn
2020-04-28 10:58 ` [PATCH v2 1/2] btrfs: add authentication support Johannes Thumshirn
2020-04-29 7:23 ` kbuild test robot
2020-04-29 11:46 ` Johannes Thumshirn
2020-05-01 5:39 ` Eric Biggers
2020-05-01 6:30 ` Eric Biggers
2020-05-04 8:38 ` Johannes Thumshirn
2020-05-05 22:33 ` David Sterba
2020-05-06 8:10 ` Johannes Thumshirn
2020-05-04 10:09 ` Johannes Thumshirn
2020-05-04 20:59 ` Eric Biggers [this message]
2020-05-05 8:11 ` Johannes Thumshirn
2020-05-05 9:26 ` Qu Wenruo
2020-05-05 9:59 ` Qu Wenruo
2020-05-05 22:32 ` David Sterba
2020-05-05 23:55 ` Qu Wenruo
2020-05-06 20:40 ` btree [was Re: [PATCH v2 1/2] btrfs: add authentication support] Goffredo Baroncelli
2020-05-05 22:19 ` [PATCH v2 1/2] btrfs: add authentication support David Sterba
2020-05-05 22:37 ` Eric Biggers
2020-05-06 8:30 ` Johannes Thumshirn
2020-05-05 22:14 ` David Sterba
2020-05-05 22:31 ` Eric Biggers
2020-05-05 22:46 ` David Sterba
2020-05-05 23:31 ` Eric Biggers
2020-05-06 0:29 ` David Sterba
2020-05-06 0:44 ` Eric Biggers
2020-05-04 21:37 ` Richard Weinberger
2020-05-05 7:46 ` Johannes Thumshirn
2020-05-05 11:56 ` Richard Weinberger
2020-05-04 21:59 ` Richard Weinberger
2020-05-05 7:55 ` Johannes Thumshirn
2020-05-05 12:36 ` Jeff Mahoney
2020-05-05 12:39 ` Qu Wenruo
2020-05-05 12:41 ` Jeff Mahoney
2020-05-05 12:48 ` Qu Wenruo
2020-05-05 23:02 ` David Sterba
2020-05-06 21:24 ` Goffredo Baroncelli
2020-05-05 23:00 ` David Sterba
2020-05-05 9:43 ` Qu Wenruo
2020-05-06 20:59 ` Goffredo Baroncelli
2020-04-28 10:58 ` [PATCH v2 2/2] btrfs: rename btrfs_parse_device_options back to btrfs_parse_early_options Johannes Thumshirn
2020-05-01 6:03 ` [PATCH v2 0/2] Add file-system authentication to BTRFS Eric Biggers
2020-05-04 8:39 ` Johannes Thumshirn
2020-05-05 23:16 ` David Sterba
2020-05-01 21:26 ` Jason A. Donenfeld
2020-05-05 23:38 ` David Sterba
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=20200504205935.GA51650@gmail.com \
--to=ebiggers@kernel.org \
--cc=Johannes.Thumshirn@wdc.com \
--cc=dsterba@suse.cz \
--cc=jth@kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=richard@nod.at \
/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).