Merge sc-dev-plus-aosp-without-vendor@7634622

Merged-In: I78039d08a9bc7d9a2d285744e6d64f4af6ac851a
Change-Id: I958ef629f8ca43d6539ae90e037b846d9e0b44a3
This commit is contained in:
Xin Li 2021-08-14 06:31:09 +00:00
commit b9d97763d2
5 changed files with 29 additions and 9 deletions

View file

@ -383,7 +383,9 @@ static bool encryptWithKeystoreKey(Keystore& keystore, const std::string& dir,
const km::AuthorizationSet& keyParams, const KeyBuffer& message, const km::AuthorizationSet& keyParams, const KeyBuffer& message,
std::string* ciphertext) { std::string* ciphertext) {
km::AuthorizationSet opParams = km::AuthorizationSet opParams =
km::AuthorizationSetBuilder().Authorization(km::TAG_PURPOSE, km::KeyPurpose::ENCRYPT); km::AuthorizationSetBuilder()
.Authorization(km::TAG_ROLLBACK_RESISTANCE)
.Authorization(km::TAG_PURPOSE, km::KeyPurpose::ENCRYPT);
km::AuthorizationSet outParams; km::AuthorizationSet outParams;
auto opHandle = BeginKeystoreOp(keystore, dir, keyParams, opParams, &outParams); auto opHandle = BeginKeystoreOp(keystore, dir, keyParams, opParams, &outParams);
if (!opHandle) return false; if (!opHandle) return false;
@ -412,6 +414,7 @@ static bool decryptWithKeystoreKey(Keystore& keystore, const std::string& dir,
auto bodyAndMac = ciphertext.substr(GCM_NONCE_BYTES); auto bodyAndMac = ciphertext.substr(GCM_NONCE_BYTES);
auto opParams = km::AuthorizationSetBuilder() auto opParams = km::AuthorizationSetBuilder()
.Authorization(km::TAG_NONCE, nonce) .Authorization(km::TAG_NONCE, nonce)
.Authorization(km::TAG_ROLLBACK_RESISTANCE)
.Authorization(km::TAG_PURPOSE, km::KeyPurpose::DECRYPT); .Authorization(km::TAG_PURPOSE, km::KeyPurpose::DECRYPT);
auto opHandle = BeginKeystoreOp(keystore, dir, keyParams, opParams, nullptr); auto opHandle = BeginKeystoreOp(keystore, dir, keyParams, opParams, nullptr);
if (!opHandle) return false; if (!opHandle) return false;

View file

@ -1,8 +1,14 @@
{ {
"presubmit": [ "presubmit": [
{
"name": "CtsScopedStorageCoreHostTest"
},
{ {
"name": "CtsScopedStorageHostTest" "name": "CtsScopedStorageHostTest"
}, },
{
"name": "CtsScopedStorageDeviceOnlyTest"
},
{ {
"name": "AdoptableHostTest" "name": "AdoptableHostTest"
} }

View file

@ -55,6 +55,7 @@ namespace vold {
namespace { namespace {
constexpr const char* kDump = "android.permission.DUMP"; constexpr const char* kDump = "android.permission.DUMP";
constexpr auto kIncFsReadNoTimeoutMs = 100;
static binder::Status error(const std::string& msg) { static binder::Status error(const std::string& msg) {
PLOG(ERROR) << msg; PLOG(ERROR) << msg;
@ -989,6 +990,7 @@ binder::Status VoldNativeService::incFsEnabled(bool* _aidl_return) {
binder::Status VoldNativeService::mountIncFs( binder::Status VoldNativeService::mountIncFs(
const std::string& backingPath, const std::string& targetDir, int32_t flags, const std::string& backingPath, const std::string& targetDir, int32_t flags,
const std::string& sysfsName,
::android::os::incremental::IncrementalFileSystemControlParcel* _aidl_return) { ::android::os::incremental::IncrementalFileSystemControlParcel* _aidl_return) {
ENFORCE_SYSTEM_OR_ROOT; ENFORCE_SYSTEM_OR_ROOT;
CHECK_ARGUMENT_PATH(backingPath); CHECK_ARGUMENT_PATH(backingPath);
@ -996,9 +998,11 @@ binder::Status VoldNativeService::mountIncFs(
auto control = incfs::mount(backingPath, targetDir, auto control = incfs::mount(backingPath, targetDir,
{.flags = IncFsMountFlags(flags), {.flags = IncFsMountFlags(flags),
// Mount with read timeouts.
.defaultReadTimeoutMs = INCFS_DEFAULT_READ_TIMEOUT_MS, .defaultReadTimeoutMs = INCFS_DEFAULT_READ_TIMEOUT_MS,
// Mount with read logs disabled. // Mount with read logs disabled.
.readLogBufferPages = 0}); .readLogBufferPages = 0,
.sysfsName = sysfsName.c_str()});
if (!control) { if (!control) {
return translate(-errno); return translate(-errno);
} }
@ -1007,6 +1011,9 @@ binder::Status VoldNativeService::mountIncFs(
_aidl_return->cmd.reset(unique_fd(fds[CMD].release())); _aidl_return->cmd.reset(unique_fd(fds[CMD].release()));
_aidl_return->pendingReads.reset(unique_fd(fds[PENDING_READS].release())); _aidl_return->pendingReads.reset(unique_fd(fds[PENDING_READS].release()));
_aidl_return->log.reset(unique_fd(fds[LOGS].release())); _aidl_return->log.reset(unique_fd(fds[LOGS].release()));
if (fds[BLOCKS_WRITTEN].ok()) {
_aidl_return->blocksWritten.emplace(unique_fd(fds[BLOCKS_WRITTEN].release()));
}
return Ok(); return Ok();
} }
@ -1019,11 +1026,12 @@ binder::Status VoldNativeService::unmountIncFs(const std::string& dir) {
binder::Status VoldNativeService::setIncFsMountOptions( binder::Status VoldNativeService::setIncFsMountOptions(
const ::android::os::incremental::IncrementalFileSystemControlParcel& control, const ::android::os::incremental::IncrementalFileSystemControlParcel& control,
bool enableReadLogs) { bool enableReadLogs, bool enableReadTimeouts, const std::string& sysfsName) {
ENFORCE_SYSTEM_OR_ROOT; ENFORCE_SYSTEM_OR_ROOT;
auto incfsControl = auto incfsControl =
incfs::createControl(control.cmd.get(), control.pendingReads.get(), control.log.get()); incfs::createControl(control.cmd.get(), control.pendingReads.get(), control.log.get(),
control.blocksWritten ? control.blocksWritten->get() : -1);
auto cleanupFunc = [](auto incfsControl) { auto cleanupFunc = [](auto incfsControl) {
for (auto& fd : incfsControl->releaseFds()) { for (auto& fd : incfsControl->releaseFds()) {
(void)fd.release(); (void)fd.release();
@ -1033,8 +1041,10 @@ binder::Status VoldNativeService::setIncFsMountOptions(
std::unique_ptr<incfs::Control, decltype(cleanupFunc)>(&incfsControl, cleanupFunc); std::unique_ptr<incfs::Control, decltype(cleanupFunc)>(&incfsControl, cleanupFunc);
if (auto error = incfs::setOptions( if (auto error = incfs::setOptions(
incfsControl, incfsControl,
{.defaultReadTimeoutMs = INCFS_DEFAULT_READ_TIMEOUT_MS, {.defaultReadTimeoutMs =
.readLogBufferPages = enableReadLogs ? INCFS_DEFAULT_PAGE_READ_BUFFER_PAGES : 0}); enableReadTimeouts ? INCFS_DEFAULT_READ_TIMEOUT_MS : kIncFsReadNoTimeoutMs,
.readLogBufferPages = enableReadLogs ? INCFS_DEFAULT_PAGE_READ_BUFFER_PAGES : 0,
.sysfsName = sysfsName.c_str()});
error < 0) { error < 0) {
return binder::Status::fromServiceSpecificError(error); return binder::Status::fromServiceSpecificError(error);
} }

View file

@ -162,11 +162,12 @@ class VoldNativeService : public BinderService<VoldNativeService>, public os::Bn
binder::Status incFsEnabled(bool* _aidl_return) override; binder::Status incFsEnabled(bool* _aidl_return) override;
binder::Status mountIncFs( binder::Status mountIncFs(
const std::string& backingPath, const std::string& targetDir, int32_t flags, const std::string& backingPath, const std::string& targetDir, int32_t flags,
const std::string& sysfsName,
::android::os::incremental::IncrementalFileSystemControlParcel* _aidl_return) override; ::android::os::incremental::IncrementalFileSystemControlParcel* _aidl_return) override;
binder::Status unmountIncFs(const std::string& dir) override; binder::Status unmountIncFs(const std::string& dir) override;
binder::Status setIncFsMountOptions( binder::Status setIncFsMountOptions(
const ::android::os::incremental::IncrementalFileSystemControlParcel& control, const ::android::os::incremental::IncrementalFileSystemControlParcel& control,
bool enableReadLogs) override; bool enableReadLogs, bool enableReadTimeouts, const std::string& sysfsName) override;
binder::Status bindMount(const std::string& sourceDir, const std::string& targetDir) override; binder::Status bindMount(const std::string& sourceDir, const std::string& targetDir) override;
binder::Status destroyDsuMetadataKey(const std::string& dsuSlot) override; binder::Status destroyDsuMetadataKey(const std::string& dsuSlot) override;

View file

@ -140,9 +140,9 @@ interface IVold {
FileDescriptor openAppFuseFile(int uid, int mountId, int fileId, int flags); FileDescriptor openAppFuseFile(int uid, int mountId, int fileId, int flags);
boolean incFsEnabled(); boolean incFsEnabled();
IncrementalFileSystemControlParcel mountIncFs(@utf8InCpp String backingPath, @utf8InCpp String targetDir, int flags); IncrementalFileSystemControlParcel mountIncFs(@utf8InCpp String backingPath, @utf8InCpp String targetDir, int flags, @utf8InCpp String sysfsName);
void unmountIncFs(@utf8InCpp String dir); void unmountIncFs(@utf8InCpp String dir);
void setIncFsMountOptions(in IncrementalFileSystemControlParcel control, boolean enableReadLogs); void setIncFsMountOptions(in IncrementalFileSystemControlParcel control, boolean enableReadLogs, boolean enableReadTimeouts, @utf8InCpp String sysfsName);
void bindMount(@utf8InCpp String sourceDir, @utf8InCpp String targetDir); void bindMount(@utf8InCpp String sourceDir, @utf8InCpp String targetDir);
void destroyDsuMetadataKey(@utf8InCpp String dsuSlot); void destroyDsuMetadataKey(@utf8InCpp String dsuSlot);