diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-07-03 12:07:03 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2021-07-03 12:07:03 +0000 |
commit | 17bc9ba426c0a358d68a5d062dc69d9d88be962d (patch) | |
tree | 5b94cddbafa38e172cc578729b912acc71fe6d64 | |
parent | c8b4d65396fff9cc8f6c5cf840d209b7ca4ffba4 (diff) | |
parent | 9ee010e46f64315b93ee8e4b2c45e2b53e276f8e (diff) | |
download | vold-17bc9ba426c0a358d68a5d062dc69d9d88be962d.tar.gz |
Snap for 7521021 from 9ee010e46f64315b93ee8e4b2c45e2b53e276f8e to mainline-media-swcodec-release
Change-Id: Ic53bee1824e38d46821836ccc427d992a87f671c
-rw-r--r-- | VoldNativeService.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/VoldNativeService.cpp b/VoldNativeService.cpp index d26758c5..ef26fb6b 100644 --- a/VoldNativeService.cpp +++ b/VoldNativeService.cpp @@ -26,6 +26,7 @@ #include <private/android_filesystem_config.h> #include <utils/Trace.h> +#include <sys/vfs.h> #include <fstream> #include <thread> @@ -939,10 +940,42 @@ static void initializeIncFs() { incfs::features(); } +// This is missing from the kernel UAPI headers. +#define ST_RDONLY 0x0001 + +// FDE devices run the post-fs-data trigger (and hence also earlyBootEnded) +// multiple times, sometimes prior to the real /data being mounted. That causes +// keystore2 to try to open a file in /data, causing it to panic or have to be +// killed by vold later, causing problems (vold failing to connect to keystore2, +// or keystore2 operations erroring out later). As a workaround to keep FDE +// working, ignore these too-early calls to earlyBootEnded. +// +// This can be removed when support for FDE is removed. +static bool IgnoreEarlyBootEnded() { + // The statfs("/data") below should be sufficient by itself, but to be safe + // we also explicitly return false on FBE devices. (This really should be + // ro.crypto.type != "block" for "non-FDE devices", but on FDE devices this + // is sometimes called before ro.crypto.type gets set.) + if (fscrypt_is_native()) return false; + + struct statfs buf; + if (statfs(DATA_MNT_POINT, &buf) != 0) { + PLOG(ERROR) << "statfs(\"/data\") failed"; + return false; + } + if (buf.f_type == TMPFS_MAGIC || (buf.f_flags & ST_RDONLY)) { + LOG(INFO) << "Ignoring earlyBootEnded since real /data isn't mounted yet"; + return true; + } + return false; +} + binder::Status VoldNativeService::earlyBootEnded() { ENFORCE_SYSTEM_OR_ROOT; ACQUIRE_LOCK; + if (IgnoreEarlyBootEnded()) return Ok(); + initializeIncFs(); Keymaster::earlyBootEnded(); return Ok(); |