Commit graph

253 commits

Author SHA1 Message Date
Sudheer Shanka
8f2ff80e87 Support "full" mode when updating bind mounts of a process.
Bug: 133829348
Test: manual
Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/ExternalStorageHostTest.java
Change-Id: I5f48ecbfe8cce243fa75a2e8447ce1d4676003ad
2019-05-30 16:40:20 -07:00
Sudheer Shanka
ebce4cc16b Remove storage sandboxes related code.
Bug: 131115422
Test: manual
Test: atest --test-mapping packages/providers/MediaProvider
Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/ExternalStorageHostTest.java
Test: atest DownloadProviderTests
Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java
Test: atest cts/tests/app/DownloadManagerLegacyTest/src/android/app/cts/DownloadManagerLegacyTest.java
Test: atest cts/tests/app/DownloadManagerApi28Test/src/android/app/cts/DownloadManagerApi28Test.java
Change-Id: Ib3272a47a901ed106474039e72f123b11f5443ff
Merged-In: Ib3272a47a901ed106474039e72f123b11f5443ff
2019-05-09 17:46:30 +00:00
Sudheer Shanka
36bdf7ab54 Update remountUidLegacy to handle "full" mount mode.
Bug: 130791955
Test: manual
Change-Id: I078c2922d1d5a8d16bbb213201a3cad7b1bf4b86
2019-04-18 15:18:30 -07:00
Sudheer Shanka
a05ea743f0 Allow sandboxed apps to access only package specific dirs.
Bug: 130427780
Test: manual
Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/ExternalStorageHostTest.java
Change-Id: I7afcea090306336c4033860084a2a436d2bb4740
2019-04-12 16:40:57 -07:00
Nick Kralevich
58e1a816ba VolumeManager: more O_CLOEXEC changes
Test: compiles and boots
Bug: 129350825
Change-Id: Ie6a0e05f1814d744eb16863f749c939ab1e097e0
2019-03-29 19:23:40 -07:00
Nick Kralevich
9bda3fe810 Merge "vold: cleanups for O_CLOEXEC tidy checks." am: a59868d6de am: 5af0c75525
am: 4197c098df

Change-Id: Ibe3636abcfafab7854c7b0434095b6e91fadcacf
2019-03-29 18:46:07 -07:00
Nick Kralevich
e7e89acbc8 vold: cleanups for O_CLOEXEC tidy checks.
Bug: 129350825
Test: compiles and boots
Change-Id: I83a484ca15df1b757b670008f15af5504bc94df1
2019-03-29 16:04:47 -07:00
Jiyong Park
4b64463572 Merge "Don't unmount /storage for early native processes" am: ee9554b2d9 am: b5acb5bfba
am: f1baff6ddd

Change-Id: I7107dd9d24dd07f9c17ea11d24db17db2cd10f12
2019-03-08 18:05:14 -08:00
Jiyong Park
8d21c924d7 Don't unmount /storage for early native processes
Motivation:

Early processes launched before the runtime APEX - that hosts the bionic
libs - is activated can't use the bionic libs from the APEX, but from the
system partition (which we call the bootstrap bionic). Other processes
after the APEX activation should use the bionic libs from the APEX.
In order to let both types of processes to access the bionic libs via
the same standard paths /system/lib/{libc|libdl|libm}.so, some mount
namespace magic is used.

To be specific, when the device boots, the init initially bind-mounts
the bootstrap bionic libs to the standard paths with MS_PRIVATE. Early
processes are then executed with their own mount namespaces (via
unshare(CLONE_NEWNS)). After the runtime APEX is activated, init
bind-mounts the bionic libs in the APEX to the same standard paths.
Processes launched thereafter use the bionic libs from the APEX (which
can be updated.)

