home of the madduck/ blog/
Blackouts and encrypted filesystems

After some recent filesystem fun, I now have a laptop with encrypted partitions, using dm-crypt and LUKS, conveniently installed with partman-crypto.

Pre-Scriptum: I have updated my previous post about XFS troubles in response to Ingo's statements. Just in case you care...

The following post poses a question and a meta-question:

As I was cycling home today, I thought about what would happen if my laptop lost power now in the middle of a write operation. Sure, ext3's journal would make sure the filesystem was consistent, but what about the actual data on the disk?

Journaling works by writing a change to the journal, then writing it to disk, then deleting the enty from the journal. If the filesystem is mounted and it has entries in the journal, those are "played back", meaning they just get written to disk again, overwriting potentially incomplete data written as the power was lost. Yes, this is simplified, but it'll do for now.

With encrypted filesystems, there's an important layer between the filesystem and the physical storage: the encryption algorithm. An encryption algorithm like AES works on blocks, by default 64 bytes in size. 64 bytes are not a whole lot, but given the nature of hard drives, it's not possible to write 64 bytes to the drive atomically [*]_. Thus, conceivably, it could happen that your power cuts out after only 32 bytes have been written. I don't believe dm-crypt does journaling for the encrypted data it writes, so effectively, a power loss on systems with encrypted filesystems almost certainly means data loss?

Please correct me if I'm wrong!

And the meta-question would be: where would I go to discuss such issues? I've abused debian-security previously, the issue seems too general for the dm-crypt mailing list, there is cryptography ät metzdowd.com but somehow this does not seem to be a crypto problem... so where would you take this? Let me know...

.. [*] In a computer architecture course in college, the prof raised the : interesting point that between the loss of power and the actual disappearance of all current in the circuits, several million operations are possible on modern machines. I have not yet heard of any computer or hardware device making use of those precious cycles.

: Update: actually, several manufacturers are making use of the precious cycles. See for instance this post, which describes some stuff done by SGI. Hanspeter Kunz also adds that harddrives use this time to park their heads.