Test that plaintext can't be read from disk for encrypted files.
Bug: 36029169
Test: tested by hand on Taimen
Change-Id: I5717a8630bb2c8d8fe5c343d519c4e59862ecbdf
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 @@
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 @@
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 @@
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);