Commit graph

2331 commits

Author SHA1 Message Date
Tom Cherry
4c5bde2b92 Move over to the C++ Fstab class
Test: build and boot
Change-Id: Id3850c9c133f6644073a2439368501253a2a94a9
2019-01-31 12:34:39 -08:00
Treehugger Robot
eb00112e09 Merge "Remove secontext.h, secontext.cpp, hash.h" 2019-01-30 16:29:26 +00:00
LongPing Wei
7f3ab95b8d Remove secontext.h, secontext.cpp, hash.h
cryptfs.cpp and MetadataCrypt.cpp can use android::vold::sFsckContext directly.
hash.h is unuseful.

Test: make
Change-Id: I7acdac97d6ed1c9b2a5dc367fcea8aa2942192e8
2019-01-30 16:28:02 +08:00
Eric Biggers
f028d279ae Merge "cryptfs: improve logging of dm-crypt device creation" 2019-01-29 20:58:29 +00:00
Eric Biggers
e7205eaa44 Merge "cryptfs: round down dm-crypt device size to crypto sector boundary" 2019-01-29 18:30:55 +00:00
Eric Biggers
e1a7e77269 cryptfs: improve logging of dm-crypt device creation
Log the main configuration of the dm-crypt device -- the name, the
cipher, the keysize, the real device, and the length -- in addition to
the extra parameters which we were already logging.

(We can't simply log the actual string passed to the kernel, of course,
 because that includes the key.  So we choose the fields individually.)

Test: booted device configured to use FDE and checked the log message
Change-Id: Ia95de807c4fad68d93b7e7e73508a01e5139dc76
2019-01-25 13:42:07 -08:00
Eric Biggers
ed45ec3ae8 cryptfs: round down dm-crypt device size to crypto sector boundary
This is needed to make adoptable storage volumes work with a 4K crypto
sector size when the block device size is not a multiple of 4K.

It is fine to do this because the filesystem ends on a 4K boundary
anyway and doesn't use any partial block at the end.

Bug: 123375298
Test: booted device configured to use FDE with sector size 4k, ran
      'sm set-virtual-disk true' and formatted the virtual SD card as
      adoptable storage.  Then did the same but with a temporary patch
      that changed kSizeVirtualDisk to be misaligned
Change-Id: I95ee6d7dcaaa8989c674aea9988c09116e830b0c
2019-01-25 13:42:02 -08:00
Treehugger Robot
aaac873faf Merge "Preserve options on remount in commitChanges" 2019-01-25 04:26:17 +00:00
Daniel Rosenberg
14ca4acd86 Preserve options on remount in commitChanges
Copy the existing mount options when remounting f2fs for checkpointing
mode.

Bug: 123376509
Test: Boot with checkpointing, and ensure entries match fstab
Change-Id: If022d9872a44657b550ab892259230805716dc77
2019-01-24 18:26:53 -08:00
Treehugger Robot
9b2b8fd459 Merge "Add supportsCheckpoint" 2019-01-24 06:14:44 +00:00
Daniel Rosenberg
9b667fbe41 Add supportsCheckpoint
This returns true if any entries in the fstab have checkpoint=
set.

Test: Call vdc checkpoint supportsCheckpoint. Should return 1
      iff an fstab entry has checkpoint=fs or checkpoint=block set
Bug: 111020314

Change-Id: Ic79bc96ded4da6605f73992dcff542e7cb50d705
2019-01-22 17:58:03 -08:00
Eric Biggers
f156c40404 Merge "cryptfs: check for errors in create_encrypted_random_key()" 2019-01-22 18:18:18 +00:00
Eric Biggers
a2bd436594 Merge "Utils: correctly handle read() errors in ReadRandomBytes()" 2019-01-22 18:14:49 +00:00
Sudheer Shanka
b9fae464fc Merge "Create new mount directory /mnt/runtime/full." 2019-01-19 00:24:23 +00:00
Sudheer Shanka
dd4bb17343 Create new mount directory /mnt/runtime/full.
This will be used for system internals to access
secondary volumes without having to bypass sdcardfs.

