Commit graph

3346 commits

Author SHA1 Message Date
Automerger Merge Worker
cc64e0c9af Merge "Fixed a wrong AIDL import path" am: aa038e2f4d am: b35ead2c3a am: 3c78c789d6
Change-Id: Ifccc45bfaf67cc31f12902f56bcc50da238f8901
2020-01-23 03:53:23 +00:00
Automerger Merge Worker
3c78c789d6 Merge "Fixed a wrong AIDL import path" am: aa038e2f4d am: b35ead2c3a
Change-Id: Ib43192a85298925ad4b7220a79930c2baaac5361
2020-01-23 03:41:43 +00:00
Jiyong Park
b35ead2c3a Merge "Fixed a wrong AIDL import path"
am: aa038e2f4d

Change-Id: I8f3bf6b512ac1a0509ceb17cfa35efd0af6581b8
2020-01-22 19:27:04 -08:00
Treehugger Robot
aa038e2f4d Merge "Fixed a wrong AIDL import path" 2020-01-23 00:57:58 +00:00
Zimuzo Ezeozue
7ca3481d92 Merge "Harden /mnt/{user,installer} permission bits" 2020-01-22 20:03:25 +00:00
Zim
1242be866c Harden /mnt/{user,installer} permission bits
These paths previously had 0755 permission bits
(/mnt/installer got its bits from the /mnt/user bind mount).
With such permissive bits, an unauthorized app can access a file using
the /mnt/installer path for instance even if access via /storage
would have been restricted.

In init.rc we create /mnt/user with 0755 initially, this is to keep
/sdcard working without FUSE. When mounting a FUSE filesystem, we
enusure in vold that /mnt/user is changed to 0700

Bug: 135341433
Test: adb shell ls -d /mnt/{user, installer}
Change-Id: Id387e34c5fd257858861246ad51486892653fb3a
2020-01-22 18:28:37 +00:00
Shawn Willden
ae8f06fe1c Update vold to use KM4.1
This CL updates vold to use the Keymaster 4.1 interface, but does not
yet call any of the new methods.

Test: Boot the device
Change-Id: I4574a2f6eead3b71d1e89488b496b734694620c7
2020-01-21 06:58:19 -07:00
Jiyong Park
50c3ab6ac1 Fixed a wrong AIDL import path
AIDL import path should point to a root directory where relative path to
an AIDL file encodes the fully qualified name of the type in the file.

Since libvold_binder imports types like
android.os.incremental.IncrementalFileSystemControlParcel which are
under frameworks/base/core/java, the import path should set to the path,
not to the sub directory that directly has the AIDL files.

Bug: 147918827
Test: m
Change-Id: Ic4941578813eced5a7eb59a0656c10b76e902515
2020-01-20 12:37:52 +09:00
Paul Crowley
e3d2051668 Merge "vold: Do not cache CE keys in vold" 2020-01-19 21:58:02 +00:00
Automerger Merge Worker
b47c53d83b Merge changes I1bbf480c,Icf2059cc am: 701a99834f am: 16f46cd3d5 am: 17a1295297
Change-Id: I4f0e5b0b7f95a00bf222f31597e1d3c7c5c016c1
2020-01-17 18:04:27 +00:00
Automerger Merge Worker
17a1295297 Merge changes I1bbf480c,Icf2059cc am: 701a99834f am: 16f46cd3d5
Change-Id: I3bd7beaa23e058b1d22ba86debd82fe727f4a92e
2020-01-17 17:53:48 +00:00
Automerger Merge Worker
16f46cd3d5 Merge changes I1bbf480c,Icf2059cc am: 701a99834f
Change-Id: I958b327f69f52cebf0e54e99b3c174ae30bce455
2020-01-17 17:40:39 +00:00
Oli Lan
701a99834f Merge changes I1bbf480c,Icf2059cc
* changes:
  Allow search permission on apex data directories.
  Change ownership of apex data directories to root.
2020-01-17 17:20:36 +00:00
Oli Lan
e1b3f5cd2d Allow search permission on apex data directories.
This gives x permission to all on the parent apex data directory
so that the data directories can be accessed by modules.

Bug: 147848983
Test: Build & flash, check permissions are correct
Change-Id: I1bbf480cbf9f9e758353237e333317516ad375ee
2020-01-17 11:37:31 +00:00
Oli Lan
9cfc404c2d Change ownership of apex data directories to root.
The apex data directories must be accessed by apexd in order for it to
perform snapshot and restore as part of the rollback process. As apexd
runs as root, this CL changes the apex data directories under misc_[ce|de]
to be owned by root.

