diff options
| author | Jeff Sharkey <jsharkey@android.com> | 2017-06-15 09:59:43 -0600 |
|---|---|---|
| committer | Paul Crowley <paulcrowley@google.com> | 2017-10-27 15:14:56 -0700 |
| commit | 2048a2865cfa1f8c794b94eb044854f130943f9c (patch) | |
| tree | e2e1352ee2c8e34eb2d6cbc9bf2a8d5ac5e1329b /VoldNativeService.cpp | |
| parent | 2d64b91823ee820204330d7f9daa4d79c41c436c (diff) | |
Test that plaintext can't be read from disk for encrypted files.
Bug: 36029169
Test: tested by hand on Taimen
Change-Id: I5717a8630bb2c8d8fe5c343d519c4e59862ecbdf
Diffstat (limited to 'VoldNativeService.cpp')
| -rw-r--r-- | VoldNativeService.cpp | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/VoldNativeService.cpp b/VoldNativeService.cpp index 0053478..d7a6576 100644 --- a/VoldNativeService.cpp +++ b/VoldNativeService.cpp @@ -17,11 +17,12 @@ #define ATRACE_TAG ATRACE_TAG_PACKAGE_MANAGER #include "VoldNativeService.h" -#include "VolumeManager.h" #include "Benchmark.h" +#include "CheckEncryption.h" +#include "IdleMaint.h" #include "MoveStorage.h" #include "Process.h" -#include "IdleMaint.h" +#include "VolumeManager.h" #include "cryptfs.h" #include "Ext4Crypt.h" @@ -357,15 +358,9 @@ binder::Status VoldNativeService::format(const std::string& volId, const std::st return translate(vol->format(fsType)); } -binder::Status VoldNativeService::benchmark(const std::string& volId, - const android::sp<android::os::IVoldTaskListener>& listener) { - ENFORCE_UID(AID_SYSTEM); - CHECK_ARGUMENT_ID(volId); - ACQUIRE_LOCK; - - std::string path; +static binder::Status pathForVolId(const std::string& volId, std::string* path) { if (volId == "private" || volId == "null") { - path = "/data"; + *path = "/data"; } else { auto vol = VolumeManager::Instance()->findVolume(volId); if (vol == nullptr) { @@ -377,12 +372,23 @@ binder::Status VoldNativeService::benchmark(const std::string& volId, if (vol->getState() != VolumeBase::State::kMounted) { return error("Volume " + volId + " not mounted"); } - path = vol->getPath(); + *path = vol->getPath(); + if (path->empty()) { + return error("Volume " + volId + " missing path"); + } } + return ok(); +} - if (path.empty()) { - return error("Volume " + volId + " missing path"); - } +binder::Status VoldNativeService::benchmark( + const std::string& volId, const android::sp<android::os::IVoldTaskListener>& listener) { + ENFORCE_UID(AID_SYSTEM); + CHECK_ARGUMENT_ID(volId); + ACQUIRE_LOCK; + + std::string path; + auto status = pathForVolId(volId, &path); + if (!status.isOk()) return status; std::thread([=]() { android::vold::Benchmark(path, listener); @@ -390,6 +396,17 @@ binder::Status VoldNativeService::benchmark(const std::string& volId, return ok(); } +binder::Status VoldNativeService::checkEncryption(const std::string& volId) { + ENFORCE_UID(AID_SYSTEM); + CHECK_ARGUMENT_ID(volId); + ACQUIRE_LOCK; + + std::string path; + auto status = pathForVolId(volId, &path); + if (!status.isOk()) return status; + return translate(android::vold::CheckEncryption(path)); +} + binder::Status VoldNativeService::moveStorage(const std::string& fromVolId, const std::string& toVolId, const android::sp<android::os::IVoldTaskListener>& listener) { ENFORCE_UID(AID_SYSTEM); |
