Commit graph

4299 commits

Author SHA1 Message Date
Eric Biggers
fec0c0e472 Add syncs when creating parent directories
vold creates some directories for storing encryption keys if they don't
already exist, potentially including parent directories:

    /metadata/vold/metadata_encryption
    /data/misc/vold/volume_keys/$volume_uuid
    /data/misc_de/$user/vold/volume_keys/$volume_uuid
    /data/misc_ce/$user/vold/volume_keys/$volume_uuid

Currently fs_mkdirs() is used for this.  However, fs_mkdirs() doesn't
include the fsync()s of the parent directories that are needed to ensure
that the new directories are persisted to disk right away -- which is
important for encryption keys.

Add a utility function MkdirsSync() which does what is needed, and make
the appropriate places call it.

Test: Booted and checked log for "Created directory" message.
      Also ran 'atest vold_tests' to run the new unit test.
Change-Id: Ie9917b616433080139b8db3fd6877203ee6faf77
2021-02-16 16:18:53 -08:00
Eric Biggers
3345a2a98c Sync parent directory in storeKeyAtomically()
When an FBE or metadata encryption key is created, it's important that
it be persisted to disk right away; otherwise the device may fail to
boot after an unclean shutdown.  storeKey() has the needed fsync()s.
However, storeKeyAtomically() doesn't, as it doesn't fsync() the parent
directory of key_path after it renames tmp_path to it.

Two callers do fsync() the parent directory themselves, but others
don't.  E.g., the metadata encryption key doesn't get properly synced.

Therefore, add the needed fsync() to storeKeyAtomically() so that it
gets done for everyone.

Also remove the now-unneeded fsync()s from the two callers that did it
themselves.

Change-Id: I342ebd94f0a3d2bf3a7a443c35b6bda0f12e1ab2
2021-02-16 16:05:38 -08:00
Eric Biggers
bd138dd08a Move pathExists() to Utils.cpp
This is useful as a general utility function.

Change-Id: Id43fc106dc6c544c6e4ce65f10c7d4246b99e54a
2021-02-16 16:05:38 -08:00
Treehugger Robot
810bcca4d0 Merge "[LSC] Add LOCAL_LICENSE_KINDS to system/vold" 2021-02-15 23:21:47 +00:00
Bob Badour
8eb43ae497 [LSC] Add LOCAL_LICENSE_KINDS to system/vold
Added SPDX-license-identifier-Apache-2.0 to:
  Android.bp
  bench/inodeop_bench/Android.bp
  tests/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I91823c7097d7bee39a363a0c0cc30de13e4d7539
2021-02-14 10:37:25 -08:00
Treehugger Robot
915f6227a7 Merge "Obtain incfs features early in the booting sequence." 2021-02-13 06:32:14 +00:00
Alex Buynytskyy
b02e7b698e Obtain incfs features early in the booting sequence.
Has to be done before SystemConfig initialization to set correct
Incremental version feature.

Bug: 180010901
Test: atest PackageManagerShellCommandTest PackageManagerShellCommandIncrementalTest IncrementalServiceTest PackageManagerServiceTest ChecksumsTest
Change-Id: I262d1f06aecb481f37bf82005c85fed02c476510
2021-02-12 08:39:13 -08:00
Martijn Coenen
2e8f0d438b Merge "Revert "Revert "Set a default ACL on /data/media/userId.""" 2021-02-01 13:30:04 +00:00
Martijn Coenen
ea9681e4cd Revert "Revert "Set a default ACL on /data/media/userId.""
This reverts commit b276e80aec.

Reason for revert: b/177926359 is now fixed

Change-Id: I8ec5d80a44fc9e491ab3430592e17d10a82f40ea
2021-02-01 07:57:02 +00:00
Seth Moore
6207c9cde4 Merge "Add support for binding storage encryption to a seed" 2021-01-27 00:40:35 +00:00
Treehugger Robot
8e10f698ef Merge "Specify version for aidl_interface explicitly" 2021-01-26 22:28:23 +00:00
Seth Moore
5a43d61e66 Add support for binding storage encryption to a seed
With this change, vold exposes an API that may be used to bind key
storage encryption keys to a given seed value. The seed value passed to
vold must be consistent across reboots, or key storage keys will not be
derived consistently. The seed is expected to be set very early in boot,
prior to the use of any key storage encryption keys.

