Merge "Remove LLNDK libraries from system required"
diff --git a/debuggerd/crasher/Android.bp b/debuggerd/crasher/Android.bp
index 3af806b..fe1689c 100644
--- a/debuggerd/crasher/Android.bp
+++ b/debuggerd/crasher/Android.bp
@@ -15,6 +15,7 @@
"-fstack-protector-all",
"-Wno-date-time",
],
+ tidy: false, // crasher.cpp tests many memory access errors
srcs: ["crasher.cpp"],
arch: {
arm: {
diff --git a/fastboot/socket_test.cpp b/fastboot/socket_test.cpp
index 373abc3..74ff377 100644
--- a/fastboot/socket_test.cpp
+++ b/fastboot/socket_test.cpp
@@ -293,23 +293,23 @@
}
TEST(SocketMockTest, TestSendFailure) {
- SocketMock* mock = new SocketMock;
+ std::unique_ptr<SocketMock> mock(new SocketMock);
mock->ExpectSendFailure("foo");
- EXPECT_FALSE(SendString(mock, "foo"));
+ EXPECT_FALSE(SendString(mock.get(), "foo"));
- EXPECT_NONFATAL_FAILURE(SendString(mock, "foo"), "no message was expected");
+ EXPECT_NONFATAL_FAILURE(SendString(mock.get(), "foo"), "no message was expected");
mock->ExpectSend("foo");
- EXPECT_NONFATAL_FAILURE(SendString(mock, "bar"), "expected foo, but got bar");
- EXPECT_TRUE(SendString(mock, "foo"));
+ EXPECT_NONFATAL_FAILURE(SendString(mock.get(), "bar"), "expected foo, but got bar");
+ EXPECT_TRUE(SendString(mock.get(), "foo"));
mock->AddReceive("foo");
- EXPECT_NONFATAL_FAILURE(SendString(mock, "foo"), "called out-of-order");
- EXPECT_TRUE(ReceiveString(mock, "foo"));
+ EXPECT_NONFATAL_FAILURE(SendString(mock.get(), "foo"), "called out-of-order");
+ EXPECT_TRUE(ReceiveString(mock.get(), "foo"));
mock->ExpectSend("foo");
- EXPECT_NONFATAL_FAILURE(delete mock, "1 event(s) were not handled");
+ EXPECT_NONFATAL_FAILURE(mock.reset(), "1 event(s) were not handled");
}
TEST(SocketMockTest, TestReceiveSuccess) {
@@ -331,33 +331,33 @@
}
TEST(SocketMockTest, TestReceiveFailure) {
- SocketMock* mock = new SocketMock;
+ std::unique_ptr<SocketMock> mock(new SocketMock);
mock->AddReceiveFailure();
- EXPECT_FALSE(ReceiveString(mock, "foo"));
+ EXPECT_FALSE(ReceiveString(mock.get(), "foo"));
EXPECT_FALSE(mock->ReceiveTimedOut());
mock->AddReceiveTimeout();
- EXPECT_FALSE(ReceiveString(mock, "foo"));
+ EXPECT_FALSE(ReceiveString(mock.get(), "foo"));
EXPECT_TRUE(mock->ReceiveTimedOut());
mock->AddReceive("foo");
mock->AddReceiveFailure();
- EXPECT_FALSE(ReceiveString(mock, "foobar"));
+ EXPECT_FALSE(ReceiveString(mock.get(), "foobar"));
- EXPECT_NONFATAL_FAILURE(ReceiveString(mock, "foo"), "no message was ready");
+ EXPECT_NONFATAL_FAILURE(ReceiveString(mock.get(), "foo"), "no message was ready");
mock->ExpectSend("foo");
- EXPECT_NONFATAL_FAILURE(ReceiveString(mock, "foo"), "called out-of-order");
- EXPECT_TRUE(SendString(mock, "foo"));
+ EXPECT_NONFATAL_FAILURE(ReceiveString(mock.get(), "foo"), "called out-of-order");
+ EXPECT_TRUE(SendString(mock.get(), "foo"));
char c;
mock->AddReceive("foo");
EXPECT_NONFATAL_FAILURE(mock->Receive(&c, 1, 0), "not enough bytes (1) for foo");
- EXPECT_TRUE(ReceiveString(mock, "foo"));
+ EXPECT_TRUE(ReceiveString(mock.get(), "foo"));
mock->AddReceive("foo");
- EXPECT_NONFATAL_FAILURE(delete mock, "1 event(s) were not handled");
+ EXPECT_NONFATAL_FAILURE(mock.reset(), "1 event(s) were not handled");
}
TEST(SocketMockTest, TestAcceptSuccess) {
@@ -372,14 +372,14 @@
}
TEST(SocketMockTest, TestAcceptFailure) {
- SocketMock* mock = new SocketMock;
+ std::unique_ptr<SocketMock> mock(new SocketMock);
EXPECT_NONFATAL_FAILURE(mock->Accept(), "no socket was ready");
mock->ExpectSend("foo");
EXPECT_NONFATAL_FAILURE(mock->Accept(), "called out-of-order");
- EXPECT_TRUE(SendString(mock, "foo"));
+ EXPECT_TRUE(SendString(mock.get(), "foo"));
mock->AddAccept(nullptr);
- EXPECT_NONFATAL_FAILURE(delete mock, "1 event(s) were not handled");
+ EXPECT_NONFATAL_FAILURE(mock.reset(), "1 event(s) were not handled");
}
diff --git a/fs_mgr/OWNERS b/fs_mgr/OWNERS
index 6f1059b..bd46489 100644
--- a/fs_mgr/OWNERS
+++ b/fs_mgr/OWNERS
@@ -1,4 +1,4 @@
-# Bug component: 30545
+# Bug component: 325626
bowgotsai@google.com
dvander@google.com
elsk@google.com
diff --git a/fs_mgr/libsnapshot/Android.bp b/fs_mgr/libsnapshot/Android.bp
index 8e4b556..2165961 100644
--- a/fs_mgr/libsnapshot/Android.bp
+++ b/fs_mgr/libsnapshot/Android.bp
@@ -261,6 +261,7 @@
},
auto_gen_config: true,
require_root: true,
+ compile_multilib: "first",
}
cc_test {
diff --git a/fs_mgr/libsnapshot/snapshot_writer.cpp b/fs_mgr/libsnapshot/snapshot_writer.cpp
index 6aad3d1..82a7fd7 100644
--- a/fs_mgr/libsnapshot/snapshot_writer.cpp
+++ b/fs_mgr/libsnapshot/snapshot_writer.cpp
@@ -93,6 +93,9 @@
std::unique_ptr<FileDescriptor> CompressedSnapshotWriter::OpenReader() {
auto cow = OpenCowReader();
+ if (cow == nullptr) {
+ return nullptr;
+ }
auto reader = std::make_unique<CompressedSnapshotReader>();
if (!reader->SetCow(std::move(cow))) {
diff --git a/init/init.cpp b/init/init.cpp
index 540e2ca..4262191 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -739,33 +739,13 @@
HandlePowerctlMessage("shutdown,container");
}
-static constexpr std::chrono::milliseconds kDiagnosticTimeout = 10s;
-
-static void HandleSignalFd(bool one_off) {
+static void HandleSignalFd() {
signalfd_siginfo siginfo;
- auto started = std::chrono::steady_clock::now();
- do {
- ssize_t bytes_read = TEMP_FAILURE_RETRY(read(signal_fd, &siginfo, sizeof(siginfo)));
- if (bytes_read < 0 && errno == EAGAIN) {
- if (one_off) {
- return;
- }
- auto now = std::chrono::steady_clock::now();
- std::chrono::duration<double> waited = now - started;
- if (waited >= kDiagnosticTimeout) {
- LOG(ERROR) << "epoll() woke us up, but we waited with no SIGCHLD!";
- started = now;
- }
-
- std::this_thread::sleep_for(100ms);
- continue;
- }
- if (bytes_read != sizeof(siginfo)) {
- PLOG(ERROR) << "Failed to read siginfo from signal_fd";
- return;
- }
- break;
- } while (!one_off);
+ ssize_t bytes_read = TEMP_FAILURE_RETRY(read(signal_fd, &siginfo, sizeof(siginfo)));
+ if (bytes_read != sizeof(siginfo)) {
+ PLOG(ERROR) << "Failed to read siginfo from signal_fd";
+ return;
+ }
switch (siginfo.ssi_signo) {
case SIGCHLD:
@@ -820,14 +800,13 @@
LOG(FATAL) << "Failed to register a fork handler: " << strerror(result);
}
- signal_fd = signalfd(-1, &mask, SFD_CLOEXEC | SFD_NONBLOCK);
+ signal_fd = signalfd(-1, &mask, SFD_CLOEXEC);
if (signal_fd == -1) {
PLOG(FATAL) << "failed to create signalfd";
}
constexpr int flags = EPOLLIN | EPOLLPRI;
- auto handler = std::bind(HandleSignalFd, false);
- if (auto result = epoll->RegisterHandler(signal_fd, handler, flags); !result.ok()) {
+ if (auto result = epoll->RegisterHandler(signal_fd, HandleSignalFd, flags); !result.ok()) {
LOG(FATAL) << result.error();
}
}
@@ -956,32 +935,6 @@
return {};
}
-static void DumpPidFds(const std::string& prefix, pid_t pid) {
- std::error_code ec;
- std::string proc_dir = "/proc/" + std::to_string(pid) + "/fd";
- for (const auto& entry : std::filesystem::directory_iterator(proc_dir)) {
- std::string target;
- if (android::base::Readlink(entry.path(), &target)) {
- LOG(ERROR) << prefix << target;
- } else {
- LOG(ERROR) << prefix << entry.path();
- }
- }
-}
-
-static void DumpFile(const std::string& prefix, const std::string& file) {
- std::ifstream fp(file);
- if (!fp) {
- LOG(ERROR) << "Could not open " << file;
- return;
- }
-
- std::string line;
- while (std::getline(fp, line)) {
- LOG(ERROR) << prefix << line;
- }
-}
-
int SecondStageMain(int argc, char** argv) {
if (REBOOT_BOOTLOADER_ON_PANIC) {
InstallRebootSignalHandlers();
@@ -1155,7 +1108,7 @@
setpriority(PRIO_PROCESS, 0, 0);
while (true) {
// By default, sleep until something happens.
- std::chrono::milliseconds epoll_timeout{kDiagnosticTimeout};
+ std::optional<std::chrono::milliseconds> epoll_timeout;
auto shutdown_command = shutdown_state.CheckShutdown();
if (shutdown_command) {
@@ -1187,25 +1140,6 @@
auto epoll_result = epoll.Wait(epoll_timeout);
if (!epoll_result.ok()) {
LOG(ERROR) << epoll_result.error();
- } else if (*epoll_result <= 0 && Service::is_exec_service_running()) {
- static bool dumped_diagnostics = false;
- std::chrono::duration<double> waited =
- std::chrono::steady_clock::now() - Service::exec_service_started();
- if (waited >= kDiagnosticTimeout) {
- LOG(ERROR) << "Exec service is hung? Waited " << waited.count()
- << " without SIGCHLD";
- if (!dumped_diagnostics) {
- DumpPidFds("exec service opened: ", Service::exec_service_pid());
-
- std::string status_file =
- "/proc/" + std::to_string(Service::exec_service_pid()) + "/status";
- DumpFile("exec service: ", status_file);
- dumped_diagnostics = true;
-
- LOG(INFO) << "Attempting to handle any stuck SIGCHLDs...";
- HandleSignalFd(true);
- }
- }
}
if (!IsShuttingDown()) {
HandleControlMessages();
diff --git a/init/init_test.cpp b/init/init_test.cpp
index 7bad6fd..aea1cb3 100644
--- a/init/init_test.cpp
+++ b/init/init_test.cpp
@@ -194,10 +194,9 @@
}
TEST(init, StartConsole) {
- // Two different failures have been observed for this test: (1) No
- // permission to open /dev/console and (2) getsid() != pid. Skip this test
- // until these failures have been root-caused and fixed.
- GTEST_SKIP() << "This test needs to be improved";
+ if (access("/dev/console", F_OK) < 0) {
+ GTEST_SKIP() << "/dev/console not found";
+ }
std::string init_script = R"init(
service console /system/bin/sh
class core
@@ -205,7 +204,7 @@
disabled
user root
group root shell log readproc
- seclabel u:r:su:s0
+ seclabel u:r:shell:s0
setenv HOSTNAME console
)init";
@@ -219,7 +218,7 @@
ASSERT_RESULT_OK(service->Start());
const pid_t pid = service->pid();
ASSERT_GT(pid, 0);
- EXPECT_EQ(getsid(pid), pid);
+ EXPECT_NE(getsid(pid), 0);
service->Stop();
}
diff --git a/init/service.cpp b/init/service.cpp
index ccc7191..8db2b05 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -136,8 +136,6 @@
unsigned long Service::next_start_order_ = 1;
bool Service::is_exec_service_running_ = false;
-pid_t Service::exec_service_pid_ = -1;
-std::chrono::time_point<std::chrono::steady_clock> Service::exec_service_started_;
Service::Service(const std::string& name, Subcontext* subcontext_for_restart_commands,
const std::string& filename, const std::vector<std::string>& args)
@@ -433,8 +431,6 @@
flags_ |= SVC_EXEC;
is_exec_service_running_ = true;
- exec_service_pid_ = pid_;
- exec_service_started_ = std::chrono::steady_clock::now();
LOG(INFO) << "SVC_EXEC service '" << name_ << "' pid " << pid_ << " (uid " << proc_attr_.uid
<< " gid " << proc_attr_.gid << "+" << proc_attr_.supp_gids.size() << " context "
diff --git a/init/service.h b/init/service.h
index 54bf638..6fb2804 100644
--- a/init/service.h
+++ b/init/service.h
@@ -104,10 +104,6 @@
size_t CheckAllCommands() const { return onrestart_.CheckAllCommands(); }
static bool is_exec_service_running() { return is_exec_service_running_; }
- static pid_t exec_service_pid() { return exec_service_pid_; }
- static std::chrono::time_point<std::chrono::steady_clock> exec_service_started() {
- return exec_service_started_;
- }
const std::string& name() const { return name_; }
const std::set<std::string>& classnames() const { return classnames_; }
@@ -160,8 +156,6 @@
void SetMountNamespace();
static unsigned long next_start_order_;
static bool is_exec_service_running_;
- static std::chrono::time_point<std::chrono::steady_clock> exec_service_started_;
- static pid_t exec_service_pid_;
const std::string name_;
std::set<std::string> classnames_;
diff --git a/init/service_list.cpp b/init/service_list.cpp
index 3047821..937d82e 100644
--- a/init/service_list.cpp
+++ b/init/service_list.cpp
@@ -24,8 +24,8 @@
ServiceList::ServiceList() {}
ServiceList& ServiceList::GetInstance() {
- static ServiceList instance;
- return instance;
+ static ServiceList* instance = new ServiceList;
+ return *instance;
}
size_t ServiceList::CheckAllCommands() {
diff --git a/janitors/OWNERS b/janitors/OWNERS
index e132f0b..d871201 100644
--- a/janitors/OWNERS
+++ b/janitors/OWNERS
@@ -1,6 +1,7 @@
# OWNERS file for projects that don't really have owners so much as volunteer janitors.
ccross@google.com
+cferris@google.com
dwillemsen@google.com
enh@google.com
narayan@google.com
-sadafebrahimi@google.com
\ No newline at end of file
+sadafebrahimi@google.com
diff --git a/rootdir/init.rc b/rootdir/init.rc
index f05c0bf..1131f3f 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -1108,6 +1108,7 @@
# are not aware of using fsync()/sync() to prepare sudden power-cut.
write /dev/sys/fs/by-name/userdata/cp_interval 200
write /dev/sys/fs/by-name/userdata/gc_urgent_sleep_time 50
+ write /dev/sys/fs/by-name/userdata/iostat_period_ms 1000
write /dev/sys/fs/by-name/userdata/iostat_enable 1
# set readahead multiplier for POSIX_FADV_SEQUENTIAL files
diff --git a/trusty/keymaster/keymint/TrustyKeyMintDevice.cpp b/trusty/keymaster/keymint/TrustyKeyMintDevice.cpp
index 7d58162..b696ff9 100644
--- a/trusty/keymaster/keymint/TrustyKeyMintDevice.cpp
+++ b/trusty/keymaster/keymint/TrustyKeyMintDevice.cpp
@@ -91,7 +91,7 @@
} // namespace
ScopedAStatus TrustyKeyMintDevice::getHardwareInfo(KeyMintHardwareInfo* info) {
- info->versionNumber = 2;
+ info->versionNumber = 3;
info->securityLevel = kSecurityLevel;
info->keyMintName = "TrustyKeyMintDevice";
info->keyMintAuthorName = "Google";
diff --git a/trusty/keymaster/keymint/service.cpp b/trusty/keymaster/keymint/service.cpp
index 3447b27..14549d2 100644
--- a/trusty/keymaster/keymint/service.cpp
+++ b/trusty/keymaster/keymint/service.cpp
@@ -41,7 +41,7 @@
int main() {
auto trustyKeymaster = std::make_shared<keymaster::TrustyKeymaster>();
- int err = trustyKeymaster->Initialize(keymaster::KmVersion::KEYMINT_2);
+ int err = trustyKeymaster->Initialize(keymaster::KmVersion::KEYMINT_3);
if (err != 0) {
LOG(FATAL) << "Could not initialize TrustyKeymaster for KeyMint (" << err << ")";
return -1;
diff --git a/trusty/storage/proxy/Android.bp b/trusty/storage/proxy/Android.bp
index 94f26d8..e952ee0 100644
--- a/trusty/storage/proxy/Android.bp
+++ b/trusty/storage/proxy/Android.bp
@@ -32,11 +32,11 @@
shared_libs: [
"libbase",
+ "libcutils",
"liblog",
"libhardware_legacy",
],
header_libs: [
- "libcutils_headers",
"libgsi_headers",
],
diff --git a/trusty/storage/proxy/storage.c b/trusty/storage/proxy/storage.c
index c531cfd..033dc21 100644
--- a/trusty/storage/proxy/storage.c
+++ b/trusty/storage/proxy/storage.c
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#include <cutils/properties.h>
#include <errno.h>
#include <fcntl.h>
#include <inttypes.h>
@@ -43,6 +44,22 @@
static const char *ssdir_name;
+/*
+ * Property set to 1 after we have opened a file under ssdir_name. The backing
+ * files for both TD and TDP are currently located under /data/vendor/ss and can
+ * only be opened once userdata is mounted. This storageproxyd service is
+ * restarted when userdata is available, which causes the Trusty storage service
+ * to reconnect and attempt to open the backing files for TD and TDP. Once we
+ * set this property, other users can expect that the Trusty storage service
+ * ports will be available (although they may block if still being initialized),
+ * and connections will not be reset after this point (assuming the
+ * storageproxyd service stays running).
+ */
+#define FS_READY_PROPERTY "ro.vendor.trusty.storage.fs_ready"
+
+/* has FS_READY_PROPERTY been set? */
+static bool fs_ready_initialized = false;
+
static enum sync_state fs_state;
static enum sync_state fd_state[FD_TBL_SIZE];
@@ -336,6 +353,16 @@
ALOGV("%s: \"%s\": fd = %u: handle = %d\n",
__func__, path, rc, resp.handle);
+ /* a backing file has been opened, notify any waiting init steps */
+ if (!fs_ready_initialized) {
+ rc = property_set(FS_READY_PROPERTY, "1");
+ if (rc == 0) {
+ fs_ready_initialized = true;
+ } else {
+ ALOGE("Could not set property %s, rc: %d\n", FS_READY_PROPERTY, rc);
+ }
+ }
+
return ipc_respond(msg, &resp, sizeof(resp));
err_response:
diff --git a/trusty/test/binder/aidl/ByteEnum.aidl b/trusty/test/binder/aidl/com/android/trusty/binder/test/ByteEnum.aidl
similarity index 94%
rename from trusty/test/binder/aidl/ByteEnum.aidl
rename to trusty/test/binder/aidl/com/android/trusty/binder/test/ByteEnum.aidl
index d3a13ac..9c712c0 100644
--- a/trusty/test/binder/aidl/ByteEnum.aidl
+++ b/trusty/test/binder/aidl/com/android/trusty/binder/test/ByteEnum.aidl
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+package com.android.trusty.binder.test;
+
/*
* Hello, world!
*/
diff --git a/trusty/test/binder/aidl/ITestService.aidl b/trusty/test/binder/aidl/com/android/trusty/binder/test/ITestService.aidl
similarity index 93%
rename from trusty/test/binder/aidl/ITestService.aidl
rename to trusty/test/binder/aidl/com/android/trusty/binder/test/ITestService.aidl
index c6a99c8..cfbb246 100644
--- a/trusty/test/binder/aidl/ITestService.aidl
+++ b/trusty/test/binder/aidl/com/android/trusty/binder/test/ITestService.aidl
@@ -14,10 +14,11 @@
* limitations under the License.
*/
+package com.android.trusty.binder.test;
-import ByteEnum;
-import IntEnum;
-import LongEnum;
+import com.android.trusty.binder.test.ByteEnum;
+import com.android.trusty.binder.test.IntEnum;
+import com.android.trusty.binder.test.LongEnum;
interface ITestService {
const @utf8InCpp String PORT = "com.android.trusty.binder.test.service";
diff --git a/trusty/test/binder/aidl/IntEnum.aidl b/trusty/test/binder/aidl/com/android/trusty/binder/test/IntEnum.aidl
similarity index 94%
rename from trusty/test/binder/aidl/IntEnum.aidl
rename to trusty/test/binder/aidl/com/android/trusty/binder/test/IntEnum.aidl
index 120e44f..4055b25 100644
--- a/trusty/test/binder/aidl/IntEnum.aidl
+++ b/trusty/test/binder/aidl/com/android/trusty/binder/test/IntEnum.aidl
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+package com.android.trusty.binder.test;
+
@JavaDerive(toString=true)
@Backing(type="int")
enum IntEnum {
diff --git a/trusty/test/binder/aidl/LongEnum.aidl b/trusty/test/binder/aidl/com/android/trusty/binder/test/LongEnum.aidl
similarity index 94%
rename from trusty/test/binder/aidl/LongEnum.aidl
rename to trusty/test/binder/aidl/com/android/trusty/binder/test/LongEnum.aidl
index 0e9e933..20c64af 100644
--- a/trusty/test/binder/aidl/LongEnum.aidl
+++ b/trusty/test/binder/aidl/com/android/trusty/binder/test/LongEnum.aidl
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+package com.android.trusty.binder.test;
+
@Backing(type="long")
enum LongEnum {
FOO = 100000000000,
diff --git a/trusty/test/binder/aidl/rules.mk b/trusty/test/binder/aidl/rules.mk
index 6154abb..546a370 100644
--- a/trusty/test/binder/aidl/rules.mk
+++ b/trusty/test/binder/aidl/rules.mk
@@ -17,10 +17,12 @@
MODULE := $(LOCAL_DIR)
+MODULE_AIDL_PACKAGE := com/android/trusty/binder/test
+
MODULE_AIDLS := \
- $(LOCAL_DIR)/ByteEnum.aidl \
- $(LOCAL_DIR)/IntEnum.aidl \
- $(LOCAL_DIR)/ITestService.aidl \
- $(LOCAL_DIR)/LongEnum.aidl \
+ $(LOCAL_DIR)/$(MODULE_AIDL_PACKAGE)/ByteEnum.aidl \
+ $(LOCAL_DIR)/$(MODULE_AIDL_PACKAGE)/IntEnum.aidl \
+ $(LOCAL_DIR)/$(MODULE_AIDL_PACKAGE)/ITestService.aidl \
+ $(LOCAL_DIR)/$(MODULE_AIDL_PACKAGE)/LongEnum.aidl \
include make/aidl.mk