Bug: 141148175
Test: Build and flash; check permissions are set correctly.
Change-Id: Icf2059cc9448364f834eef7892914a99883746a1
2020-01-17 11:11:06 +00:00
Zim
53d16d39dd Always symlink self/primary to /storage/emulated
This allows readlink(2) of /sdcard paths to work correctly
and return /storage/emulated/<userid> instead of
/mnt/user/<userid>/emulated/<userid>

Test: readlink /sdcard -> /storage/emulated/0
Bug: 135341433
Change-Id: I2cfa9cede02a93024e41d90f17c926a69ec6e052
2020-01-17 01:37:08 +00:00
Zimuzo Ezeozue
d0c7c52edc Merge "Handle failures after partial mounts" 2020-01-16 22:27:27 +00:00
Barani Muthukumaran
9ad51adeb9 vold: Do not cache CE keys in vold
CE keys were cached in vold to support untrusted reset
by a device admin, this is now supported by Locksettingservice
using synthetic password. This change requires a secret to be
provided to retrieve the CE key and re-wrap without the secret
when user removes the credential.

Test: Set credential, remove credential, swipe to none
and vice-versa.
Bug: 26948053
Change-Id: I4cb1c035a472477e70c1ff5bf0b2c3fcfad495e5
2020-01-16 12:16:25 -08:00
Automerger Merge Worker
100e15e8e2 [automerger skipped] DO NOT MERGE - Empty merge qt-qpr1-dev-plus-aosp-without-vendor (6129114) into stage-aosp-master am: 1119e4b809 am: 0925b02603 -s ours
am skip reason: subject contains skip directive

Change-Id: I751e639c592a780131d5e783355b3e23b5c3eac6
2020-01-16 01:58:32 +00:00
Automerger Merge Worker
0925b02603 DO NOT MERGE - Empty merge qt-qpr1-dev-plus-aosp-without-vendor (6129114) into stage-aosp-master am: 1119e4b809
Change-Id: Ib3631a92cc1b913d1ff6a80ae70e6eff6da8c067
2020-01-16 01:46:00 +00:00
Xin Li
1119e4b809 DO NOT MERGE - Empty merge qt-qpr1-dev-plus-aosp-without-vendor (6129114) into stage-aosp-master
Bug: 146167222
Change-Id: Ia5363ad8550ac868591e4e7cd49ee62670d3caef
2020-01-15 15:59:18 -08:00
Zim
df073f50d2 Handle failures after partial mounts
When we try mounting an EmulatedVolume, we may mount sdcardfs but fail
in any of the FUSE mounts, in this case we should unmount whatever
mounts we made during the mount.

Test: Intentionally causing a partial failure, verified that sdcardfs
gets unmounted
Bug: 147610762

Change-Id: I29ed044ed8ab8aa3dd83bc97a49eb3140ce4fe27
2020-01-15 16:10:54 +00:00
Automerger Merge Worker
636123c523 Merge "Fix the overflow issue in Checkpoint" am: 6492a6abf6 am: e4c34d9cc3 am: c8425b0e8c
Change-Id: Idb11dfdd37c5813da6676894c35acb1503199553
2020-01-14 21:30:21 +00:00
Automerger Merge Worker
c8425b0e8c Merge "Fix the overflow issue in Checkpoint" am: 6492a6abf6 am: e4c34d9cc3
Change-Id: I82dece7b2fe00a31810120d63902048b2ffa6e8d
2020-01-14 21:14:50 +00:00
Qilin Tan
e4c34d9cc3 Merge "Fix the overflow issue in Checkpoint"
am: 6492a6abf6

Change-Id: I8991fd3bbe742fb87bc26bb6831280a73a2d5afb
2020-01-14 13:03:10 -08:00
Treehugger Robot
6492a6abf6 Merge "Fix the overflow issue in Checkpoint" 2020-01-14 20:47:23 +00:00
Martijn Coenen
3a2dbfee88 Bind mount write view of Android/obb for installers.
Installers will be allowed to write OBB for any application; this is not
easy to achieve on sdcardfs, where the GID of Android/obb is the same as
the GID of Android/data (app-private data), meaning giving installers
write access to Android/obb would also give them write access to
Android/data.

Instead, we create a /mnt/installer view, which is exactly the same as
/mnt/user, with the sole exception that the write sdcardfs view of
Android/obb is mounted on top. This is what will allow installers to
write there, while still being restricted with respect to app-private
data in Android/data.

Bug: 134706060
Test: atest AdoptableHostTest
Change-Id: If2b93870a877efef182bdc06466552a7527499ad
2020-01-11 19:50:25 +01:00
Martijn Coenen
b0e977a0b1 vold: Don't unmount /mnt/installer on start.
This is a slave bind mount of /mnt/user, created before we create the
two mount namespaces. Unmounting it here prevents us from re-creating it
in the right way, so leave it alone.

