init: Weaken property override security for the init extension
Sometimes we need to override ro.* properties by using our vendor init extension. Previously there was a security check which was blocking that. To resolve the issue, we need to weaken the security check during the execution of our vendor init extension. This is safe because the vendor init extension gets executed as part of init construction and it is considered a trusted system component. Change-Id: I6095bbf92267fcb78ab53f37b5d7b443239ce80b Signed-off-by: Dmitrii <bankersenator@gmail.com>
This commit is contained in:
parent
7934335c2a
commit
b35c6272dc
1 changed files with 10 additions and 2 deletions
|
|
@ -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<PropertyAuditData*>(data);
|
||||
|
||||
|
|
@ -406,8 +408,8 @@ static std::optional<uint32_t> 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();
|
||||
|
||||
|
|
@ -1253,6 +1258,9 @@ void PropertyLoadBootDefaults() {
|
|||
property_initialize_ro_vendor_api_level();
|
||||
|
||||
update_sys_usb_config();
|
||||
|
||||
// Restore the normal property override security after init extension is executed
|
||||
weaken_prop_override_security = false;
|
||||
}
|
||||
|
||||
void PropertyLoadDerivedDefaults() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue