No description
Find a file
Eric Biggers f038c5f5e1 Refactor EncryptInplace.cpp
Refactor EncryptInplace.cpp to simplify and improve it a lot.  This is
everything that didn't fit into prior commits, including:

- Share a lot more code between ext4, f2fs, and full encryption.

- Improve the log messages.  Most importantly, don't spam the log with
  huge numbers of messages, and don't log errors in expected cases.
  Note: generate_f2fs_info() is still too noisy, but that's part of
  "system/extras", not vold, so this change doesn't change that.

- When possible, do 32K reads/writes for f2fs and for full encryption,
  not just for ext4.  This might improve performance.

- Take advantage of C++ functionality.

- Be more careful about edge cases.  E.g. if the calculation of the
  number of blocks to encrypt was wrong, don't set vold.encrypt_progress
  to > 99 until we're actually done.

The net change is over 200 lines removed.

Before-after comparison of log when enabling metadata encryption:

ext4 before:
    I vold    : Beginning inplace encryption, nr_sec: 16777216
    D vold    : cryptfs_enable_inplace(/dev/block/dm-8, /dev/block/by-name/userdata, 16777216, 0)
    D vold    : Opening/dev/block/by-name/userdata
    D vold    : Opening/dev/block/dm-8
    I vold    : Encrypting ext4 filesystem in place...
    [omitted 6387 log messages]
    I vold    : Encrypted to sector 822084608
    D vold    : cryptfs_enable_inplace_ext4 success
    I vold    : Inplace encryption complete

ext4 after:
    D vold    : encrypt_inplace(/dev/block/dm-8, /dev/block/by-name/userdata, 16777216, false)
    D vold    : ext4 filesystem has 64 block groups
    I vold    : Encrypting ext4 filesystem on /dev/block/by-name/userdata in-place via /dev/block/dm-8
    I vold    : 50327 blocks (206 MB) of 2097152 blocks are in-use
    D vold    : Encrypted 10000 of 50327 blocks
    D vold    : Encrypted 20000 of 50327 blocks
    D vold    : Encrypted 30000 of 50327 blocks
    D vold    : Encrypted 40000 of 50327 blocks
    D vold    : Encrypted 50000 of 50327 blocks
    D vold    : Encrypted 50327 of 50327 blocks
    I vold    : Successfully encrypted ext4 filesystem on /dev/block/by-name/userdata

f2fs before:
    I vold    : Beginning inplace encryption, nr_sec: 16777216
    D vold    : cryptfs_enable_inplace(/dev/block/dm-8, /dev/block/by-name/userdata, 16777216, 0)
    D vold    : Opening/dev/block/by-name/userdata
    D vold    : Opening/dev/block/dm-8
    E vold    : Reading ext4 extent caused an exception
    D vold    : cryptfs_enable_inplace_ext4()=-1
    [omitted logspam from f2fs_sparseblock]
    I vold    : Encrypting from block 0
    I vold    : Encrypted to block 15872
    I vold    : Encrypting from block 16384
    I vold    : Encrypted to block 16385
    I vold    : Encrypting from block 17408
    I vold    : Encrypted to block 17412
    D vold    : cryptfs_enable_inplace_f2fs success
    I vold    : Inplace encryption complete

f2fs after:
    D vold    : encrypt_inplace(/dev/block/dm-8, /dev/block/by-name/userdata, 16777216, false)
    [omitted logspam from f2fs_sparseblock]
    I vold    : Encrypting f2fs filesystem on /dev/block/by-name/userdata in-place via /dev/block/dm-8
    I vold    : 15880 blocks (65 MB) of 2097152 blocks are in-use
    D vold    : Encrypted 10000 of 15880 blocks
    D vold    : Encrypted 15880 of 15880 blocks
    I vold    : Successfully encrypted f2fs filesystem on /dev/block/by-name/userdata

Test: Booted Cuttlefish with metadata encryption enabled and with the
      userdata filesystem using (1) ext4, (2) f2fs, and (3) f2fs but
      with EncryptInplace.cpp patched to not recognize the filesystem
      and fall back to the "full" encryption case.  Checked that the log
      messages were as expected and that /data was mounted.

      I've had no luck testing FDE yet; it doesn't work even without
      these changes.  Suggestions appreciated...