Bug: 134706060
Test: verify mount is still there after vold starts
Change-Id: Iaac91953cbb9abfef0aaac60f74b99b16c943f87
2020-01-11 19:24:26 +01:00
Martijn Coenen
60ddb198b7 Merge "Add REMOUNT_MODE_ANDROID_WRITABLE." 2020-01-09 07:38:24 +00:00
Martijn Coenen
b52eb85297 Add REMOUNT_MODE_ANDROID_WRITABLE.
Constant to indicate a regular scoped storage view, with the sole
exception that Android/ should be writable.

Bug: 134706060
Bug: 146490513
Test: builds
Change-Id: Ifbcd4fd912ed4cc18d7c6e3eab2c582bc862e10c
2020-01-08 15:04:21 +01:00
Zim
aea1247706 Add self/primary symlink on /mnt/pass_through
We bind mount /mnt/user/<userid> onto /storage for normal apps and
/mnt/pass_through/<userid> for special apps like the FUSE daemon or
the old android.process.media hosting the DownloadManager. This bind
mount allows app have /storage/self/primary which is what /sdcard
symlinks to.

Before this change, we were not creating the self/primary symlink on
/mnt/pass_through/<userid> so trying to access /sdcard from the
DownloadManager would fail.

Bug: 135341433
Test: atest android.app.cts.DownloadManagerTest#testAddCompletedDownload_invalidPaths
Change-Id: I660139be3d850e6e9ea4705f86ef2b5872ddca16
2020-01-08 11:09:47 +00:00
Martijn Coenen
8f391ad110 Merge changes I2c1d4b42,I06fe4d33
* changes:
  Conditionally use sdcardfs.
  Also delay creating found disks until user 0 is started.
2020-01-07 10:28:14 +00:00
Zimuzo Ezeozue
a064500bf3 Merge "Convert paths to lower filesystem paths during setupAppDir" 2020-01-07 08:09:52 +00:00
Martijn Coenen
86f21a2211 Conditionally use sdcardfs.
In preparation of sdcardfs going away on devices launching with R,
conditionally use it.

Bug: 146419093
Test: cuttlefish with sdcardfs, cuttlefish without sdcardfs but with
FUSE
Change-Id: I2c1d4b428dcb43c3fd274dde84d5088984161993
2020-01-07 09:03:35 +01:00
Zim
c59d774149 Convert paths to lower filesystem paths during setupAppDir
Making FUSE request from vold is risky because the FUSE daemon may be
down and vold could get wedged.

Additionally, the FUSE daemon only responds to requests with matching
user id paths, i.e requests on /mnt/user/0/emulated/10 will fail.
So if vold (running as user 0) makes a request on
/storage/emulated/10, it really means /mnt/user/0/emulated/10
which will fail if it gets to the FUSE daemon.

TODO: Fix the lower filesystem paths to support devices without
sdcardfs

Bug: 141540368
Change-Id: I90d698f6aecd114d75b6d578ad08620988da7d7d
atest: atest android.appsecurity.cts.ExternalStorageHostTest#testMediaSandboxedFull
2020-01-06 21:55:13 +00:00
Zim
06b0cafb29 Fix /mnt/user/<userid> permission bits
Previously, when mounting a FUSE volume, the permission bits for
/mnt/user/<userid> were very strict, 700 which was good, however this
value was ignored because it was overriden in zygote to 755. In fact
if it wasn't ignored, apps wouldn't have had access to /sdcard becase
they would lack the directory 'execute' bit for /mnt/user/<userid>
needed while looking up /mnt/user/<userid>/emulated

Now we set it to a strict enough value, 710 that only allows apps
running under the same user id to lookup /mnt/user/<userid>.
This ensures that user 10 cannot access /mnt/user/0.

A special case is added for /mnt/user/0 for shell since it is not in
the 'everybody' group and would otherwise not be able to 'adb shell ls
/sdcard'

Bug: 135341433
Test: atest -c android.appsecurity.cts.ExternalStorageHostTest#testSecondaryUsersInaccessible

Change-Id: Ia427d1b69c7140254ae3459b98e51531d8322f1a
2020-01-06 12:51:18 +00:00
Martijn Coenen
e3102990ca Merge "Replace mkdirs() with setupAppDir()." 2020-01-06 09:04:13 +00:00
Martijn Coenen
cf5916f3fa Also delay creating found disks until user 0 is started.
Public and private volumes can be discovered before user 0 is up and
running; when using FUSE however, we can't mount these disks yet,
because we depend on the user to become unlocked before we can start the
FUSE daemon (which is the MediaProvider application process). So besides
waiting for any secure keyguard to be dismissed, also wait for user 0 to
be started.

