From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from blaine.gmane.org (195-159-176-226.customer.powertech.no [195.159.176.226]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.server123.net (Postfix) with ESMTPS for ; Thu, 26 Sep 2019 23:27:36 +0200 (CEST) Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1iDbIU-000SE2-V3 for dm-crypt@saout.de; Thu, 26 Sep 2019 23:27:34 +0200 From: Robert Nichols Date: Thu, 26 Sep 2019 16:27:27 -0500 Message-ID: References: <83ff6ae8-0ac3-a2d3-a982-750862018d7c@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit In-Reply-To: Content-Language: en-US Subject: Re: [dm-crypt] Why is it necessary to "wipe" an authenticated luks2 device when creating it? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: dm-crypt@saout.de On 9/26/19 9:29 AM, Ondrej Kozina wrote: > On 9/26/19 3:38 PM, Robert Nichols wrote: >> >> On 9/26/19 2:41 AM, Milan Broz wrote: >>> On 25/09/2019 21:40, .. ink .. wrote: >>>> I just added an ability to create an authenticated luks2 device in >>>> zuluCrypt[1] and i am >>>> wondering why these volumes need to be wiped when created. I made it work by >>>> looking at how cryptsetup does it but i don't understand why because i >>>> have so far >>>> failed to find any documentation about it. >>> >>> I think it is explained in the referenced paper, we should add a FAQ about it. >>> >>> Initial wipe recalculates integrity tags - so you can read the device afterward. >>> >>> If you skip initialization (wipe), integrity tags for all sectors is incorrect >>> and read will return integrity failure (EILSEQ errno). >>> >>> In theory, it is not a problem ("do not read what you did not write"). >>> >>> But it reality it cases many programs to fail because it can access device >>> through page cache. If the *write* is not aligned to a page, page cache tries >>> to first read content, then update content, and write it back to the device. >>> >>> But as said above, all read fails because integrity tags are not initialized, >>> thus even page-unaligned writes can fail. >>> (I have seen this problem even in programs like mkfs, where it is apparent bug.) >> >> So, LUKS2 is incompatible with LVM thin provisioning or other sparse storage >> formats like QCOW2. Good to know. >> > > That is not correct. > > First, LUKS2 does not enforce use of authenticated encryption in any way. It's optional choice and definitely not default (it's still considered experimental feature, unlike LUKS2 format that is new upstream default). > > Contrary, if you prefer discards (trim) pass-through via dm-crypt you may use --persistent --allow-discards option so that it's automatically enabled during every following LUKS2 device activation. So it's more thin provisioning friendly if that is important for you (for others it may not be so). > > Yes, authenticated encryption with dm-integrity in interleave mode does require device initialization for reason Milan described and moreover dm-integrity does not allow discards pass-through so thin provisioning does not make sense with it because you won't be able to reclaim free space from it. I wasn't even thinking of trim pass-through. I routinely set up VMs with space allocations that, in total, exceed the space available on the host. Such VMs cannot use authenticated encryption since they would have to immediately use all of their allocated space. I also routinely save system images with partclone or clonezilla, specifically to avoid saving the content of the free space in the filesystems. Such an image would fail authentication when restored. These are fairly common practices. LUKS2 authenticated encryption should come with huge warnings. -- Bob Nichols "NOSPAM" is really part of my email address. Do NOT delete it.