Important thing is that, since the propagation type of the mount points
(the standard paths) is 'private', the new bind-mount events for the
updated bionic libs should not affect the early processes. Otherwise,
they would experience sudden change of bionic libs at runtime. However,
other mount/unmounts events outside of the private mount points are
still shared across early/late processes as before. This is made possible
because the propagation type of / is 'shared' .

Problem:

vold uses the equality of the mount namespace to filter-out processes
that share the global mount namespace (the namespace of the init). However,
due to the aforementioned change, the early processes are not filtered
out because they have different mount namespaces. As a result,
umount2("/storage/") is executed on them and this unmount event
becomes visible to the global mount namespace (because as mentioned before /
is 'shared').

Solution:

Fiter-out the early processes by skipping a native (non-Java) process
whose UID is < AID_APP. The former condition is because all early
processes are native ones; i.e., zygote is started after the runtime
APEX is activated. The latter condition is to not filter-out native
processes created locally by apps.

Bug: 120266448
Test: m; device boots

Change-Id: I054deedc4af8421854cf35be84e14995523a259a
2019-03-04 16:22:41 +09:00
Sudheer Shanka
23d725d85a Ignore packages whose sandboxes are already created.
Bug: 124788246
Test: manual
Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/ExternalStorageHostTest.java
Change-Id: Ie80bbdebc9d3d50e96d2cd17db804b7589b49055
2019-02-28 10:46:48 -08:00
Sudheer Shanka
8368040841 Look for visible vols for a user under /mnt/user/<userId>/package/.
Currently, we pass down visisble volumes for a user to zygote so that
it can set up appropriate bind mounts after forking. This method has
atleast a couple of race conditions, so instead make zygote just
look under /mnt/user/<userId>/package for volumes that need to be
handled for a particular user.

Bug: 126069494
Test: manual
Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/ExternalStorageHostTest.java
Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java
Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore*
Change-Id: If996cde24d9fc158729fcc8a8bdb17ca952a518e
2019-02-24 12:47:27 -08:00
Sudheer Shanka
30df1c61d9 Don't delete /mnt/user/<userId>/package on reset.
We need this to stay mounted at /storage.

Bug: 124466384
Test: manual
Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/ExternalStorageHostTest.java
Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore*
Change-Id: I0cc835471ced2822d83d7056bec53d62ddc682f0
2019-02-22 17:03:02 -08:00
Sudheer Shanka
727c5fad41 Avoid creating /mnt/user/<userId>/package/<packageName> for all pkgs.
Bug: 124466384
Test: manual
Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/ExternalStorageHostTest.java
Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java
Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore*
Change-Id: I678e199ef03805bb85a8a7ad9f1f7bae0a9fc56a
2019-02-21 15:12:42 -08:00
Sudheer Shanka
6d285cec24 Ignore EEXIST errors when creating pkg specific dirs.
Some of the pkg specific dirs could be created by zygote
and vold in parallel, so ignore any EEXIST errors while
creating these dirs.

Bug: 118185801
Test: manual

Change-Id: Ifaa9998131764304867ac027af335414dbfc291c
2019-02-19 14:46:15 -08:00
Sudheer Shanka
f9b38a58e1 Revert "Revert "Ensure necessary external storage dirs while creating sandboxes.""
This reverts commit 88114b2a56.

Reason for revert: blocking issue in b/124345887 is resolved

Change-Id: Ie34843c12b7a471d2384b64ad049ede63aed09e8
2019-02-14 19:11:20 +00:00
Jeff Sharkey
88114b2a56 Revert "Ensure necessary external storage dirs while creating sandboxes."
This reverts commit 083377e593.

Reason for revert: b/124345887

Change-Id: I388d45fab68b611917464a204269a48bf771ac57
2019-02-14 15:41:28 +00:00
Sudheer Shanka
083377e593 Ensure necessary external storage dirs while creating sandboxes.
Bug: 124058579
Test: manual
Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/ExternalStorageHostTest.java
Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java
Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore*

Change-Id: I0e62de38e9ceff80df75e253443af69d4391a49e
2019-02-13 18:16:50 -08:00
Jeff Sharkey
a6082500e4 Enable isolated storage by default.
We've been dogfooding the isolated storage feature for many months
on various internal groups, and we're ready to enable it globally.

Bug: 112545973
Test: executed entire CTS suite using forrest
Change-Id: I612b6aba4f08dc0ac13f4f94b03c4bddd6de12df
2019-02-11 13:14:37 -07:00
Sudheer Shanka
023b5391f9 Remove sandbox specific bind mounts from root namespace.
Update vold to only create package sandboxes and not do any bind mounts.
After zygote forks, all the necessary bind mounts will be setup for
the process.

Bug: 124009234
Test: manual
Test: atest cts/hostsidetests/appsecurity/src/android/appsecurity/cts/ExternalStorageHostTest.java
Test: atest DownloadProviderTests
Test: atest cts/tests/app/src/android/app/cts/DownloadManagerTest.java
Test: atest MediaProviderTests
Test: atest cts/tests/tests/provider/src/android/provider/cts/MediaStore*

Change-Id: Ia42209cb74cbc423bb09c1c51cb7a164f7c568da
2019-02-06 19:36:11 -08:00
Sudheer Shanka
5504901bf0 Create a new MOUNT_EXTERNAL_LEGACY storage mode.
Apps that are already installed on the device before isolated_storage
feature is enabled will be granted MOUNT_EXTERNAL_LEGACY mode. In this
mode, /mnt/runtime/write will be mounted at /storage giving them same
level of access as in P.

A new mount directory /mnt/runtime/full is also created which will be
used for mounting at /storage for apps started with MOUNT_EXTERNAL_FULL
mode. This will allow apps with WRITE_MEDIA_STORAGE permission to
read/write anywhere on the secondary devices without needing to bypass
sdcardfs.

Bug: 121277410
Test: manual
Test: atest android.appsecurity.cts.ExternalStorageHostTest
Change-Id: Icc1ff9da35545692daedef7173d7c89290dd2766
2019-01-18 18:48:55 -08:00
Jeff Sharkey
5ee228e3db Merge "Use "sys.isolated_storage_snapshot" prop to check for the feature." 2019-01-18 21:54:30 +00:00
Sudheer Shanka
34b437b301 Use "sys.isolated_storage_snapshot" prop to check for the feature.
StorageManager.hasIsolatedStorage() has already been updated to use
this, so most callers are already using this sys prop. Now, updating
remaining callers to use it as well.

Bug: 122559151
Test: manual
Change-Id: I6982a84b737a1d329f397b8182b7b7cdc5a8897f
2019-01-17 17:20:47 -08:00
Sudheer Shanka
6bf1480813 Update VolumeManager to use UnmountTreeWithPrefix.
Bug: 122905493
Test: manual
Change-Id: Ia6aa1d400277a76dfd2c1db87c613d7e692b0b5c
2019-01-17 15:18:10 -08:00
TreeHugger Robot
37fd66f19d Merge "vold: const-ify some of the API" 2018-12-20 21:19:55 +00:00
Sudheer Shanka
dfd8b64621 Merge "Update process mount points when appop gets updated." 2018-12-20 21:11:30 +00: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
Greg Kaiser
2bc201e6bb 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
2018-12-20 10:30:17 -08:00
Sudheer Shanka
ba0c62f752 Remove packageName from vold internal state.
std::remove will only move the matching items to the end, there
should be an erase call after that to actually get rid of those
items from the container.

Test: manual
Change-Id: I7d3b48f77fa5fab703fb10cf429d8c183322ed29
2018-12-16 18:35:53 -08:00
Sudheer Shanka
817b911ca4 Update process mount points when appop gets updated.
When an app is started, it's mountmode is dependent on
OP_REQUEST_INSTALL_PACKAGES. If user changes the appop grant of an app,
we need to update the mounts of any processes running in that app.

