linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: Alex Elsayed <eternaleye@gmail.com>, linux-btrfs@vger.kernel.org
Subject: Re: [RFC] Preliminary BTRFS Encryption
Date: Fri, 16 Sep 2016 19:35:40 +0800	[thread overview]
Message-ID: <08d5b53f-f5df-65bb-cf79-fe0a87451f9c@oracle.com> (raw)
In-Reply-To: <nre1o9$hdn$2@blaine.gmane.org>



On 09/15/2016 07:47 PM, Alex Elsayed wrote:
> On Thu, 15 Sep 2016 19:33:48 +0800, Anand Jain wrote:
>
>> Thanks for commenting. pls see inline below.
>>
>> On 09/15/2016 12:53 PM, Alex Elsayed wrote:
>>> On Tue, 13 Sep 2016 21:39:46 +0800, Anand Jain wrote:
>>>
>>>> This patchset adds btrfs encryption support.
>>>>
>>>> The main objective of this series is to have bugs fixed and stability.
>>>> I have verified with fstests to confirm that there is no regression.
>>>>
>>>> A design write-up is coming next, however here below is the quick
>>>> example on the cli usage. Please try out, let me know if I have missed
>>>> something.
>>>>
>>>> Also would like to mention that a review from the security experts is
>>>> due,
>>>> which is important and I believe those review comments can be
>>>> accommodated without major changes from here.
>>>>
>>>> Also yes, thanks for the emails, I hear, per file encryption and
>>>> inline with vfs layer is also important, which is wip among other
>>>> things in the list.
>>>>
>>>> As of now these patch set supports encryption on per subvolume, as
>>>> managing properties on per subvolume is a kind of core to btrfs, which
>>>> is easier for data center solution-ing, seamlessly persistent and easy
>>>> to manage.
>>>>
>>>>
>>>> Steps:
>>>> -----
>>>>
>>>> Make sure following kernel TFMs are compiled in.
>>>> # cat /proc/crypto | egrep 'cbc\(aes\)|ctr\(aes\)'
>>>> name         : ctr(aes)
>>>> name         : cbc(aes)
>>>
>>> First problem: These are purely encryption algorithms, rather than AE
>>> (Authenticated Encryption) or AEAD (Authenticated Encryption with
>>> Associated Data). As a result, they are necessarily vulnerable to
>>> adaptive chosen-ciphertext attacks, and CBC has historically had other
>>> issues. I highly recommend using a well-reviewed AE or AEAD mode, such
>>> as AES-GCM (as ecryptfs does), as long as the code can handle the
>>> ciphertext being longer than the plaintext.
>>>
>>> If it _cannot_ handle the ciphertext being longer than the plaintext,
>>> please consider that a very serious red flag: It means that you cannot
>>> provide better security than block-level encryption, which greatly
>>> reduces the benefit of filesystem-integrated encryption. Being at the
>>> extent level _should_ permit using AEAD - if it does not, something is
>>> wrong.
>>>
>>> If at all possible, I'd suggest _only_ permitting AEAD cipher modes to
>>> be used.
>>>
>>> Anyway, even for block-level encryption, CTR and CBC have been
>>> considered obsolete and potentially dangerous to use in disk encryption
>>> for quite a while - current recommendations for block-level encryption
>>> are to use either a narrow-block tweakable cipher mode (such as XTS),
>>> or a wide- block one (such as EME or CMC), with the latter providing
>>> slightly better security, but worse performance.
>>
>>    Yes. CTR should be changed, so I have kept it as a cli option. And
>>    with the current internal design, hope we can plugin more algorithms
>>    as suggested/if-its-outdated and yes code can handle (or with a
>>    little tweak) bigger ciphertext (than plaintext) as well.
>>
>>    encryption + keyhash (as below) + Btrfs-data-checksum provides
>>    similar to AE,  right ?
>
> No, it does not provide anything remotely similar to AE. AE requires
> _cryptographic_ authentication of the data. Not only is a CRC (as Btrfs
> uses for the data checksum) not enough, a _cryptographic hash_ (such as
> SHA256) isn't even enough. A MAC (message authentication code) is
> necessary.
>
> Moreover, combining an encryption algorithm and a MAC is very easy to get
> wrong, in ways that absolutely ruin security - as an example, see the
> Vaudenay/Lucky13 padding oracle attacks on TLS.
>
> In order for this to be secure, you need to use a secure encryption
> system that also authenticates the data in a cryptographically secure
> manner. Certain schemes are well-studied and believed to be secure - AES-
> GCM and ChaCha20-Poly1305 are common and well-regarded, and there's a
> generic security reduction for Encrypt-then-MAC constructions (using CTR
> together with HMAC in such a construction is generally acceptable).
>
> The Btrfs data checksum is wholly inadequate, and the keyhash is a non-
> sequitur - it prevents accidentally opening the subvolume with the wrong
> key, but neither it (nor the btrfs data checksum, which is a CRC rather
> than a cryptographic MAC) protect adequately against malicious corruption
> of the ciphertext.
>
> I'd suggest pulling in Herbert Xu, as he'd likely be able to tell you
> what of the Crypto API is actually sane to use for this.


  As mentioned 'inline with vfs layer' I mean to say to use
  fs/crypto KPIs. Which I haven't seen what parts of the code
  was made as generic KPIs from ext4. If that's solving the
  problem, then it would here as well.


