frameworks/base
Revision | 80b629288444d7841dd7a3e0daf46c263c818445 (tree) |
---|---|
Time | 2016-12-07 09:31:15 |
Author | Jeff Sharkey <jsharkey@andr...> |
Commiter | gitbuildkicker |
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)
@@ -135,7 +135,8 @@ public class ExternalStorageProvider extends DocumentsProvider { | ||
135 | 135 | final VolumeInfo privateVol = mStorageManager.findPrivateForEmulated(volume); |
136 | 136 | title = mStorageManager.getBestVolumeDescription(privateVol); |
137 | 137 | } |
138 | - } else if (volume.getType() == VolumeInfo.TYPE_PUBLIC) { | |
138 | + } else if (volume.getType() == VolumeInfo.TYPE_PUBLIC | |
139 | + && volume.getMountUserId() == userId) { | |
139 | 140 | rootId = volume.getFsUuid(); |
140 | 141 | title = mStorageManager.getBestVolumeDescription(volume); |
141 | 142 | } else { |
@@ -169,6 +169,11 @@ class MountService extends IMountService.Stub | ||
169 | 169 | } |
170 | 170 | |
171 | 171 | @Override |
172 | + public void onSwitchUser(int userHandle) { | |
173 | + mMountService.mCurrentUserId = userHandle; | |
174 | + } | |
175 | + | |
176 | + @Override | |
172 | 177 | public void onStartUser(int userHandle) { |
173 | 178 | mMountService.onStartUser(userHandle); |
174 | 179 | } |
@@ -307,6 +312,8 @@ class MountService extends IMountService.Stub | ||
307 | 312 | @GuardedBy("mLock") |
308 | 313 | private String mMoveTargetUuid; |
309 | 314 | |
315 | + private volatile int mCurrentUserId = UserHandle.USER_OWNER; | |
316 | + | |
310 | 317 | private VolumeInfo findVolumeByIdOrThrow(String id) { |
311 | 318 | synchronized (mLock) { |
312 | 319 | final VolumeInfo vol = mVolumes.get(id); |
@@ -1189,7 +1196,7 @@ class MountService extends IMountService.Stub | ||
1189 | 1196 | vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE; |
1190 | 1197 | } |
1191 | 1198 | |
1192 | - vol.mountUserId = UserHandle.USER_OWNER; | |
1199 | + vol.mountUserId = mCurrentUserId; | |
1193 | 1200 | mHandler.obtainMessage(H_VOLUME_MOUNT, vol).sendToTarget(); |
1194 | 1201 | |
1195 | 1202 | } else if (vol.type == VolumeInfo.TYPE_PRIVATE) { |