Bug: 121099965
Test: atest android.appsecurity.cts.ExternalStorageHostTest#testExternalStorageObbGifts
Change-Id: I87fee492891d33ccc9fc9e2548114f67d90cc759
2018-12-16 16:02:14 -08:00
Sudheer Shanka
03992e3741 Create a new mount mode for installer packages.
New external storage mount mode for installers so
that they can access obb dirs of all apps.

Bug: 111789719
Test: atest android.appsecurity.cts#testExternalStorageObbGifts
Change-Id: Iab112f0273806f8f812f14d6691bbe71dff42d83
2018-12-12 19:04:52 -08:00
Risan
1271b90560 Merge "Extract AppFuse as a util" am: 7be8a7ee1d am: d04a16cbd5
am: 9f7af4b6e3

Change-Id: I92a3fa8828e983df876d42637913737e2b31fd4f
2018-11-30 01:17:08 -08:00
Treehugger Robot
7be8a7ee1d Merge "Extract AppFuse as a util" 2018-11-30 05:05:10 +00:00
TreeHugger Robot
5c801225e4 Merge "Change AppFuse mount location to vold namespace" 2018-11-30 01:34:21 +00:00
LongPing.WEI
60f121b389 Merge "Use setmntent with "e" option" am: 396040ca2c am: a92bdeb7f5
am: 2255cf528f

Change-Id: Ibc84f3b9d2dc8ab0707b354d64529434355f36d6
2018-11-28 10:03:09 -08:00
Risan
8f6198d299 Change AppFuse mount location to vold namespace
Previously, AppFuse is mounted in system_server's mount namespace. This
CL moves the mount location to vold namespace.

Relanding this since it fails to be merged on ag/5521004 (blocked by
Presubmit, seems to be caused by temporary state) - this one now
passes presubmit without any changes.

Bug: 110379912
Test: testOpenProxyFileDescriptor passes
Change-Id: Id93c26d5a98842c78f27850c83e15df619cec1ab
2018-11-26 15:30:01 +00:00
LongPing.WEI
4f04606811 Use setmntent with "e" option
Otherwise it will cause selinux warning in children processes sometimes

Change-Id: I41239c3f9779140622076c644a5f63051d00eaa8
2018-11-23 19:27:35 +08:00
Risan
ac02a4863f Extract AppFuse as a util
Bug: 110379912
Test: testOpenProxyFileDescriptor
Change-Id: I0429a498d7b54682efe9b05815f3470e8745609e
2018-11-14 07:28:06 +00:00
Risan
5f53cd3b79 Change AppFuse mount location to vold namespace
Previously, AppFuse is mounted in system_server's mount namespace. This
CL moves the mount location to vold namespace.

Bug: 110379912
Test: testOpenProxyFileDescriptor passes
Change-Id: Id93c26d5a98842c78f27850c83e15df619cec1ab
2018-11-13 22:46:23 +00:00
Risan
4d8ba07231 Merge "StubVolume as first class Volume in Vold" am: dcbce84fed am: 14955896e5
am: a294e197b4

Change-Id: Iaec41c8ffe6feaa59163987c914fa21edc7ae2cd
2018-11-13 12:13:23 -08:00
Risan
8c9f33242f StubVolume as first class Volume in Vold
StubVolume is a Volume that is maintained by external party such as the
ChromeOS processes in ARC++.

Bug: 110380403
Test: Tested on ARC++

Change-Id: I3198bd7283d5f60a524da3707dea7385ffec599d
2018-11-08 07:40:43 +00:00
Eric Biggers
b288bf0f44 vold: rename from "ext4 encryption" to fscrypt am: a701c458ca am: 10b70834a4
am: a51283d281

