From caa7a60e2d2bd881c7c03131e59052d47a88240a Mon Sep 17 00:00:00 2001 From: Florian Mayer Date: Thu, 15 Sep 2022 18:10:54 -0700 Subject: [PATCH] [MTE] Add device config to control upgrade time Bug: 169277947 Change-Id: I67eb94a668e60a2970bb086f82cc69396275340a --- init/service.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/init/service.cpp b/init/service.cpp index 4cf409c2d..054ae49b4 100644 --- a/init/service.cpp +++ b/init/service.cpp @@ -331,9 +331,18 @@ void Service::Reap(const siginfo_t& siginfo) { !upgraded_mte_; if (should_upgrade_mte) { - LOG(INFO) << "Upgrading service " << name_ << " to sync MTE"; - once_environment_vars_.emplace_back("BIONIC_MEMTAG_UPGRADE_SECS", "60"); - upgraded_mte_ = true; + constexpr int kDefaultUpgradeSecs = 60; + int secs = GetIntProperty("persist.device_config.memory_safety_native.upgrade_secs.default", + kDefaultUpgradeSecs); + secs = GetIntProperty( + "persist.device_config.memory_safety_native.upgrade_secs.service." + name_, secs); + if (secs > 0) { + LOG(INFO) << "Upgrading service " << name_ << " to sync MTE for " << secs << " seconds"; + once_environment_vars_.emplace_back("BIONIC_MEMTAG_UPGRADE_SECS", std::to_string(secs)); + upgraded_mte_ = true; + } else { + LOG(INFO) << "Not upgrading service " << name_ << " to sync MTE due to device config"; + } } #endif