Bug: 121277410
Test: manual
Exempt-From-Owner-Approval: Got approval on internal master
Change-Id: I9b3e33f6c6e426e83469b8030b02d59c02183946
2019-01-18 23:48:45 +00:00
Eric Biggers
3a2f7db477 cryptfs: check for errors in create_encrypted_random_key()
When generating the key and salt we weren't checking for an error
opening or reading from /dev/urandom.  Switch to the helper function
ReadRandomBytes() and start checking for errors.

Test: Booted device with FDE.  As a extra sanity check I also
      temporarily added log messages that dump the key and salt,
      and I verified they still appear random.
Change-Id: I01ccee4f1f9910bf9508c8f02a918157393b0e68
2019-01-18 13:26:08 -08:00
Eric Biggers
0ef7bfd59c Utils: correctly handle read() errors in ReadRandomBytes()
read() returns -1 on error, so we need to use a signed type.

Test: Booted device with FDE
Change-Id: Ib44247c1cdfd38674a7439209e333823f2fb6cf8
2019-01-18 13:24:30 -08:00
Xin Li
9f7aa175a0 Merge "DO NOT MERGE - Skip pie-platform-release (PPRL.190105.001) in master" 2019-01-17 21:19:43 +00:00
Sudheer Shanka
2e9aafb620 Merge "Add UnmountTreeWithPrefix util method." 2019-01-17 18:04:27 +00:00
Annie Meng
625203444b Merge "Create subdirs in system_ce/ for multi-user backup" 2019-01-17 15:29:32 +00:00
Annie Meng
66176c55e9 Create subdirs in system_ce/ for multi-user backup
Backup system service bookkeeping is being moved to per-user CE
directories to support multiple users participating in the service.

Accompanies SELinux changes at aosp/873133

Bug: 121197420
Test: 1) Boot device; check dirs created with correct label; run backup
successfully on system user
2) Create secondary user; check dirs created with correct label; run
backup successfully

Change-Id: I3a0fdbfcf18a3c242fc64fba0dd014160b50b2f0
2019-01-17 12:53:16 +00:00
Annie Meng
3cc1866454 Merge "vold_prepare_subdirs: prepare /data/misc_[ce|de]/rollback." 2019-01-17 11:01:00 +00:00
Sudheer Shanka
295fb241e2 Add UnmountTreeWithPrefix util method.
Add a utility method to unmount all mountpoints
that start with a prefix.

Bug: 122905493
Test: manual
Change-Id: I11739e40e7849c1b4ca9e0b90c5c3f243691257a
2019-01-17 01:42:48 -08:00
Treehugger Robot
9ff07121ff Merge "Checkpoints: Support validation and roll forward on fail" 2019-01-17 01:08:20 +00:00
Paul Lawrence
27691c2883 Checkpoints: Support validation and roll forward on fail
Test: Rolls backward, and if you hexedit a BOW page, rolls forward
Change-Id: If99a6c3a3bc3f615bd1445f5af14ea490a58e053
2019-01-16 14:14:48 -08:00
Narayan Kamath
a232fd7fc8 vold_prepare_subdirs: prepare /data/misc_[ce|de]/rollback.
These directories are managed by installd and used to store
snapshots of application data directories in order to roll them
back in the case of bad updates.

Bug: 112431924
Test: make, device boot & manual verification.

Change-Id: Ieaca697a45d013937327e0f16f36b9b1eaad6b22
2019-01-16 15:16:51 +00:00
Xin Li
723b2545d2 DO NOT MERGE - Skip pie-platform-release (PPRL.190105.001) in master
Bug: 122685541
Change-Id: I951a35cc32c6dc0a3b051099d687c89a5e38ebbb
2019-01-15 10:19:51 -08:00
Treehugger Robot
a892eb154e Merge "Fsync directories after creating files" 2019-01-07 20:09:34 +00:00
Paul Crowley
621d9b9732 Fsync directories after creating files
Bug: 120248692
Test: adb shell locksettings set-pin 1111 && \
    adb shell "echo b > /proc/sysrq-trigger"
