• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

frameworks/base


Commit MetaInfo

Revision80b629288444d7841dd7a3e0daf46c263c818445 (tree)
Time2016-12-07 09:31:15
AuthorJeff Sharkey <jsharkey@andr...>
Commitergitbuildkicker

Log Message

Public volumes belong to a single user.

When a public (vfat) device is inserted, it's strongly associated
with the current foreground user, and no other users should be able
to access it, since otherwise that would be a cross-user data leak.

To use the device under a different user, switch users and then
eject/remount the device.

Test: verified user isolation of USB drive
Bug: 32523490
Change-Id: I590c791996f1fea8d78f625dc942d149f1f41614
(cherry picked from commit 6b0079d3bc970d48e71cf9211d178e447f7f8a7c)

Change Summary

Incremental Difference

--- a/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java
+++ b/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java
@@ -135,7 +135,8 @@ public class ExternalStorageProvider extends DocumentsProvider {
135135 final VolumeInfo privateVol = mStorageManager.findPrivateForEmulated(volume);
136136 title = mStorageManager.getBestVolumeDescription(privateVol);
137137 }
138- } else if (volume.getType() == VolumeInfo.TYPE_PUBLIC) {
138+ } else if (volume.getType() == VolumeInfo.TYPE_PUBLIC
139+ && volume.getMountUserId() == userId) {
139140 rootId = volume.getFsUuid();
140141 title = mStorageManager.getBestVolumeDescription(volume);
141142 } else {
--- a/services/core/java/com/android/server/MountService.java
+++ b/services/core/java/com/android/server/MountService.java
@@ -169,6 +169,11 @@ class MountService extends IMountService.Stub
169169 }
170170
171171 @Override
172+ public void onSwitchUser(int userHandle) {
173+ mMountService.mCurrentUserId = userHandle;
174+ }
175+
176+ @Override
172177 public void onStartUser(int userHandle) {
173178 mMountService.onStartUser(userHandle);
174179 }
@@ -307,6 +312,8 @@ class MountService extends IMountService.Stub
307312 @GuardedBy("mLock")
308313 private String mMoveTargetUuid;
309314
315+ private volatile int mCurrentUserId = UserHandle.USER_OWNER;
316+
310317 private VolumeInfo findVolumeByIdOrThrow(String id) {
311318 synchronized (mLock) {
312319 final VolumeInfo vol = mVolumes.get(id);
@@ -1189,7 +1196,7 @@ class MountService extends IMountService.Stub
11891196 vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE;
11901197 }
11911198
1192- vol.mountUserId = UserHandle.USER_OWNER;
1199+ vol.mountUserId = mCurrentUserId;
11931200 mHandler.obtainMessage(H_VOLUME_MOUNT, vol).sendToTarget();
11941201
11951202 } else if (vol.type == VolumeInfo.TYPE_PRIVATE) {