>>>> Create encrypted subvolume.
>>>> # btrfs su create -e 'ctr(aes)' /btrfs/e1 Create subvolume '/btrfs/e1'
>>>> Passphrase:
>>>> Again passphrase:
>>>
>>> I presume the command first creates a key, then creates a subvolume
>>> referencing that key? If so, that seems sensible.
>>
>>   Hmm I didn't get the why part, any help ? (this doesn't encrypt
>>   metadata part).
>
> Basically, if your tool merely sets up an entry in the kernel keyring,
> then calls the subvolume creation interface (passing in the key ID), then
> it can be composed with more advanced tooling that generates the key in a
> different manner.
>
> If, instead, you call the subvolume creation API with a flag saying
> "please also create a key", then it does not compose and is inflexible.
>
> That then becomes an obstacle to later extensions, such as trusted &
> encrypted keys.

   Yes key creation and subvol create are separate and independent.

Thanks, Anand


>>>> A key is created and its hash is updated into the subvolume item,
>>>> and then added to the system keyctl.
>>>> # btrfs su show /btrfs/e1 | egrep -i encrypt
>>>> 	Encryption: 		ctr(aes)@btrfs:75197c8e (594790215)
>>>>
>>>> # keyctl show 594790215 Keyring
>>>>  594790215 --alsw-v      0     0  logon: btrfs:75197c8e
>>>
>>> That's entirely reasonable, though you may want to support "trusted and
>>> encrypted keys" (Documentation/security/keys-trusted-encrypted.txt)
>>
>>    Yes. that's in the list.
>>
>
> Okay, good to hear!
>
> <snip>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

  reply	other threads:[~2016-09-16 11:33 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-13 13:39 [RFC] Preliminary BTRFS Encryption Anand Jain
2016-09-13 13:39 ` [PATCH] btrfs: Encryption: Add btrfs encryption support Anand Jain
2016-09-13 14:12   ` kbuild test robot
2016-09-13 14:24   ` kbuild test robot
2016-09-13 16:10   ` kbuild test robot
2016-09-13 13:39 ` [PATCH 1/2] btrfs-progs: make wait_for_commit non static Anand Jain
2016-09-13 13:39 ` [PATCH 2/2] btrfs-progs: add encryption support Anand Jain
2016-09-13 13:39 ` [PATCH] fstests: btrfs: support encryption Anand Jain
2016-09-13 16:42 ` [RFC] Preliminary BTRFS Encryption Wilson Meier
2016-09-14  7:02   ` Anand Jain
2016-09-14 18:26     ` Wilson Meier
2016-09-15  4:53 ` Alex Elsayed
2016-09-15 11:33   ` Anand Jain
2016-09-15 11:47     ` Alex Elsayed
2016-09-16 11:35       ` Anand Jain [this message]
2016-09-15  5:38 ` Chris Murphy
2016-09-15 11:32   ` Anand Jain
2016-09-15 11:37 ` Austin S. Hemmelgarn
2016-09-15 14:06   ` Anand Jain
2016-09-15 14:24     ` Austin S. Hemmelgarn
2016-09-16  8:58       ` David Sterba
2016-09-17  2:18       ` Zygo Blaxell
2016-09-16  1:12 ` Dave Chinner
2016-09-16  5:47   ` Roman Mamedov
2016-09-16  6:49   ` Alex Elsayed
2016-09-17  4:38     ` Zygo Blaxell
2016-09-17  6:37       ` Alex Elsayed
2016-09-19 18:08         ` Zygo Blaxell
2016-09-19 20:01           ` Alex Elsayed
2016-09-19 22:22             ` Zygo Blaxell
2016-09-19 22:25             ` Chris Murphy
2016-09-19 22:31               ` Zygo Blaxell
2016-09-20  1:10                 ` Zygo Blaxell
2016-09-17 18:45       ` David Sterba
2016-09-20 14:26         ` Anand Jain
2016-09-16 10:45   ` Brendan Hide
2016-09-16 11:46   ` Anand Jain
2016-09-16  8:49 ` David Sterba
2016-09-16 11:56   ` Anand Jain
2016-09-17 20:35     ` David Sterba
2016-09-18  8:34       ` RAID1 availability issue[2], Hot-spare and auto-replace Anand Jain
2016-09-18 17:28         ` Chris Murphy
2016-09-18 17:34           ` Chris Murphy
2016-09-19  2:25           ` Anand Jain
2016-09-19 12:07             ` Austin S. Hemmelgarn
2016-09-19 12:25           ` Austin S. Hemmelgarn
2016-09-18  9:54       ` [RFC] Preliminary BTRFS Encryption Anand Jain
2016-09-20  0:12   ` Chris Mason
2016-09-20  0:55     ` Anand Jain
2016-09-17  6:58 ` Eric Biggers
2016-09-17  7:13   ` Alex Elsayed
2016-09-19 18:57     ` Zygo Blaxell
2016-09-19 19:50       ` Alex Elsayed
2016-09-19 22:12         ` Zygo Blaxell
2016-09-17 16:12   ` Anand Jain
2016-09-17 18:57     ` Chris Murphy
2016-09-19 15:15 ` Experimental btrfs encryption Theodore Ts'o
2016-09-19 20:58   ` Alex Elsayed
2016-09-20  0:32     ` Chris Mason
2016-09-20  2:47       ` Alex Elsayed
2016-09-20  2:50       ` Theodore Ts'o
2016-09-20  3:05         ` Alex Elsayed
2016-09-20  4:09         ` Zygo Blaxell
2016-09-20 15:44         ` Chris Mason
2016-09-21 13:52           ` Anand Jain
2016-09-20  4:05   ` Anand Jain

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=08d5b53f-f5df-65bb-cf79-fe0a87451f9c@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=eternaleye@gmail.com \
    --cc=linux-btrfs@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).