Commit graph

3346 commits

Author SHA1 Message Date
Eric Biggers
506342fb37 Clean up providing key via old API
- Use FSCRYPT_MAX_KEY_SIZE from <linux/fscrypt.h> instead of manually
  defining FS_AES_256_XTS_KEY_SIZE.  These have the same numeric value
  (64), but the former is supposed to be used, and AES-256-XTS isn't
  necessarily the encryption algorithm that is being used anyway.

- Use the new name FSCRYPT_KEY_DESCRIPTOR_SIZE instead of the old name
  FS_KEY_DESCRIPTOR_SIZE.  These have the same numeric value (8).

- Don't try to handle sizeof(fscrypt_key::raw) > FSCRYPT_MAX_KEY_SIZE,
  as this simply isn't the case.

- Set fscrypt_key::mode to 0 rather than FS_ENCRYPTION_MODE_AES_256_XTS.
  This field has always been ignored by the kernel, and AES-256-XTS
  isn't necessarily the encryption algorithm that is being used anyway.

- Initialize the fields of fscrypt_key in order.

This is a cleanup only.

Test: booted hikey with fileencryption=aes-256-xts and a kernel that
      doesn't support the new fscrypt ioctls.
Bug: none
Change-Id: Ie2a7e9240aa479dfab2765c11db8a7124d20c643
2019-12-17 13:48:25 -08:00
Automerger Merge Worker
82c87c5209 Merge "Use <linux/fscrypt.h> from Bionic" am: 1d3cd24c4e am: c1e5cbe182 am: feef5dc6d0
Change-Id: If95d848f36bc9dd1180812ba06ec6b486d9daafc
2019-12-17 18:07:00 +00:00
Automerger Merge Worker
feef5dc6d0 Merge "Use <linux/fscrypt.h> from Bionic" am: 1d3cd24c4e am: c1e5cbe182
Change-Id: Ie0142719a4b3836912aa4b41ce72f782e8c68f43
2019-12-17 17:50:04 +00:00
Eric Biggers
c1e5cbe182 Merge "Use <linux/fscrypt.h> from Bionic"
am: 1d3cd24c4e

Change-Id: Icf5a715146d6edd6740fcff0b45df9e817fac1ef
2019-12-17 09:39:37 -08:00
Eric Biggers
1d3cd24c4e Merge "Use <linux/fscrypt.h> from Bionic" 2019-12-17 17:35:03 +00:00
Martijn Coenen
1986bfda8d Vold mkdirs should use lower filesystem.
If vold's view of /storage is FUSE, it means that creation of
directories in Android/ will go through FUSE as well. The implementation
of fs_mkdirs() tries to opendir() individual parts of the entire path;
so for a path "/storage/emulated/0/Android", it will try to opendir()
"/storage", "/storage/emulated", etc.

By default, "/storage/emulated" is created with 711 permissions; while
vold itself is root, access to /storage/emulated is routed through
MediaProvider (because of FUSE), and MediaProvider doesn't run as root,
nor does it have the capabilities to bypass the ACL. This means that
fs_mkdirs() as it is will fail, because opendir("/storage/emulated")
will fail from MediaProvider.

To prevent this, route these accesses directly to the lower filesystem
(currently, sdcardfs), by renaming the paths.

Bug: 146189163
Test: atest AdoptableHostTest
Change-Id: Idbb41b9ffad9713f3b255c51bd4de16f4d090223
2019-12-17 14:43:26 +01:00
Eric Biggers
3e9c996ab0 Use <linux/fscrypt.h> from Bionic
aosp/1184798 has updated the kernel headers to 5.4, so we no longer need
the file fscrypt_uapi.h.  In KeyUtil.cpp we also now don't need
<linux/fs.h>, but rather just the more specific <linux/fscrypt.h>.

Test: build
Bug: None
Change-Id: I56d17826eb7c3b95c74ce0435a4feae7f3cc325e
2019-12-16 16:19:44 -08:00
Martijn Coenen
adecd0ae75 Use the default sdcardfs view for the Android/ bind-mount.
Now that StorageManager asks vold to create package directories again,
apps only need write access in their own app-private directory. Both
app-private and OBB dirs will be created by privileged daemons as
needed.

This means we can use the "default" sdcardfs view for the Android/
bind-mount again. This has the added benefit that it fixes shell, which
wasn't in the "everybody" group, and therefore suddenly couldn't enter
/sdcard/Android anymore.