Change-Id: I346bca3f23cfe84d77e5de1e8ef601fb7debf620
2018-10-29 10:41:02 -07:00
Eric Biggers
a701c458ca vold: rename from "ext4 encryption" to fscrypt
We support file-based encryption on both ext4 and f2fs now, and the
kernel API is the same.  So rename things appropriately in vold:

    e4crypt => fscrypt
    ext4enc => fscrypt
    Ext4Crypt => FsCrypt
    EXT4_* => FS_*
    ext4_encryption_key => fscrypt_key

Additionally, the common functions shared by 'vold' and 'init' are now
in libfscrypt rather than ext4_utils.  So update vold to link to
libfscrypt and include the renamed headers.

Note: there's a chance of 'fscrypt' being confused with the dm-crypt
based encryption code in vold which is called 'cryptfs'.  However,
fscrypt is the name used in the kernel for ext4/f2fs/ubifs encryption,
and it's preferable to use the same name in userspace.

Test: built, booted device with f2fs encryption
Change-Id: I2a46a49f30d9c0b73d6f6fe09e4a4904d4138ff6
2018-10-25 17:12:32 -07:00
Sudheer Shanka
69bc40f9a9 Update StorageManagerService handling of packages info.
Instead of maintaining local copy of all appIds and sandboxIds,
StorageManagerService will just get required packages info
from PackageManagerService when an user starts and passes it
to vold.

Bug: 117988901
Test: manual
Change-Id: Idab274529e843784c8804929e920c3af63032690
2018-10-25 11:58:43 -07:00
Sudheer Shanka
51a38dada7 Update shared sandbox directory structure.
Sandboxes for apps with sharedUserIds will live
at Android/shared:sharedUserId/ instead of
Android/shared/sharedUserId/.

Bug: 117573457
Test: manual
Change-Id: I7ab920814b501b9cdd4c58fefe81c53162b318f3
2018-10-20 21:00:13 -07:00
Sudheer Shanka
b792c3a210 Merge "Delete package sandbox data when it is uninstalled." 2018-10-10 21:00:04 +00:00
Sudheer Shanka
fa6a174a05 Delete package sandbox data when it is uninstalled.
Bug: 111890351
Test: manual
Change-Id: I989d507f3352959e824b161a94c0eaad6eed9bba
2018-10-09 11:12:52 -07:00
Sudheer Shanka
9acc6d4398 Check isolated_storage is enabled before cleaning up sandboxes.
Also, clear packages state stored for the user being stopped.

Bug: 117329171
Bug: 111890351
Test: manual
Change-Id: Ida48fcec851830dbb756e329c20c322c631ad264
2018-10-06 19:03:02 -07:00
Mark Salyzyn
c4405e9c17 Protect /mnt/scratch from stale umount on userdebug
On userdebug protect /mnt/scratch. On user builds ensure that
/mnt/scratch is considered a stale mount so it can not be used.
vold runs before ro.debuggable is set, so this must be a compile
time decision.

Minor technical debt cleanup associated with using android::base.

Test: compile
Bug: 109821005
Change-Id: I8efdbedfe850dd24daecf03a37aea61de47edc7d
Merged-In: I8efdbedfe850dd24daecf03a37aea61de47edc7d
2018-10-02 18:00:49 +00:00
Mark Salyzyn
86e81e7183 Protect /mnt/scratch from stale umount on userdebug
On userdebug protect /mnt/scratch. On user builds ensure that
/mnt/scratch is considered a stale mount so it can not be used.
vold runs before ro.debuggable is set, so this must be a compile
time decision.

Minor technical debt cleanup associated with using android::base.

Test: compile
Bug: 109821005
Change-Id: I8efdbedfe850dd24daecf03a37aea61de47edc7d
2018-10-01 10:49:23 -07:00
Sudheer Shanka
1fa13825fc Merge "Remove unmount_tree in VolumeManager." am: 9931db7e59 am: 96707825f2
am: 65eac7fc1a

Change-Id: I40174a2504b376ebce6962f23ce1e06b7d2c1666
2018-09-28 20:13:09 -07:00