Compare commits
5 commits
7934335c2a
...
e5106dcec6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5106dcec6 | ||
|
|
bd7d27af34 | ||
|
|
9eef643c87 | ||
|
|
af70f20d4c | ||
|
|
35dd4cf950 |
2 changed files with 53 additions and 2 deletions
|
|
@ -123,6 +123,7 @@ libinit_cc_defaults {
|
|||
"-DREBOOT_BOOTLOADER_ON_PANIC=0",
|
||||
"-DSHUTDOWN_ZERO_TIMEOUT=0",
|
||||
"-DWORLD_WRITABLE_KMSG=0",
|
||||
"-DSPOOF_SAFETYNET=1",
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"-Wextra",
|
||||
|
|
@ -150,6 +151,8 @@ libinit_cc_defaults {
|
|||
cppflags: [
|
||||
"-USHUTDOWN_ZERO_TIMEOUT",
|
||||
"-DSHUTDOWN_ZERO_TIMEOUT=1",
|
||||
"-USPOOF_SAFETYNET",
|
||||
"-DSPOOF_SAFETYNET=0",
|
||||
],
|
||||
},
|
||||
uml: {
|
||||
|
|
@ -419,6 +422,7 @@ init_first_stage_cc_defaults {
|
|||
"-DSHUTDOWN_ZERO_TIMEOUT=0",
|
||||
"-DLOG_UEVENTS=0",
|
||||
"-DSEPOLICY_VERSION=30", // TODO(jiyong): externalize the version number
|
||||
"-DSPOOF_SAFETYNET=1",
|
||||
],
|
||||
|
||||
product_variables: {
|
||||
|
|
@ -448,6 +452,8 @@ init_first_stage_cc_defaults {
|
|||
cflags: [
|
||||
"-USHUTDOWN_ZERO_TIMEOUT",
|
||||
"-DSHUTDOWN_ZERO_TIMEOUT=1",
|
||||
"-USPOOF_SAFETYNET",
|
||||
"-DSPOOF_SAFETYNET=0",
|
||||
],
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
@ -1410,6 +1418,33 @@ static void ProcessBootconfig() {
|
|||
});
|
||||
}
|
||||
|
||||
static void SetSafetyNetProps() {
|
||||
InitPropertySet("ro.boot.flash.locked", "1");
|
||||
InitPropertySet("ro.boot.vbmeta.device_state", "locked");
|
||||
InitPropertySet("ro.boot.verifiedbootstate", "green");
|
||||
InitPropertySet("ro.boot.veritymode", "enforcing");
|
||||
InitPropertySet("ro.boot.warranty_bit", "0");
|
||||
InitPropertySet("ro.warranty_bit", "0");
|
||||
InitPropertySet("ro.debuggable", "0");
|
||||
InitPropertySet("ro.secure", "1");
|
||||
InitPropertySet("ro.bootimage.build.type", "user");
|
||||
InitPropertySet("ro.build.type", "user");
|
||||
InitPropertySet("ro.build.keys", "release-keys");
|
||||
InitPropertySet("ro.build.tags", "release-keys");
|
||||
InitPropertySet("ro.system.build.tags", "release-keys");
|
||||
InitPropertySet("ro.product.build.type", "user");
|
||||
InitPropertySet("ro.odm.build.type", "user");
|
||||
InitPropertySet("ro.system.build.type", "user");
|
||||
InitPropertySet("ro.system_ext.build.type", "user");
|
||||
InitPropertySet("ro.vendor.build.type", "user");
|
||||
InitPropertySet("ro.vendor_dlkm.build.type", "user");
|
||||
InitPropertySet("ro.vendor.boot.warranty_bit", "0");
|
||||
InitPropertySet("ro.vendor.warranty_bit", "0");
|
||||
InitPropertySet("vendor.boot.vbmeta.device_state", "locked");
|
||||
InitPropertySet("vendor.boot.verifiedbootstate", "green");
|
||||
InitPropertySet("oplusboot.verifiedbootstate", "green");
|
||||
}
|
||||
|
||||
void PropertyInit() {
|
||||
selinux_callback cb;
|
||||
cb.func_audit = PropertyAuditCallback;
|
||||
|
|
@ -1424,6 +1459,16 @@ void PropertyInit() {
|
|||
LOG(FATAL) << "Failed to load serialized property info file";
|
||||
}
|
||||
|
||||
// Report a valid verified boot chain to make Google SafetyNet integrity
|
||||
// checks pass. This needs to be done before parsing the kernel cmdline as
|
||||
// these properties are read-only and will be set to invalid values with
|
||||
// androidboot cmdline arguments.
|
||||
if (SPOOF_SAFETYNET) {
|
||||
if (!IsRecoveryMode()) {
|
||||
SetSafetyNetProps();
|
||||
}
|
||||
}
|
||||
|
||||
// If arguments are passed both on the command line and in DT,
|
||||
// properties set in DT always have priority over the command-line ones.
|
||||
ProcessKernelDt();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue