Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raviole #1

Merged
merged 2 commits into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 1 addition & 6 deletions fastboot/device/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,7 @@ std::vector<std::string> ListPartitions(FastbootDevice* device) {
}

bool GetDeviceLockStatus() {
std::string cmdline;
// Return lock status true if unable to read kernel command line.
if (!android::base::ReadFileToString("/proc/cmdline", &cmdline)) {
return true;
}
return cmdline.find("androidboot.verifiedbootstate=orange") == std::string::npos;
return android::base::GetProperty("ro.boot.verifiedbootstate", "") != "orange";
}

bool UpdateAllPartitionMetadata(FastbootDevice* device, const std::string& super_name,
Expand Down
33 changes: 33 additions & 0 deletions init/property_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,7 @@ static void ProcessKernelDt() {
}

constexpr auto ANDROIDBOOT_PREFIX = "androidboot."sv;
constexpr auto ANDROIDBOOT_MODE = "androidboot.mode"sv;

static void ProcessKernelCmdline() {
ImportKernelCmdline([&](const std::string& key, const std::string& value) {
Expand All @@ -1371,6 +1372,35 @@ static void ProcessBootconfig() {
});
}

static void SetSafetyNetProps() {
// Check whether this is a normal boot, and whether the bootloader is actually locked
auto isNormalBoot = true; // no prop = normal boot
// This runs before keys are set as props, so we need to process them ourselves.
ImportKernelCmdline([&](const std::string& key, const std::string& value) {
if (key == ANDROIDBOOT_MODE && value != "normal") {
isNormalBoot = false;
}
});
ImportBootconfig([&](const std::string& key, const std::string& value) {
if (key == ANDROIDBOOT_MODE && value != "normal") {
isNormalBoot = false;
}
});

// Bail out if this is recovery, fastbootd, or anything other than a normal boot.
// fastbootd, in particular, needs the real values so it can allow flashing on
// unlocked bootloaders.
if (!isNormalBoot) {
return;
}

// Spoof properties
InitPropertySet("ro.boot.flash.locked", "1");
InitPropertySet("ro.boot.verifiedbootstate", "green");
InitPropertySet("ro.boot.veritymode", "enforcing");
InitPropertySet("ro.boot.vbmeta.device_state", "locked");
}

void PropertyInit() {
selinux_callback cb;
cb.func_audit = PropertyAuditCallback;
Expand All @@ -1385,6 +1415,9 @@ void PropertyInit() {
LOG(FATAL) << "Failed to load serialized property info file";
}

// Report valid verified boot chain to help pass Google SafetyNet integrity checks
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();
Expand Down