Change-Id: I53d252942c21365983b4f8b6e0948b1864f195c1
2019-01-07 04:30:08 -08:00
Treehugger Robot
1ea17070fe Merge "cryptfs: Add error messages when remove dm-crypt device is failed" 2019-01-07 09:45:22 +00:00
android-build-team Robot
06084fee42 Merge cherrypicks of [5929407, 5929627, 5929597, 5929598] into pi-platform-release
Change-Id: I71193baac96d5936f6e3dd69a7ee37e70d85f898
2019-01-03 23:49:33 +00:00
Greg Kaiser
13c6f32d77 cryptfs: Allow setting dm-crypt sector size
We add the property ro.crypto.fde_sector_size to allow devices
to pass the "sector_size:<size>" argument to dm-crypt in the kernel.
We also pass "iv_large_sectors" when setting the sector size.

Using 4096-byte sectors rather than the default of 512 improves
dm-crypt performance, especially when the Adiantum encryption mode
is used.

Bug: 112010205
Test: Run on a device
Change-Id: I144ec7088a0aad3430369dc7158370d7ff3ef5d2
Merged-In: I144ec7088a0aad3430369dc7158370d7ff3ef5d2
(cherry picked from commit 88738e8b6f59e307a2120d352843759025588539)
2019-01-03 23:49:28 +00:00
Greg Kaiser
7f0c5e4754 cryptfs: Add Adiantum support
Adiantum is a crypto method Android is supporting for devices
which don't have AES CPU instructions.  See the paper
"Adiantum: length-preserving encryption for entry-level processors"
(https://eprint.iacr.org/2018/720.pdf) for more details.

We add Adiantum to our list of supported crypto types.

Bug: 112010205
Test: Tested on a device
Change-Id: Ic190a9b90fc8bc077fdc7d60c9d5ae8d8f555025
Merged-In: Ic190a9b90fc8bc077fdc7d60c9d5ae8d8f555025
(cherry picked from commit 18824ec6cc9cd0f16530de2e034a7fe5b8fd17be)
2019-01-03 23:49:25 +00:00
Yue Hu
9d6cc18bf1 cryptfs: Add error messages when remove dm-crypt device is failed
We do not know what happened if remove dm-crypt device is failed, so
the error status added is useful to debug failed ioctl.

Change-Id: I49be91b9087ef2a213a706dd6b2a07eb6dafe6e6
Signed-off-by: Yue Hu <zbestahu@gmail.com>
2019-01-03 14:20:27 +08:00
Greg Kaiser
2374693556 Merge changes I1c50546e,I8254cb6b,Ib179299a,Iec1c2801
* changes:
  EncryptInplace: Rename variable
  Checkpoint: Assure proper buffer alignment
  vold: Pass std::string by const reference
  vold: const-ify some of the API
2018-12-21 00:10:42 +00:00
Greg Kaiser
e0691cc674 EncryptInplace: Rename variable
We rename our 'buf' in the inner scope to avoid confusion with
the 'buf' in the outer scope which is used immediately after
exiting the inner scope.

Test: TreeHugger
Change-Id: I1c50546e86c680e963eedcbda26138f8b43e55e9
2018-12-20 10:38:31 -08:00
Greg Kaiser
8859c9c9e7 Checkpoint: Assure proper buffer alignment
We have a char buffer on the stack, which we then cast to a
struct, and then proceed to access elements in the struct.
This is not safe across all platforms, as some platforms
may require a certain alignment for members of the struct.
We fix this by assuring an appropriate alignment for our
char buffer.

We also use C++ casting, and rename our buffer to differenciate
it from the other 'buffer' variable in this function.

Test: TreeHugger
Change-Id: I8254cb6b8124e394bd805afd1ccca0faedb27ffa
2018-12-20 10:38:31 -08:00
Greg Kaiser
8ae16db72a vold: Pass std::string by const reference
In a couple places, we change to pass a std::string argument
instead of by copy.

Test: TreeHugger
Change-Id: Ib179299a2322fcbab4e6d192051218823ad66a36
2018-12-20 10:38:31 -08:00
Greg Kaiser
ef9abab5ee vold: const-ify some of the API
We make some of the C++ member functions 'const', to reflect how
they (don't) affect the state of the class.

Test: TreeHugger
Change-Id: Iec1c2801bfe721e2741406ed1ac0ef95662840a6
Merged-In: Iec1c2801bfe721e2741406ed1ac0ef95662840a6
2018-12-20 10:38:15 -08:00
Treehugger Robot
03d3856c90 Merge changes from topic "checkpoint-enable"
* changes:
  Add Support for metadata key with rollback
  Add property for checkpointing
2018-12-15 04:39:51 +00:00
Daniel Rosenberg
690d6de5bf Add Support for metadata key with rollback
This adds the ability to upgrade a key and retain the
old one for rollback purposes. We delete the old key
if we boot successfully and delete the new key if we
do not.

Test: Enable checkpointing and test rolling back
      between two versions
Bug: 111020314

Change-Id: I19f31a1ac06a811c0644fc956e61b5ca84e7241a
2018-12-14 14:55:28 -08:00
Daniel Rosenberg
ffa1bb0370 Add property for checkpointing
We set a property when we commit a chackpoint to signal
to anyone who wants to do post commit cleanup.

Test: Boot to homescreen and check getprop for vold.checkpoint_committed
Bug: 111020314
Change-Id: Idf35e3abf9d24eb40c6926a30a8403064c05e10a
2018-12-14 14:55:16 -08:00
Greg Kaiser
7adca74263 Merge changes from topic "userspace_adiantum_support"
* changes:
  cryptfs: Allow setting dm-crypt sector size
  cryptfs: Add Adiantum support
2018-12-12 04:59:25 +00:00
Greg Kaiser
ab1e84ad5f cryptfs: Allow setting dm-crypt sector size
We add the property ro.crypto.fde_sector_size to allow devices
to pass the "sector_size:<size>" argument to dm-crypt in the kernel.
We also pass "iv_large_sectors" when setting the sector size.

Using 4096-byte sectors rather than the default of 512 improves
dm-crypt performance, especially when the Adiantum encryption mode
is used.

Bug: 112010205
Test: Run on a device
Change-Id: I144ec7088a0aad3430369dc7158370d7ff3ef5d2
2018-12-11 17:22:00 -08:00
Greg Kaiser
8cb4c9ff78 cryptfs: Add Adiantum support
Adiantum is a crypto method Android is supporting for devices
which don't have AES CPU instructions.  See the paper
"Adiantum: length-preserving encryption for entry-level processors"
(https://eprint.iacr.org/2018/720.pdf) for more details.

We add Adiantum to our list of supported crypto types.

Bug: 112010205
Test: Tested on a device
Change-Id: Ic190a9b90fc8bc077fdc7d60c9d5ae8d8f555025
2018-12-11 15:41:17 -08:00
Treehugger Robot
595172d1e6 Merge "DO NOT MERGE" 2018-12-10 17:20:41 +00:00
Treehugger Robot
b1166633b6 Merge "Check for errors in dup2" 2018-12-08 02:03:37 +00:00
Xin Li
e6ba0cc34a DO NOT MERGE
Merge pie-platform-release (PPRL.181205.001, history only) into master

Bug: 120502534
Change-Id: I087ef5ac78dc1c42448b7c8d50864a412afd3154
2018-12-07 16:14:54 -08:00
Paul Crowley
be857bfd9b Check for errors in dup2
Bug: 26735063
Test: adb shell sm partition disk:7,3 private && adb logcat -d
Change-Id: I3aa8d1f6183dd5e77f54f422482a54ea8197d768
2018-12-07 12:23:25 -08:00
Treehugger Robot
b46a2f7dea Merge "Fix signedness mismatch and integer underflow" 2018-12-07 11:05:17 +00:00