Bug: 146419093
Test: Boot cuttlefish with a fake public volume; is available after
repeated boots.

Change-Id: I06fe4d336d1baec3a49886c3cf12d844a1d0eb26
2020-01-03 16:32:20 +01:00
Qilin Tan
5d0aaaf8e0 Fix the overflow issue in Checkpoint
When the partition is f2fs and the OS is 32bit, the data.f_bavail and
data.f_frsize are 32 bits in size. The product of them is also 32 bits
in size. If the available size of storage is greater than 4G, the
product may be greater than the unsigned long max value. If the product
is overflow and less than 100M. The UDC feature will be disabled.

There is also an overflow for std::strtoul when the variable content
is a very big number(more the unsigned long max value).

To avoid the overflow:
1. convert the variable data.f_bavvail to uint64_t and then compute the
multiplication.
2. use std::strtoull replace to std::strtoul.

Bug: 147118861
Change-Id: I60172ae4cb7c997e2ad4a36583be74736c25e565
2020-01-03 08:12:03 +00:00
Martijn Coenen
13ff668775 Replace mkdirs() with setupAppDir().
vold historically offerred functionality to create directories on behalf
of others. This functionality was purely used to create app-specific
data/obb/media dirs. Make this more explicit by renaming the method to
indicate this.

Additionally, in the past, we never needed to care about the UID set on
these directories, because sdcardfs would take care of that for us
automatically. But with sdcardfs going away, we need to make sure the
UID of the app-specific directories is set correctly. Allow the caller
to pass this in as an argument.

Bug: 146419093
Test: atest FuseDaemonHostTest
Change-Id: Ibeb5fdc91b40d53583bc0960ee11c4d640549c34
2019-12-31 15:58:41 +01:00
Automerger Merge Worker
6a9bd24233 Merge "Consistently use CLOCK_MONOTONIC for timing encryption" am: f9510e3262 am: 395c47e046 am: 61f5d1e399
Change-Id: Ie78c05e0857b980215c237520d4e8f04e376e74e
2019-12-27 02:37:50 +00:00
Automerger Merge Worker
61f5d1e399 Merge "Consistently use CLOCK_MONOTONIC for timing encryption" am: f9510e3262 am: 395c47e046
Change-Id: I5aa535a2dc31bce130c1e48c8a3cf9bdc1a8b238
2019-12-27 02:21:36 +00:00
Denis Hsu
395c47e046 Merge "Consistently use CLOCK_MONOTONIC for timing encryption"
am: f9510e3262

Change-Id: I6eb165b5e9214eb614434ecfa654cfcd22327af1
2019-12-26 18:03:33 -08:00
Treehugger Robot
f9510e3262 Merge "Consistently use CLOCK_MONOTONIC for timing encryption" 2019-12-27 01:51:56 +00:00
Denis Hsu
1740effeaa Consistently use CLOCK_MONOTONIC for timing encryption
time_started in encryptGroupsData is set from and compared to
clock_gettime(CLOCK_MONOTONIC, ...) nearly everywhere: "Clock that
cannot be set and represents monotonic time since some unspecified
starting point". However in cryptfs_enable_inplace_f2fs() it is set
from a different clock, time(NULL), with the result that the setprop
calls that indicate progress are wrong and can be called much too
often. The fix is to make this function consistent with
cryptfs_enable_inplace_ext4.

Bug: 146877356
Change-Id: I2707180e5c5bf723a5a880f6a3aac47f2bb34ccd
2019-12-26 18:53:53 +00:00
Automerger Merge Worker
da4d63eaff Merge "Clean up providing key via old API" am: 180b1a7f89 am: fe823efdae am: 270e041a14
Change-Id: I94cb7467ccd56711a4442fb6f1b795b8bf6bc284
2019-12-18 20:59:24 +00:00
Automerger Merge Worker
270e041a14 Merge "Clean up providing key via old API" am: 180b1a7f89 am: fe823efdae
Change-Id: Ic130119f9887dcb0d8459770aed2253bcbf909c1
2019-12-18 20:13:43 +00:00
Eric Biggers
fe823efdae Merge "Clean up providing key via old API"
am: 180b1a7f89

Change-Id: Icc84ee275ce240fc65eb872d44ffc856e8cc8dd0
2019-12-18 11:57:42 -08:00
Eric Biggers
180b1a7f89 Merge "Clean up providing key via old API" 2019-12-18 19:13:28 +00:00
Martijn Coenen
5e289ee859 Merge changes from topic "fuse_fix_shell"
* changes:
  Vold mkdirs should use lower filesystem.
  Use the default sdcardfs view for the Android/ bind-mount.
2019-12-18 07:58:53 +00:00