This feature is intended to be used for embedded applications such as
in autos, where the seed may be provided by some other component of the
system. In such systems, there is a default user that is automatically
signed in without a PIN or other credentials. By binding the file
encryption to a platform-provided seed, the default user's data gains
additional protection against removal of the Android embedded device
from the integrated system.

Bug: 157501579
Test: Set seed at startup via init.rc. Seed changes fail as expected.
Change-Id: I9b048ec5e045b84c45883724ace2356d4ef6244d
2021-01-26 21:30:19 +00:00
Jeongik Cha
89253240ec Specify version for aidl_interface explicitly
Bug: 150578172
Test: m
Change-Id: Ie51caa503b6b1e5c29372b85d0357be292144126
2021-01-26 22:35:14 +09:00
Martijn Coenen
d9cf8590cb Merge "Revert "Set a default ACL on /data/media/userId."" 2021-01-21 08:19:20 +00:00
Yifan Hong
3355ff7790 Merge changes from topic "health_storage_aidl"
* changes:
  Use AIDL HAL for Dev GC
  Refactor HIDL HAL Dev GC invocation
2021-01-20 19:45:16 +00:00
Martijn Coenen
b276e80aec Revert "Set a default ACL on /data/media/userId."
This reverts commit a71323ec0e.

Reason for revert: b/177926359 - note that this is a Google testing infrastructure issue, and no issue with this patch. Partners can keep using this patch. It will be resubmitted in a few weeks.

Change-Id: Ia13279ac1aafa2e4425c4527aeadd5d0fadbc2e4
2021-01-20 15:51:44 +00:00
Treehugger Robot
69c97b6d12 Merge "Revert^4 "Customize StubVolume implementation for ARC"" 2021-01-20 10:33:52 +00:00
Risan
4ad2048001 Revert^4 "Customize StubVolume implementation for ARC"
This reverts commit 8ed81fd9ca.

Reason for revert: Let me try one last time more carefully. According to https://googleplex-android-review.git.corp.google.com/q/%2522customize+stubvolume%2522 - this CL will flow to aosp branches (without vendor images) and 2 branches with vendor images. I have submitted the vendor CL for both branches now (ag/13366009 and ag/13371672). This should not break anything now.

Change-Id: I69aacceabfb70053387a3c156b49e06be65fe6e4
2021-01-20 10:33:18 +00:00
Maurice Lam
922af320dd Merge "Revert "Revert "Revert "Customize StubVolume implementation for ARC"""" 2021-01-19 19:28:36 +00:00
Maurice Lam
8ed81fd9ca Revert "Revert "Revert "Customize StubVolume implementation for ARC"""
This reverts commit 3164c0a238.

Reason for revert: b/177917240

Change-Id: I69f541698a3068d59553d555846ba45d169fbbed
2021-01-19 19:03:56 +00:00
rickywai
d4de02ed14 Merge "Call setupAppDir before EnsureDirExists" 2021-01-19 15:24:02 +00:00
Ricky Wai
f6da79cf5d Call setupAppDir before EnsureDirExists
So we can ensure Android/ dir is created,
otherwise EnsureDirExists may return false if Android/ doesn't exist

Bug: 177281374
Test: Able to boot without errors
Change-Id: I02e816b60530ac9d3d3b978a7c9028d2c0e34bad
2021-01-19 11:28:05 +00:00
Risan
a8ebbe77a0 Merge "Revert "Revert "Customize StubVolume implementation for ARC""" 2021-01-19 11:20:08 +00:00
Martijn Coenen
14782046f3 Merge "Set a default ACL on /data/media/userId." 2021-01-19 09:38:55 +00:00
Risan
3164c0a238 Revert "Revert "Customize StubVolume implementation for ARC""
This reverts commit 0cf77b025d.

