Commit graph

3405 commits

Author SHA1 Message Date
Martijn Coenen
8a68a075a2 Remove appDirRoot argument from setupAppDir.
This is no longer needed, because vold can deduce this itself now.

Bug: 146419093
Test: builds
Change-Id: Ib4f4a4109919af683722a63b305b343ef5fe972d
2020-02-12 15:38:45 +01:00
Martijn Coenen
fd9cdbf124 Set quota project ID and inheritance on top-level storage directory.
When creating external storage directories like /data/media/0, make sure
we set the quota project ID correctly, and enable project ID
inheritance. This ensures that all directories/files under this will be
created with the correct project ID and inheritance as well.

Bug: 146419093
Test: lsattr -p on /data/media
Change-Id: I32bfced0d67eb8c1865897b085324f00c55926a0
2020-02-12 13:18:46 +01:00
Martijn Coenen
879fa8015d Set default ACL on application-specific directories.
On devices without sdcardfs, application-specific directories have a
particular GID that ensure some privileged daemons (like installers) are
able to write to them. Android applications however run with a umask of 0077, which means that
any subdirectory they create within their app-specific directory has
mode 700, which in turn prevents things like DownloadManager from
working, since it can be asked to download into a subdir of the app's
private storage.

To prevent this from happening, set a default 770 ACL on the top-level
app-specific directory (eg, /data/media/0/Android/data/com.foo); the
effect of that default ACL is that all directories that are created
within these directories automatically get a 770 mask, regardless of the
umask that the process has.

Bug: 146419093
Test: atest FuseDaemonHostTest on cf_x86 (without sdcardfs)

Change-Id: I3178694e6d25ce3d04a0918ac66862f644635704
2020-02-12 13:18:44 +01:00
Martijn Coenen
04bb17f112 Use a regex to create application directories.
A regex allows us to be more specific in what kind of directories we
accept here, which in turn makes it easier to correctly create them.

Bug: 146419093
Test: atest FuseDaemonHostTest
Change-Id: Icb8911f6516eab81b9bbd567c7287be9f605e8b0
2020-02-11 14:22:30 +01:00
Automerger Merge Worker
3fcbdbff5f Merge "Use std::string to return crypto device, not char *" am: 80731b0975 am: 2381810b99 am: 1541f9f32b
Change-Id: I68cf7bfc6ce642d46d874bb44694109b1f43258e
2020-02-11 01:18:30 +00:00
Automerger Merge Worker
1541f9f32b Merge "Use std::string to return crypto device, not char *" am: 80731b0975 am: 2381810b99
Change-Id: Ic7683749f4974ccdf251b7351110a1e3663536b7
2020-02-11 01:03:00 +00:00
Automerger Merge Worker
2381810b99 Merge "Use std::string to return crypto device, not char *" am: 80731b0975
Change-Id: I4cdc6e59713a945f9fc7b6e9d8c765e78c44b9cb
2020-02-11 00:49:53 +00:00
Paul Crowley
80731b0975 Merge "Use std::string to return crypto device, not char *" 2020-02-11 00:37:26 +00:00
Martijn Coenen
1f40bea0bb Merge "Add TEST_MAPPING for vold." 2020-02-10 09:09:29 +00:00
Martijn Coenen
b77ad3a4cc Add TEST_MAPPING for vold.
Start with FuseDaemonHostTest and AdoptableHostTest, since these heavily
rely on functionality implemented in FUSE to work correctly.

Bug: 149095627
Test: run atest in system/vold
Change-Id: Ia583505aae260584897b0ea80c419b0e34f04735
2020-02-10 08:57:30 +01:00
Martijn Coenen
a0213ff0c3 Merge "Add SetQuotaInherit API." 2020-02-10 07:54:30 +00:00
Automerger Merge Worker
cc733959f6 Merge "Refactor: make cryptfs.h smaller" am: 98c501d28e am: 645c2f40a0 am: ebbabdc8fb
Change-Id: If8c533aa196969adf38dcbf85673cebb39a79024
2020-02-08 02:27:49 +00:00
Automerger Merge Worker
ebbabdc8fb Merge "Refactor: make cryptfs.h smaller" am: 98c501d28e am: 645c2f40a0
Change-Id: I5fb7f528186b6a678a02febd9e866ca4ae467dd4
2020-02-08 02:15:04 +00:00
Automerger Merge Worker
645c2f40a0 Merge "Refactor: make cryptfs.h smaller" am: 98c501d28e
Change-Id: I85d5bacfc08245397cb4f8aa71406bfeed961c19
2020-02-08 01:50:57 +00:00
Treehugger Robot
98c501d28e Merge "Refactor: make cryptfs.h smaller" 2020-02-08 01:34:29 +00:00
Paul Crowley
81796e9dce Use std::string to return crypto device, not char *
Bug: 147814592
Test: can create private volume on Cuttlefish
Change-Id: Ic2bca81c0f0319e1b988e9204a2f4e91af57d157
2020-02-07 11:27:49 -08:00
Paul Crowley
73be12dcd5 Refactor: make cryptfs.h smaller
Move most of it into cryptfs.cpp, and include cryptfs.h in fewer files.

Bug: 147814592
Test: Treehugger
Change-Id: Ia3592d73e7abc1f07a60538e0978a3033bdea7de
2020-02-07 11:16:12 -08:00
Zim
a13d81bbf5 Create Android/media dirs
I3a879089422c7fc449b6a3e6f1c4b386b86687a4 enforces some gids on the
Android/ dirs but left out Android/media. We now create it

Test: atest FuseDaemonHostTest#testListFilesFromExternalMediaDirectory
Bug: 149072341
Change-Id: I260c414906cd491a6bdd83522ff45f8663e15604
2020-02-07 17:42:47 +00:00
Martijn Coenen
5fe1b16330 Add SetQuotaInherit API.
This allows setting the "inherit project ID" flags on directories; in
our case, we want to set this on the root of the lower filesystem, eg
"/data/media/0".

Bug: 146419093
Test: manual invocation works
Change-Id: Ic74588fd972d464e7021bef953da0e5aaafc4286
2020-02-06 18:57:47 +01:00
Martijn Coenen
ba9868bd78 Set correct quota project ID on application directories.
Use PrepareAppDirsFromRoot() to setup the quota project ID on
application-specific directories correctly. App directories use
AID_EXT_GID_START + their application ID offset, whereas cache
directories use AID_CACHE_GID_START. This is consistent with the GIDs
sdcardfs used to label these directories with.

Bug: 146419093
Test: verified project IDs with lsattr -p
Change-Id: Idca8a30d185012efb0d19ceb9b346b9a4de34f18
2020-02-04 13:02:51 +01:00
Martijn Coenen
62a4b279ab Setup Android/, Android/data and Android/obb dirs correctly.
Normally sdcardfs takes care of setting up these directories on-demand,
for example when an app requests its private data directory to be
created. On devices without sdcardfs however, we ourselves need to make
sure to setup the UID/GID of these directories correctly.

Introduce a new PrepareAndroidDirs() function which sets the dirs up
correctly. On devices without sdcardfs, that means:

Path              UID         GID         mode
/Android          media_rw    media_rw     771
/Android/data     media_rw    ext_data_rw  771
/Android/obb      media_rw    ext_obb_rw   771

Bug: 146419093
Test: wipe Android/, reboot, with and without sdcardfs, verify
      contents

Change-Id: I3a879089422c7fc449b6a3e6f1c4b386b86687a4
2020-02-04 13:02:49 +01:00
TreeHugger Robot
bff86152e5 Merge "Harden /mnt/pass_through paths" 2020-02-03 08:13:47 +00:00
Automerger Merge Worker
7b40c8e2b2 Merge changes from topics "dm-default-key-v2", "metadata_cipher" am: f60e947438 am: 0560c27092 am: 5aac6ab55f
Change-Id: Ia65e525982d7f95416345c0004f79e7ecc7e026e
2020-02-01 16:40:35 +00:00
Automerger Merge Worker
5aac6ab55f Merge changes from topics "dm-default-key-v2", "metadata_cipher" am: f60e947438 am: 0560c27092
Change-Id: I0c34298e89be72caf597c964ceeb7f3396abe20b
2020-02-01 16:29:52 +00:00
Automerger Merge Worker
0560c27092 Merge changes from topics "dm-default-key-v2", "metadata_cipher" am: f60e947438
Change-Id: I3e27ed3481542e5e6fe0db2c872d745151e50765
2020-02-01 16:19:45 +00:00
Treehugger Robot
f60e947438 Merge changes from topics "dm-default-key-v2", "metadata_cipher"
* changes:
  Set metadata cipher in fstab
  Add support for v2 of dm-default-key
2020-02-01 16:12:30 +00:00
Automerger Merge Worker
98ffa995d3 Merge "Rename key_dir to metadata_key_dir and refactor" am: a7463139cd am: 8cf1eda025 am: 48c403b820
Change-Id: I4df8daf1210a31b4ae0e32ee8c04f8f7acdc827b
2020-01-31 22:25:04 +00:00
Automerger Merge Worker
48c403b820 Merge "Rename key_dir to metadata_key_dir and refactor" am: a7463139cd am: 8cf1eda025
Change-Id: I0933c434c9c63e15f8af648aa99250eea95aa3bd
2020-01-31 22:14:21 +00:00
Automerger Merge Worker
8cf1eda025 Merge "Rename key_dir to metadata_key_dir and refactor" am: a7463139cd
Change-Id: I14535278f6e2b0ffe6c322a2e9bd7e2ae608105f
2020-01-31 21:59:05 +00:00
Paul Crowley
a7463139cd Merge "Rename key_dir to metadata_key_dir and refactor" 2020-01-31 21:49:13 +00:00
Zim
26eec7049b Harden /mnt/pass_through paths
Even though /mnt/pass_through itself is 700 root root, the paths under
it are quite permissive. Now, change them from 755 to 710 root
media_rw since the FUSE daemon is the only one that should access it
and it has media_rw gid

Test: manual
Bug: 135341433
Change-Id: I743c014f2c0273c68a1cead7f4331b55a3abcb4e
2020-01-31 16:10:06 +00:00
Paul Crowley
84e84c5f33 Set metadata cipher in fstab
Bug: 147814592
Test: Cuttlefish can use adiantum
Change-Id: I6805ae4acff4dd1ff7cecff9153dbf29e0274165
2020-01-30 17:20:27 -08:00
Paul Crowley
92a14b6b16 Add support for v2 of dm-default-key
Version 2 of dm-default-key has an extra parameter and always sets the
DUN.

Bug: 147814592
Test: Cuttlefish boots with keydirectory flag
Test: Crosshatch formatted before this change boots after it
Change-Id: I59081e385324d2e34a5f252286a97938d6ffb79b
2020-01-30 17:20:27 -08:00
Paul Crowley
c9b92f0c17 Rename key_dir to metadata_key_dir and refactor
Bug: 147814592
Test: Crosshatch boots
Change-Id: I9fce0ea5da9c81c2e4e9cf97b75c1cba821adf9e
2020-01-30 16:02:37 -08:00
Zimuzo Ezeozue
262c5dfbce Merge "Allow media_rw access to /mnt/user" 2020-01-29 08:07:13 +00:00
Zim
4dd47090a5 Allow media_rw access to /mnt/user
This allows the FUSE daemon (with media_rw) explicitly use /mnt/user
paths for redaction.

Test: atest FuseDaemonHostTest#testVfsCacheConsistency
Change-Id: If5b5f5aa6a0ce7c8e2fd300ff6146b345b25cf04
2020-01-29 02:44:46 +00:00
Yurii Zubrytskyi
8777107734 Merge "Expose new IncFS interface through Vold" 2020-01-29 01:37:01 +00:00
Automerger Merge Worker
8c52523600 Merge "Refactor to use EncryptionPolicy everywhere we used to use raw_ref" am: fda79ddd82 am: 7c3b0af05e am: 23fdbc7937
Change-Id: I73aac44990227e35352c8fa40a4dc2265c68fb04
2020-01-29 01:01:50 +00:00
Automerger Merge Worker
23fdbc7937 Merge "Refactor to use EncryptionPolicy everywhere we used to use raw_ref" am: fda79ddd82 am: 7c3b0af05e
Change-Id: Id0b36a8bd1d7db487eb61823f27c5349581bf781
2020-01-29 00:39:55 +00:00
Paul Crowley
7c3b0af05e Merge "Refactor to use EncryptionPolicy everywhere we used to use raw_ref"
am: fda79ddd82

Change-Id: I0d1599b8a2baa141e1d08029f75e5e54f486cb14
2020-01-28 16:29:00 -08:00
Paul Crowley
fda79ddd82 Merge "Refactor to use EncryptionPolicy everywhere we used to use raw_ref" 2020-01-29 00:18:44 +00:00
Paul Crowley
77df7f207d Refactor to use EncryptionPolicy everywhere we used to use raw_ref
Test: Boots, no bad log messages: Cuttlefish with v2 policies, Taimen
Bug: 147733587
Change-Id: Ice4acac3236b6b7d90e60a2f57b46814aa1949f5
2020-01-28 11:17:58 -08:00
Zimuzo Ezeozue
ac95a2cc46 Merge "Allow external_storage or media_rw gid access /mnt/media_rw" 2020-01-28 11:04:35 +00:00
Martijn Coenen
db9eedad93 Merge "Automatically use correct lower paths for setupAppDir." 2020-01-28 09:15:22 +00:00
Yurii Zubrytskyi
3497cb5be5 Expose new IncFS interface through Vold
CL is a part of multi-repository topic and will be merged
to AOSP

Bug: 146080380
Test: manual

Change-Id: I09b33a34ff1ac7f6e415b7bd090c22e7df24d72d
2020-01-27 22:26:37 -08:00
Martijn Coenen
0a7e9925a6 Automatically use correct lower paths for setupAppDir.
When we're asked to create an app directory, find the corresponding
volume, and use the raw path of that volume to create the directory.
This ensures this will continue working on devices that don't have
sdcardfs.

Bug: 146419093
Test: manual test on cuttlefish
Change-Id: I91d735c1adbcca171e5af73aca0abd7ef396d0b7
2020-01-27 14:00:29 +01:00
Martijn Coenen
59d8a4f898 Merge "Add setProjectQuotaId to vold." 2020-01-27 08:57:52 +00:00
Zim
c9a2be4e3f Allow external_storage or media_rw gid access /mnt/media_rw
PublicVolumes are mounted on /mnt/media_rw/<volume>. Two categories of
apps need access to the mounts. Fortunately, they need access in
mutually exclusive scenarios.

1. The FUSE daemon needs access when serving content from app requests on
/storage/<volume>.

2. File managers (MANAGE_EXTERNAL_STORAGE permission) need access to
ureliable (USB OTG) volumes that are only available on the
/mnt/media_rw paths, i.e, they are not bind mounted into /storage
for apps.

Additionally, we want to ensure that file managers cannot access
/mnt/media_rw when there's a stacked FUSE volume on it. To do this,
we selectively change the mount gid of the /mnt/media_rw/<volume>
path:
-media_rw if it's a reliable volume, ie there's a stacked FUSE volume
-external_storage if it's an unreliable volume.

This ensures that file managers with their external_storage gid can
access unreliable volumes from /mnt/media_rw and cannot interfere with
the FUSE daemon when it's a reliable volume.

Test: adb shell sm set-force-adoptable [on|off] to set reliable or
unreliable volumes && mounting public volumes shows the correct
ACL on /mnt/media_rw/<volume>
Bug: 144914977

Change-Id: Iecf1a422d39e5137105b5a4946704858ce902a8a
2020-01-24 22:21:55 +00:00
Automerger Merge Worker
24362685f0 [automerger skipped] Merge "vold: Do not cache CE keys in vold" am: 432ca5af06 am: 8427b24fc5 am: d88fba70c7 -s ours
am skip reason: Change-Id I4cb1c035a472477e70c1ff5bf0b2c3fcfad495e5 with SHA-1 9ad51adeb9 is in history

Change-Id: Ifb41d27fa4006229a70cf95cd979f39a0646c84f
2020-01-24 17:45:07 +00:00
Automerger Merge Worker
d88fba70c7 Merge "vold: Do not cache CE keys in vold" am: 432ca5af06 am: 8427b24fc5
Change-Id: I52ee506f94ccab65fd3cc26a5fb0366e49e3d178
2020-01-24 17:30:14 +00:00