Bug: 146189163
Test: atest AdoptableHostTest
Change-Id: I37ca3b19ea4d11ed866efa808f51be945a4dc080
2019-12-13 16:05:03 +01:00
Abhijeet Kaur
a70feb449e Merge "Replace "sys.fuse_snapshot" with "persist.sys.fuse"" 2019-12-13 14:03:29 +00:00
Abhijeet Kaur
01fa0e0d8d Replace "sys.fuse_snapshot" with "persist.sys.fuse"
With the newly added flag for Settings developer options, which is now
used to change the state of FUSE, PROP_FUSE now acts as the snapshot
feature flag for the current boot.

Bug: 145391093
Test: atest AdoptableHostTest
Change-Id: I22363b088e88c764294cbd61c6d94160c907fae3
2019-12-13 10:26:32 +00:00
Greg Kaiser
5298ccc2a7 Initialize mFuseMounted
We missed one of the constructors before.

Bug: 137890172
Test: TreeHugger
Change-Id: If2f8a15d5abdff6e3a457a76e9d54b2c58d80422
2019-12-12 05:41:46 -08:00
Automerger Merge Worker
0aeb0c388e Merge "Allow fscrypt_mount_metadata_encrypted to be called more than once" am: 69199c70ec am: c39c12d0c3 am: 4f2f5d03b1
Change-Id: Ic40fd05dd91509c1a53488d9758c9fa39a7e0b84
2019-12-11 19:30:34 +00:00
Automerger Merge Worker
4f2f5d03b1 Merge "Allow fscrypt_mount_metadata_encrypted to be called more than once" am: 69199c70ec am: c39c12d0c3
Change-Id: I075c96eff7910c7a68c295ecf5f887b9deb929c0
2019-12-11 19:09:42 +00:00
Nikita Ioffe
c39c12d0c3 Merge "Allow fscrypt_mount_metadata_encrypted to be called more than once"
am: 69199c70ec

Change-Id: I743a9bbcca76af3fc1701d315e7e053b7ebea57e
2019-12-11 10:47:20 -08:00
Nikita Ioffe
69199c70ec Merge "Allow fscrypt_mount_metadata_encrypted to be called more than once" 2019-12-11 18:40:21 +00:00
TreeHugger Robot
b4569d73ee Merge "Correctly initialize mFuseMounted." 2019-12-11 14:49:38 +00:00
Martijn Coenen
fd7362d2a8 Correctly initialize mFuseMounted.
Wasn't done before.

Bug: 137890172
Test: builds
Change-Id: I413505fae23031a2da71086cbfd85e0b1aec459c
2019-12-11 14:26:27 +00:00
Martijn Coenen
9b712e6188 Merge changes from topic "fuse_bindmount"
* changes:
  Use a regular set for started users.
  When unmounting, only kill user-specific paths.
  Bind mount Android/ directory in FUSE.
  Use sdcardfs for pass-through mounts.
2019-12-11 07:51:37 +00:00
Automerger Merge Worker
ed36dcd1a7 Merge "Clear the warm_reset flag after boot is successful" am: 3fc3d75eb0 am: 9e9e9143b0 am: 9586a3dd1b
Change-Id: I906a715f21297d87b8ecc55313690998f344b726
2019-12-10 18:58:41 +00:00
Tianjie Xu
9586a3dd1b Merge "Clear the warm_reset flag after boot is successful" am: 3fc3d75eb0
am: 9e9e9143b0

Change-Id: Ib1fe4e420b7d673cfbdb4b425ba8b9f97cbea2fc
2019-12-10 10:39:46 -08:00
Tianjie Xu
9e9e9143b0 Merge "Clear the warm_reset flag after boot is successful"
am: 3fc3d75eb0

Change-Id: I7da336fa51761f133c633a9ba9997c99772b1e9c
2019-12-10 10:37:48 -08:00
Tianjie Xu
3fc3d75eb0 Merge "Clear the warm_reset flag after boot is successful" 2019-12-10 18:28:26 +00:00
Martijn Coenen
745e0a9acb Use a regular set for started users.
We want started users to be an ordered set; eg user 0 should always go
first. This is because volumes for users other than 0 depend on user 0
coming up first, because the volume for user 0 is the one mounting
sdcardfs.

Bug: 13789012
Test: atest AdoptableHostTest
Change-Id: Ic9119f0a24bd261e5362019836ac240b90c681c0
2019-12-10 16:49:16 +01:00
Martijn Coenen
8f1e7f289f When unmounting, only kill user-specific paths.
The path for emulated volumes is set to /storage/emulated,
not /storage/emulated/<userid> . When unmounting, we only
want to kill process with a reference to /<userid>; this prevents
killing processed needlessly.

Bug: 137890172
Test: atest AdoptableHostTest
Change-Id: I70e36e87077e87db9b3c7e07dc0e481ba06c2c14
2019-12-10 16:49:16 +01:00
Martijn Coenen
5700261e5a Bind mount Android/ directory in FUSE.
For apps seeing the FUSE filesystem, we want to bind-mount the Android/
directory to the lower filesystem. The main reason for this is game
performance - Android/ contains both OBBs and app-private external data,
and both are heavily accessed during game startup. This is a pretty
straightforward bind-mount on top of /mnt/user.

Bug: 137890172
Test: Running the following:
df /storge/emulated/0 ==> /dev/fuse (FUSE)
df /storage/emulated/0/Android ==> /data/media (sdcardfs)
Test: atest AdoptableHostTest

Change-Id: Ic17a5751b5a94846ee565ff935644a078044ab06
2019-12-10 16:49:16 +01:00
Martijn Coenen
6f5802e160 Use sdcardfs for pass-through mounts.
The pass-through mount is used by MediaProvider to access external
storage. Previously, it was the raw filesystem (eg ext4/f2fs); the
problem with that is that the permissions on that filesystem don't allow
MediaProvider to access all the files it needs to - in particular
directories under Android/

To solve this problem, we can have the pass-through mount sit on top of
sdcardfs instead of the raw filesystem. This means we need to mount
sdcardfs even in case we're using FUSE, but we already needed to do this
anyway for other performance reasons.

Bug: 135341433
Test: atest AdoptableHostTest
Change-Id: I893d5e5076c5096d2d55212f643c9a857242e964
2019-12-10 16:49:16 +01:00
Oli Lan
9072cef152 Merge changes from topics "createapexdirs", "createapexrollbackdirs" am: 3e1c0478b9 am: 0ad91e40ea
am: f243a3b105

Change-Id: I29b4de125231880894571a003791f02c58ce1049
2019-12-10 05:09:30 -08:00
Oli Lan
0c871647ff Create DE_n and CE_n APEX data directories. am: 94457217cb am: e7216f643d
am: 3f26f52ede

Change-Id: I0ce19d096e41b7a3879a1c63a211fc62ee7b93e0
2019-12-10 05:09:26 -08:00
Oli Lan
f243a3b105 Merge changes from topics "createapexdirs", "createapexrollbackdirs" am: 3e1c0478b9
am: 0ad91e40ea

Change-Id: I63e3a68a9d197c89aa195409c9847d6334f1dd14
2019-12-10 05:07:29 -08:00
Oli Lan
3f26f52ede Create DE_n and CE_n APEX data directories. am: 94457217cb
am: e7216f643d

Change-Id: I2afb35d4744224f19e3dafb327ba26f3348e09a5
2019-12-10 05:07:26 -08:00
Oli Lan
0ad91e40ea Merge changes from topics "createapexdirs", "createapexrollbackdirs"
am: 3e1c0478b9

Change-Id: I8ec5a0d3d1519eec788604dbaa5e41b869b8d428
2019-12-10 05:04:20 -08:00
Oli Lan
e7216f643d Create DE_n and CE_n APEX data directories.
am: 94457217cb

Change-Id: I5e2a86ae85152b2ea36547783a86ccae654eb6ea
2019-12-10 05:04:17 -08:00
Oli Lan
3e1c0478b9 Merge changes from topics "createapexdirs", "createapexrollbackdirs"
* changes:
  Create directories for snapshots of DE_n and CE_n apex data.
  Create DE_n and CE_n APEX data directories.
2019-12-10 12:54:43 +00:00
Nikita Ioffe
f850e6e564 Allow fscrypt_mount_metadata_encrypted to be called more than once
In case of userspace reboot, this function will be called again to
remount userdata into checkpoint mode.

Test: adb shell setprop sys.init.userdata_remount.force_umount_f2fs 1
Test: adb shell /system/bin/vdc checkpoint startCheckpoint 1
Test: adb reboot userspace
Test: adb shell dumpsys activity
Bug: 135984674
Bug: 143970043
Change-Id: I300b1960a6c4e95b13c43d806c4f3a9e4a612ac4
2019-12-09 21:19:11 +00:00
Martijn Coenen
90d2652438 Merge "Get rid of confusing FUSE variables and comments." 2019-12-09 18:39:49 +00:00
Martijn Coenen
adcc845231 Get rid of confusing FUSE variables and comments.
Long before scoped storage, FUSE was used to create several views of the
filesystem; this was later replaced by sdcardfs, yet the code still
references FUSE in variables and log messages. Fix those up to avoid
confusion with the "new FUSE".

Bug: 135341433
Test: atest AdoptableHostTest
Change-Id: I2966c5f95d6f38df36a20cdfdd0b95b3051f3f1e
2019-12-09 16:52:15 +01:00
Songchun Fan
0583015a57 Merge "[incremental] use vold to mount/unmount IncrementalFileSystem" am: 6bdfb77d8b am: a0945f468a
am: 1119bc8531

Change-Id: I772667d5c43cdf1ff37b156db9f47b61820433c7
2019-12-06 01:16:26 -08:00
Songchun Fan
1119bc8531 Merge "[incremental] use vold to mount/unmount IncrementalFileSystem" am: 6bdfb77d8b
am: a0945f468a

Change-Id: I4244844cde78dc46cac88299fa1fd2e2eee9af26
2019-12-06 00:05:07 -08:00
Songchun Fan
a0945f468a Merge "[incremental] use vold to mount/unmount IncrementalFileSystem"
am: 6bdfb77d8b

Change-Id: Ic9abd7f6e502e9f051effa998e3fbd40746d57d7
2019-12-06 00:03:15 -08:00
Songchun Fan
6bdfb77d8b Merge "[incremental] use vold to mount/unmount IncrementalFileSystem" 2019-12-06 06:45:37 +00:00
Songchun Fan
ab55cecdc1 [incremental] use vold to mount/unmount IncrementalFileSystem
Let vold mount IncFs onto directories under data and open control files.

Test: builds
Change-Id: Ibd96aae254b4fefaf56c9d549c4672a987c46221
2019-12-04 14:01:22 -08:00
Automerger Merge Worker
72edc7fa35 Merge "Add '/system/bin/vdc volume reset' command" am: d21a8a495d am: 961806fdc9
Change-Id: Ib62cb7e0a63e9a3f182631f1ac3ee108607b95d1
2019-12-04 20:38:58 +00:00
Nikita Ioffe
961806fdc9 Merge "Add '/system/bin/vdc volume reset' command" am: d21a8a495d
am: 86bad28329

Change-Id: I589bc0973050eea50147f927cf2044949ca4d7e0
2019-12-04 12:18:28 -08:00
Nikita Ioffe
86bad28329 Merge "Add '/system/bin/vdc volume reset' command"
am: d21a8a495d

Change-Id: I21fde79cd170bdfcd8a32b8a85da56099a223e2d
2019-12-04 11:52:20 -08:00
Nikita Ioffe
d21a8a495d Merge "Add '/system/bin/vdc volume reset' command" 2019-12-04 19:22:50 +00:00
Martijn Coenen
10b122b4e9 Don't LOG() after fork() and before exec().
LOG() can hang, because another vold thread may have been holding
a libc lock at the time we forked. Simply moving the log line to
before the fork().

Bug: 135341433
Test: atest AdoptableHostTest
Change-Id: I6063eb33f35c835a226bc1e56de97ace426747ff
2019-12-04 15:50:29 +01:00
Oli Lan
ac003c4955 Create directories for snapshots of DE_n and CE_n apex data.
This creates apexrollback directories under /data/misc_[de|ce]/<user>
which will hold snapshots of DE_n and CE_n apex data directories
(i.e. it will hold backups of data from /data/misc_[de|ce]/<user>/apexdata
for particular apexes).

See go/apex-data-directories for details.

Bug: 141148175
Test: Built and flashed, checked directory was created.
Change-Id: I468060b20dee0c50033b5f014ce8716582d5e6bc
2019-12-04 10:29:50 +00:00
Nikita Ioffe
7596581e9f Add '/system/bin/vdc volume reset' command
It will be used during the userspace reboot to unmount all emulated
storages, which is a prerequisite to unmount+remount ext4 userdata into
checkpoint mode.

Test: adb shell /system/bin/vdc checkpoint startCheckpoint 1
Test: adb reboot userspace
Bug: 143970043
Bug: 135984674
Change-Id: I07491bc4be2f30debe21b764766c9def68548e16
2019-12-02 11:51:20 +00:00
TreeHugger Robot
7e170b919e Merge "VolumeManager: limit the scope of remountUid post fork." 2019-11-28 10:18:08 +00:00
TreeHugger Robot
8b4b452c80 Merge "Allow null IVoldMountCallback in Vold#mount" 2019-11-27 19:22:29 +00:00