Initial unified commit for Android 14, with TrebleDroid GSI target, syncing up to 20240208
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
From cb9d1aaacaa105c20551952ead0ad7a49408efce Mon Sep 17 00:00:00 2001
|
||||
From: Pierre-Hugues Husson <phh@phh.me>
|
||||
Date: Wed, 27 Oct 2021 14:39:29 -0400
|
||||
Subject: [PATCH 1/2] Disable vndklite handling
|
||||
|
||||
Change-Id: Ic4474cf80fc4b45a9a2760dd51e2ca29c4d961e2
|
||||
---
|
||||
linker/linker.cpp | 5 -----
|
||||
1 file changed, 5 deletions(-)
|
||||
|
||||
diff --git a/linker/linker.cpp b/linker/linker.cpp
|
||||
index 17b574fc1..c863f8ea6 100644
|
||||
--- a/linker/linker.cpp
|
||||
+++ b/linker/linker.cpp
|
||||
@@ -95,7 +95,6 @@ static uint64_t g_module_unload_counter = 0;
|
||||
static const char* const kLdConfigArchFilePath = "/system/etc/ld.config." ABI_STRING ".txt";
|
||||
|
||||
static const char* const kLdConfigFilePath = "/system/etc/ld.config.txt";
|
||||
-static const char* const kLdConfigVndkLiteFilePath = "/system/etc/ld.config.vndk_lite.txt";
|
||||
|
||||
static const char* const kLdGeneratedConfigFilePath = "/linkerconfig/ld.config.txt";
|
||||
|
||||
@@ -3423,10 +3422,6 @@ static std::string get_ld_config_file_apex_path(const char* executable_path) {
|
||||
}
|
||||
|
||||
static std::string get_ld_config_file_vndk_path() {
|
||||
- if (android::base::GetBoolProperty("ro.vndk.lite", false)) {
|
||||
- return kLdConfigVndkLiteFilePath;
|
||||
- }
|
||||
-
|
||||
std::string ld_config_file_vndk = kLdConfigFilePath;
|
||||
size_t insert_pos = ld_config_file_vndk.find_last_of('.');
|
||||
if (insert_pos == std::string::npos) {
|
||||
--
|
||||
2.25.1
|
||||
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
From ab1289090a65808ee3fbbeb40b0a77e91c1a6aab Mon Sep 17 00:00:00 2001
|
||||
From: Pierre-Hugues Husson <phh@phh.me>
|
||||
Date: Sat, 19 Feb 2022 08:20:25 -0500
|
||||
Subject: [PATCH 2/2] Add new mechanism to fake vendor props on a per-process
|
||||
basis
|
||||
|
||||
This reads debug.phh.props.<process name>. If its value is "vendor",
|
||||
then ro.product.device/ro.product.manufacturer is read from vendor
|
||||
---
|
||||
libc/system_properties/system_properties.cpp | 87 +++++++++++++++++++-
|
||||
1 file changed, 85 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/libc/system_properties/system_properties.cpp b/libc/system_properties/system_properties.cpp
|
||||
index 1cb15c3df..057199318 100644
|
||||
--- a/libc/system_properties/system_properties.cpp
|
||||
+++ b/libc/system_properties/system_properties.cpp
|
||||
@@ -35,6 +35,8 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
+#include <string.h>
|
||||
+#include <fcntl.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
@@ -50,6 +52,85 @@
|
||||
#define SERIAL_DIRTY(serial) ((serial)&1)
|
||||
#define SERIAL_VALUE_LEN(serial) ((serial) >> 24)
|
||||
|
||||
+static char comm[128];
|
||||
+static bool self_ok = false;
|
||||
+static char comm_override[PROP_VALUE_MAX];
|
||||
+
|
||||
+static void read_self() {
|
||||
+ //NB: Not atomic, but should be good enough, there is no possible corruption from concurrency
|
||||
+ if(self_ok) return;
|
||||
+ self_ok = true;
|
||||
+
|
||||
+ char cmdline[128];
|
||||
+ int fd = open("/proc/self/cmdline", O_RDONLY);
|
||||
+ if(fd<0) return;
|
||||
+ read(fd, cmdline, sizeof(cmdline)-1);
|
||||
+ for(unsigned i=0; i<sizeof(cmdline); i++)
|
||||
+ if(cmdline[i] == '\n')
|
||||
+ cmdline[i] = 0;
|
||||
+ close(fd);
|
||||
+
|
||||
+ // Truncate to last /, we don't want `/` in the prop
|
||||
+ const char *c = strrchr(cmdline, '/');
|
||||
+ if (c != nullptr) {
|
||||
+ c = c+1;
|
||||
+ } else {
|
||||
+ c = cmdline;
|
||||
+ }
|
||||
+ // Take only the last 16 bytes (prop names max is 32)
|
||||
+ if(strlen(c) < 15) {
|
||||
+ strcpy(comm, c);
|
||||
+ } else {
|
||||
+ strcpy(comm, c + strlen(c) - 15);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ //That's calling ourselves but that's fine because we already have self_ok = true
|
||||
+ char propName[PROP_NAME_MAX];
|
||||
+ memset(propName, 0, PROP_NAME_MAX);
|
||||
+ strncpy(propName, "debug.phh.props.", PROP_NAME_MAX - 1);
|
||||
+ strncat(propName, comm, PROP_NAME_MAX - strlen(propName) - 1);
|
||||
+
|
||||
+ //async_safe_format_log(ANDROID_LOG_WARN, "libc", "Reading debug prop %s", propName);
|
||||
+ __system_property_get(propName, comm_override);
|
||||
+}
|
||||
+
|
||||
+static const char* redirectToProp(const char *name) {
|
||||
+ read_self();
|
||||
+ /*if(strstr(name, "ro.keymaster") != nullptr || strstr(name, "security_patch") != nullptr || strstr(name, "release") != nullptr) {
|
||||
+ async_safe_format_log(ANDROID_LOG_WARN, "libc", "Process/comm %s/%s is reading %s", comm, comm_override, name);
|
||||
+ }*/
|
||||
+ if(strcmp(comm_override, "vendor") == 0) {
|
||||
+ if(strcmp(name, "ro.product.device") == 0) {
|
||||
+ return "ro.product.vendor.device";
|
||||
+ }
|
||||
+ if(strcmp(name, "ro.product.manufacturer") == 0) {
|
||||
+ return "ro.product.vendor.manufacturer";
|
||||
+ }
|
||||
+ }
|
||||
+ if(strcmp(comm_override, "keymaster") == 0) {
|
||||
+ if(strcmp(name, "ro.product.model") == 0) {
|
||||
+ return "ro.keymaster.mod";
|
||||
+ }
|
||||
+ if(strcmp(name, "ro.product.brand") == 0) {
|
||||
+ return "ro.keymaster.brn";
|
||||
+ }
|
||||
+ if(strcmp(name, "ro.build.version.release") == 0) {
|
||||
+ return "ro.keymaster.xxx.release";
|
||||
+ }
|
||||
+ if(strcmp(name, "ro.build.version.security_patch") == 0) {
|
||||
+ return "ro.keymaster.xxx.security_patch";
|
||||
+ }
|
||||
+ if(strcmp(name, "ro.boot.vbmeta.device_state") == 0) {
|
||||
+ return "ro.keymaster.xxx.vbmeta_state";
|
||||
+ }
|
||||
+ if(strcmp(name, "ro.boot.verifiedbootstate") == 0) {
|
||||
+ return "ro.keymaster.xxx.verifiedbootstate";
|
||||
+ }
|
||||
+ }
|
||||
+ return name;
|
||||
+}
|
||||
+
|
||||
static bool is_dir(const char* pathname) {
|
||||
struct stat info;
|
||||
if (stat(pathname, &info) == -1) {
|
||||
@@ -123,17 +204,19 @@ uint32_t SystemProperties::AreaSerial() {
|
||||
}
|
||||
|
||||
const prop_info* SystemProperties::Find(const char* name) {
|
||||
+ const char* newName = redirectToProp(name);
|
||||
+
|
||||
if (!initialized_) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
- prop_area* pa = contexts_->GetPropAreaForName(name);
|
||||
+ prop_area* pa = contexts_->GetPropAreaForName(newName);
|
||||
if (!pa) {
|
||||
async_safe_format_log(ANDROID_LOG_WARN, "libc", "Access denied finding property \"%s\"", name);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
- return pa->find(name);
|
||||
+ return pa->find(newName);
|
||||
}
|
||||
|
||||
static bool is_read_only(const char* name) {
|
||||
--
|
||||
2.25.1
|
||||
|
||||
Reference in New Issue
Block a user