Reason for revert: The requird libarcvolume has been submitted to master (ag/13366009)

Change-Id: I86fada53aad2ec5faa497a9bcbce5435c35d040e
2021-01-19 02:24:38 +00:00
Mariia Sandrikova
5558a72d03 Merge "Revert "Customize StubVolume implementation for ARC"" 2021-01-18 18:00:07 +00:00
Treehugger Robot
502c283c22 Merge "Add a method in vold to unmount app data and obb dir for testing" 2021-01-18 16:20:41 +00:00
Mariia Sandrikova
0cf77b025d Revert "Customize StubVolume implementation for ARC"
This reverts commit b5d7cb0a52.

Reason for revert: Broken build b/177828900
Fix: 177829766

Change-Id: Ic2984da3b11bcf5597203b511943d3058ea9ea19
2021-01-18 15:28:41 +00:00
Treehugger Robot
5e103f1106 Merge "Add kVisible flag to vold::Disk" 2021-01-18 14:54:27 +00:00
Ricky Wai
a2ca11e49b Add a method in vold to unmount app data and obb dir for testing
This new method will be used in new sm command.
Tests can use this so data and obb dirs are unmounted, and won't
be killed when volume is unmounted.

Bug: 148049767
Test: New sm command able to unmount app's data and obb dirs
Change-Id: Ifbc661ca510e996abd4b7ce1fb195aaa7afc37ad
2021-01-18 13:47:44 +00:00
Risan
253dd94521 Merge "Customize StubVolume implementation for ARC" 2021-01-18 12:49:36 +00:00
Youkichi Hosoi
defc0454a2 Add kVisible flag to vold::Disk
The new flag is used to indicate that a stub volume (external storage
volume shared with Chrome OS) is visible to Android apps.

Bug: 123377807
Bug: 142684760
Bug: 132796154
Test: Check logcat logs for StorageManagerService.mount() when the
Test: visibility setting of a removable device is toggled in Chrome OS.
Test: Confirm that the visibility setting is properly set.
Test: (Tested in R)
Change-Id: Ica69110d5667837a72a5c8693ff3bccc0f09a82d
2021-01-18 11:58:10 +00:00
Risan
b5d7cb0a52 Customize StubVolume implementation for ARC
This allow ARC to customize StubVolume implementation in vendor
partition.

Bug: 132796154
Test: Customize the implementation of StubVolume and check on device.
Ignore-AOSP-First: Will cherry-pick to AOSP.
Change-Id: I626a7ed4113b6132bb456b3258ee4a93b4f8a72e
2021-01-18 08:31:58 +00:00
Yifan Hong
e1e494519e Use AIDL HAL for Dev GC
Test: run idle maint
Bug: 177470478

Change-Id: Iefddf8628e31f020b86ff56dfb4926c2c9a2a888
2021-01-15 18:27:57 -08:00
Yifan Hong
8f0d45441c Refactor HIDL HAL Dev GC invocation
Prefix all HIDL HAL types with the letter H.
Also make the invocation more generic so that we can use
the AIDL implementation in the future.

Test: TH
Bug: 177470478

Change-Id: Iee0af9727c48c532315203c138a4996a08fcaa34
2021-01-15 18:27:57 -08:00
rickywai
610eba0ad0 Merge "Remove persist.sys.fuse == false code paths" 2021-01-15 14:00:35 +00:00
Ricky Wai
e78c78c2e6 Remove persist.sys.fuse == false code paths
Since Android R, the FUSE prop is always on and FUSE-off is no longer
supported

Test: m
Bug: 160159282
Merged-In: Ic4414b850511fe3b4fc6df3f8b736d21335db820
Change-Id: I5a7643f9ca2f37cd7f264331df76b42df31988d5
2021-01-14 15:51:54 +00:00
Alan Stokes
c0e870af67 Merge "Remove ro.vold.level_from_user." 2021-01-12 11:17:50 +00:00
rickywai
f5967975b0 Merge "Vold should still create obb / data dirs for sdcardfs device" 2021-01-08 13:14:57 +00:00
Ricky Wai
1cdd35618a Vold should still create obb / data dirs for sdcardfs device
Otherwise, zygote can't find those dirs and bind mount them.

