Call fscrypt_destroy_volume_keys() under mCryptLock
Everything in FsCrypt.cpp seems to run under VolumeManager::mCryptLock,
except for fscrypt_destroy_volume_keys() which uses mLock instead.
This was sort of okay because fscrypt_destroy_volume_keys() didn't
operate on any in-memory data structures. However, that is going to be
changed. Therefore, rework VoldNativeService::forgetPartition() to call
fscrypt_destroy_volume_keys() under mCryptLock.
Test: see I7f11a135d8550618cd96013f834cebd54be5ef84
Change-Id: Ia27a61faf2fdd546cdbddb2a3985c7c6696f6aa6
Merged-In: Ia27a61faf2fdd546cdbddb2a3985c7c6696f6aa6
(cherry picked from commit ce86e24d233a26b68ae3655ebc3f5730322d78a4)
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index db356db..c981f2d 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -349,25 +349,19 @@
}
}
-int VolumeManager::forgetPartition(const std::string& partGuid, const std::string& fsUuid) {
+bool VolumeManager::forgetPartition(const std::string& partGuid, const std::string& fsUuid) {
std::string normalizedGuid;
if (android::vold::NormalizeHex(partGuid, normalizedGuid)) {
LOG(WARNING) << "Invalid GUID " << partGuid;
- return -1;
+ return false;
}
- bool success = true;
std::string keyPath = android::vold::BuildKeyPath(normalizedGuid);
if (unlink(keyPath.c_str()) != 0) {
LOG(ERROR) << "Failed to unlink " << keyPath;
- success = false;
+ return false;
}
- if (IsFbeEnabled()) {
- if (!fscrypt_destroy_volume_keys(fsUuid)) {
- success = false;
- }
- }
- return success ? 0 : -1;
+ return true;
}
void VolumeManager::destroyEmulatedVolumesForUser(userid_t userId) {