Change-Id: I08fc8465f7962abd698904b5466f3ed080d53953
2020-11-03 14:16:32 -08:00
bench bench: Add fail-fast error path to inodeop_bench 2020-09-18 15:50:04 +00:00
binder/android/os Add IVold::destroyDsuMetadataKey() 2020-10-13 16:00:43 +08:00
fs Rename casefold/projectid properties (for f2fs). am: e9239f757e 2020-04-17 14:41:07 +00:00
model Set media folder +F for adopted storage as well 2020-10-20 18:55:54 -07:00
tests [vold] Add argument verification to IncFS methods 2020-03-25 17:21:49 -07:00
.clang-format vold: use system-clang-format 2019-09-16 12:00:40 -07:00
Android.bp Add IVold::destroyDsuMetadataKey() 2020-10-13 16:00:43 +08:00
AppFuseUtil.cpp AppFuseUtil: Call ForceUnmount before PrepareDir. 2019-04-09 18:45:32 +01:00
AppFuseUtil.h Extract AppFuse as a util 2018-11-14 07:28:06 +00:00
Benchmark.cpp vold: use RAII wake locks 2019-06-26 10:20:30 -07:00
Benchmark.h clang-format many files. 2018-09-18 15:41:22 -07:00
BenchmarkGen.h Abort long-running benchmarks, report progress. 2017-11-07 09:57:12 -07:00
Checkpoint.cpp IdleMaint: use fstab_default from VoldUtil 2020-10-15 16:54:38 -07:00
Checkpoint.h Add an isCheckpointing() binder call for adb remount. 2020-06-10 23:52:25 -07:00
CleanSpec.mk Add an empty CleanSpec.mk 2010-03-08 18:05:25 -08:00
cryptfs.cpp Refactor EncryptInplace.cpp 2020-11-03 14:16:32 -08:00
cryptfs.h Refactor key generation to handle both normal and metadata encryption. 2020-02-14 13:59:06 -08:00
CryptoType.cpp Generalize CryptoType infrastructure 2020-02-14 00:48:27 -08:00
CryptoType.h Generalize CryptoType infrastructure 2020-02-14 00:48:27 -08:00
Devmapper.cpp Replace manual dm ioctls with libdm. 2019-05-13 13:07:12 -07:00
Devmapper.h Replace manual dm ioctls with libdm. 2019-05-13 13:07:12 -07:00
EncryptInplace.cpp Refactor EncryptInplace.cpp 2020-11-03 14:16:32 -08:00
EncryptInplace.h Refactor EncryptInplace.cpp 2020-11-03 14:16:32 -08:00
FileDeviceUtils.cpp Remove excess logging in secdiscard 2019-03-21 19:13:51 +00:00
FileDeviceUtils.h clang-format many files. 2018-09-18 15:41:22 -07:00
FsCrypt.cpp FsCrypt: silently skip "." and ".." when loading keys 2020-11-02 15:47:42 -08:00
FsCrypt.h vold: Do not cache CE keys in vold 2020-01-24 00:20:22 +00:00
IdleMaint.cpp IdleMaint: skip swap space, bind mounts, and virtual filesystems 2020-10-15 16:56:16 -07:00
IdleMaint.h Add functions to handle idle maintenance 2017-11-14 15:12:30 -08:00
KeyBuffer.cpp clang-format many files. 2018-09-18 15:41:22 -07:00
KeyBuffer.h clang-format many files. 2018-09-18 15:41:22 -07:00
Keymaster.cpp Send earlyBootEnded notice to all Keymasters 2020-04-09 15:22:43 -06:00
Keymaster.h Send earlyBootEnded notice to all Keymasters 2020-04-09 15:22:43 -06:00
KeyStorage.cpp vold: Generate storage key without rollback resistance 2020-10-20 16:19:33 +00:00
KeyStorage.h KeyUtil: don't use keepOld=true for system DE and volume keys 2020-10-30 14:53:43 -07:00
KeyUtil.cpp Merge "KeyUtil: use static local variable in isFsKeyringSupported()" 2020-07-17 01:20:43 +00:00
KeyUtil.h KeyUtil: don't use keepOld=true for system DE and volume keys 2020-10-30 14:53:43 -07:00
Loop.cpp Silence useless LOOP_GET_STATUS64 warnings 2020-10-15 15:26:27 -07:00
Loop.h clang-format many files. 2018-09-18 15:41:22 -07:00
main.cpp Acknowledge the 'nofail' fs_mgr flag and skip the expected failure. 2020-05-06 16:45:23 +00:00
MetadataCrypt.cpp Refactor EncryptInplace.cpp 2020-11-03 14:16:32 -08:00
MetadataCrypt.h Add IVold::destroyDsuMetadataKey() 2020-10-13 16:00:43 +08:00
MoveStorage.cpp Utils: add IsDotOrDotDot() and use it in the appropriate places 2020-11-02 15:47:24 -08:00
MoveStorage.h clang-format many files. 2018-09-18 15:41:22 -07:00
NetlinkHandler.cpp vold: remove unused stop() methods 2020-09-23 10:02:25 -07:00
NetlinkHandler.h vold: remove unused stop() methods 2020-09-23 10:02:25 -07:00
NetlinkManager.cpp vold: remove unused stop() methods 2020-09-23 10:02:25 -07:00
NetlinkManager.h vold: remove unused stop() methods 2020-09-23 10:02:25 -07:00
OWNERS Add maco@ to vold OWNERS. 2020-08-11 09:13:58 +02:00
PREUPLOAD.cfg vold should be fully developed in AOSP. 2018-09-11 12:08:43 -06:00
Process.cpp Mount direct boot apps obb dir after fuse is ready. 2020-02-19 16:45:07 +00:00
Process.h Mount direct boot apps obb dir after fuse is ready. 2020-02-19 16:45:07 +00:00
ScryptParameters.cpp clang-format many files. 2018-09-18 15:41:22 -07:00
ScryptParameters.h clang-format many files. 2018-09-18 15:41:22 -07:00
secdiscard.cpp secdiscard: use F2FS_IOC_SEC_TRIM_FILE for secure discard 2020-09-14 08:43:15 +09:00
sehandle.h clang-format many files. 2018-09-18 15:41:22 -07:00
TEST_MAPPING FuseDaemonHostTest is migrated to CTS and renamed. 2020-05-28 18:43:08 +01:00
Utils.cpp Utils: add IsDotOrDotDot() and use it in the appropriate places 2020-11-02 15:47:24 -08:00
Utils.h Utils: add IsDotOrDotDot() and use it in the appropriate places 2020-11-02 15:47:24 -08:00
vdc.cpp Merge "vold: remove checkEncryption" am: 2d9777bfbf am: 15c0d3e5d0 2020-07-16 21:00:33 +00:00
vdc.rc Remove all references to FDE enable wipe 2017-12-22 11:17:15 -08:00
vold.rc vold: Grant root group 2018-08-08 17:08:02 -07:00
vold_prepare_subdirs.cpp Enable vold to set level from user. 2020-10-02 14:49:25 +01:00
VoldNativeService.cpp Add IVold::destroyDsuMetadataKey() 2020-10-13 16:00:43 +08:00
VoldNativeService.h Add IVold::destroyDsuMetadataKey() 2020-10-13 16:00:43 +08:00
VoldNativeServiceValidation.cpp Additional operation check when enabling read logs. 2020-04-03 18:42:04 -07:00
VoldNativeServiceValidation.h [vold] Add argument verification to IncFS methods 2020-03-25 17:21:49 -07:00
VoldUtil.cpp Move over to the C++ Fstab class 2019-01-31 12:34:39 -08:00
VoldUtil.h Remove unused code in VoldUtil.h 2020-02-18 10:48:16 -08:00
VolumeManager.cpp vold: remove unused stop() methods 2020-09-23 10:02:25 -07:00
VolumeManager.h vold: remove unused stop() methods 2020-09-23 10:02:25 -07:00
wait_for_keymaster.cpp add wait_for_keymaster 2018-05-09 12:59:18 -07:00
wait_for_keymaster.rc Add rc file for wait_for_keymaster 2018-05-15 16:15:21 -07:00