Bug: 176959830
Test: atest AdoptableHostTest
Change-Id: Ib8a7616f8e248fed244d4f23d3ae36b1419a732d
2021-01-07 09:57:44 +00:00
Jaegeuk Kim
9cecd65006 Merge "Let vold format the encrypted partition" 2021-01-06 19:12:35 +00:00
Alan Stokes
e0b7f306c1 Remove ro.vold.level_from_user.
This is on everywhere, we no longer have any need for it.

Fix: 171462631
Test: Presubmits
Change-Id: I240361619acafeee6cac383037887e15a46c0c38
2021-01-05 09:49:24 +00:00
Martijn Coenen
6836a8bda7 Merge "Revert "Set a default ACL on /data/media/userId."" 2020-12-24 08:38:02 +00:00
Martijn Coenen
a71323ec0e Set a default ACL on /data/media/userId.
This directory is used as a root for external storage on adopted storage
devices. It needs to be writable by processes holding the AID_MEDIA_RW
GID permission; in particular, it should be writable by the FUSE daemon.

On devices with sdcardfs, this was ensured automatically, because
sdcardfs presented a view of this directory that was writable, that we
could use for the FUSE daemon. But on devices without sdcardfs, the FUSE
daemon sees the raw filesystem and its permissions. This also means that
files created by the FUSE daemon will have their uid/gid set to the uid
of the FUSE daemon; to ensure these files stay writable to other system
applications that have AID_MEDIA_RW, use a default ACL to make sure the
gid stays AID_MEDIA_RW.

In particular, this fixes an issue with app cloning, where we want the
FUSE daemon of user 0 to be able to access the files of the app clone
user, and vice versa.

Bug: 154057120
Test: inspect uid/gid of /data/media/0 and contents
Change-Id: Ib718b8362df84754ee3cac33865bca3c12df2e3a
2020-12-23 21:05:02 +00:00
Martijn Coenen
94d6c1275d Revert "Set a default ACL on /data/media/userId."
This reverts commit 8688eb4f47.

Reason for revert: Probably causing b/176240229

Change-Id: Id92d1f1589e8927f372960ec2cc5d262d10ad161
2020-12-23 19:14:15 +00:00
Martijn Coenen
c5c3cdee24 Merge "Set a default ACL on /data/media/userId." 2020-12-23 07:56:19 +00:00
Jaegeuk Kim
0c52c7125f Let vold format the encrypted partition
Bug: 172378121
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I03997eb4cbf25a80e36ea738c50e0adb7f4013dd
2020-12-22 11:28:50 -08:00
Martijn Coenen
8688eb4f47 Set a default ACL on /data/media/userId.
This directory is used as a root for external storage on adopted storage
devices. It needs to be writable by processes holding the AID_MEDIA_RW
GID permission; in particular, it should be writable by the FUSE daemon.

On devices with sdcardfs, this was ensured automatically, because
sdcardfs presented a view of this directory that was writable, that we
could use for the FUSE daemon. But on devices without sdcardfs, the FUSE
daemon sees the raw filesystem and its permissions. This also means that
files created by the FUSE daemon will have their uid/gid set to the uid
of the FUSE daemon; to ensure these files stay writable to other system
applications that have AID_MEDIA_RW, use a default ACL to make sure the
gid stays AID_MEDIA_RW.

In particular, this fixes an issue with app cloning, where we want the
FUSE daemon of user 0 to be able to access the files of the app clone
user, and vice versa.

Bug: 154057120
Test: inspect uid/gid of /data/media/0 and contents
Change-Id: I6dfae41f9cb6a8283978b2667b02708a000f07c0
2020-12-16 17:54:22 +01:00
rickywai
168893621b Merge "Check if storage app data and obb directories exist in vold" 2020-12-14 14:24:36 +00:00
Jeffrey Vander Stoep
23bfcbb6be Merge "OWNERS: add alan and jeff, alphabetize" 2020-12-10 13:59:45 +00:00