diff --git a/init/property_service.cpp b/init/property_service.cpp index 5fdc959e7..01f5c4891 100644 --- a/init/property_service.cpp +++ b/init/property_service.cpp @@ -132,6 +132,8 @@ struct PropertyAuditData { const char* name; }; +static bool weaken_prop_override_security = false; + static int PropertyAuditCallback(void* data, security_class_t /*cls*/, char* buf, size_t len) { auto* d = reinterpret_cast(data); @@ -406,8 +408,8 @@ static std::optional PropertySet(const std::string& name, const std::s } else { prop_info* pi = (prop_info*)__system_property_find(name.c_str()); if (pi != nullptr) { - // ro.* properties are actually "write-once". - if (StartsWith(name, "ro.")) { + // ro.* properties are actually "write-once", unless the system decides to + if (StartsWith(name, "ro.") && !weaken_prop_override_security) { *error = "Read-only property was already set"; return {PROP_ERROR_READ_ONLY_PROPERTY}; } @@ -1242,6 +1244,9 @@ void PropertyLoadBootDefaults() { } } + // Weaken property override security during execution of the vendor init extension + weaken_prop_override_security = true; + // Update with vendor-specific property runtime overrides vendor_load_properties(); @@ -1252,6 +1257,9 @@ void PropertyLoadBootDefaults() { property_initialize_ro_cpu_abilist(); property_initialize_ro_vendor_api_level(); + // Restore the normal property override security after init extension is executed + weaken_prop_override_security = false; + update_sys_usb_config(); }