summaryrefslogtreecommitdiffstats
path: root/init/service.cpp
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2019-04-23 16:26:01 +0200
committerMartijn Coenen <maco@google.com>2019-04-26 11:54:19 +0200
commitf0bc58a42dff06213b60676c034b0d345e2b5344 (patch)
tree74441d9e95e383c0d78c2d54b4d5c7116ebc7ec3 /init/service.cpp
parenta04e48dbec87730af840b3df2b459c03b87479e8 (diff)
downloadsystem_core-f0bc58a42dff06213b60676c034b0d345e2b5344.tar.gz
system_core-f0bc58a42dff06213b60676c034b0d345e2b5344.tar.bz2
system_core-f0bc58a42dff06213b60676c034b0d345e2b5344.zip
Support for stopping/starting post-data-mount class subsets.
On devices that use FDE and APEX at the same time, we need to bring up a minimal framework to be able to mount the /data partition. During this period, a tmpfs /data filesystem is created, which doesn't contain any of the updated APEXEs. As a consequence, all those processes will be using the APEXes from the /system partition. This is obviously not desired, as APEXes in /system may be old and/or contain security issues. Additionally, it would create a difference between FBE and FDE devices at runtime. Ideally, we restart all processes that have started after we created the tmpfs /data. We can't (re)start based on class names alone, because some classes (eg 'hal') contain services that are required to start apexd itself and that shouldn't be killed (eg the graphics HAL). To address this, keep track of which processes are started after /data is mounted, with a new 'mark_post_data' keyword. Additionally, create 'class_reset_post_data', which resets all services in the class that were created after the initial /data mount, and 'class_start_post_data', which starts all services in the class that were started after /data was mounted. On a device with FBE, these keywords wouldn't be used; on a device with FDE, we'd use them to bring down the right processes after the user has entered the correct secret, and restart them. Bug: 118485723 Test: manually verified process list Change-Id: I16adb776dacf1dd1feeaff9e60639b99899905eb
Diffstat (limited to 'init/service.cpp')
-rw-r--r--init/service.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/init/service.cpp b/init/service.cpp
index f5c13b983..8c3e228a5 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -362,7 +362,7 @@ void Service::Reap(const siginfo_t& siginfo) {
// Oneshot processes go into the disabled state on exit,
// except when manually restarted.
- if ((flags_ & SVC_ONESHOT) && !(flags_ & SVC_RESTART)) {
+ if ((flags_ & SVC_ONESHOT) && !(flags_ & SVC_RESTART) && !(flags_ & SVC_RESET)) {
flags_ |= SVC_DISABLED;
}
@@ -947,6 +947,8 @@ Result<Success> Service::Start() {
pre_apexd_ = true;
}
+ post_data_ = ServiceList::GetInstance().IsPostData();
+
LOG(INFO) << "starting service '" << name_ << "'...";
pid_t pid = -1;
@@ -1146,6 +1148,12 @@ void Service::Reset() {
StopOrReset(SVC_RESET);
}
+void Service::ResetIfPostData() {
+ if (post_data_) {
+ StopOrReset(SVC_RESET);
+ }
+}
+
void Service::Stop() {
StopOrReset(SVC_DISABLED);
}
@@ -1339,6 +1347,14 @@ void ServiceList::DumpState() const {
}
}
+void ServiceList::MarkPostData() {
+ post_data_ = true;
+}
+
+bool ServiceList::IsPostData() {
+ return post_data_;
+}
+
void ServiceList::MarkServicesUpdate() {
services_update_finished_ = true;