android-10.0.0_r47 patches

This commit is contained in:
Ziyang Zhou
2023-10-05 22:33:12 +08:00
parent aea90812bf
commit 629a8db239
16 changed files with 3196 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
From 90b7a7268d094a120262ffdd1ffcb82a7b25e39b Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Mon, 26 Apr 2021 22:55:03 +0800
Subject: [PATCH] disable seccomp
---
libminijail.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libminijail.c b/libminijail.c
index 482d6bd..43a8945 100644
--- a/libminijail.c
+++ b/libminijail.c
@@ -1973,6 +1973,7 @@ static void set_seccomp_filter(const struct minijail *j)
/*
* Install the syscall filter.
*/
+#if 0 // HACKED
if (j->flags.seccomp_filter) {
if (j->flags.seccomp_filter_tsync) {
if (sys_seccomp(SECCOMP_SET_MODE_FILTER,
@@ -1987,6 +1988,7 @@ static void set_seccomp_filter(const struct minijail *j)
}
}
}
+#endif
}
static pid_t forward_pid = -1;
--
2.34.1

View File

@@ -0,0 +1,239 @@
From d1d6a6428d322db8431d92e72e95ee0334352400 Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Sun, 9 May 2021 23:12:46 +0800
Subject: [PATCH] ignore selinux
---
libselinux/include/selinux/selinux.h | 4 ++++
libselinux/src/android/android.c | 1 +
libselinux/src/android/android_platform.c | 6 ++++++
libselinux/src/checkAccess.c | 1 +
libselinux/src/getenforce.c | 1 +
libselinux/src/getfilecon.c | 1 +
libselinux/src/getpeercon.c | 1 +
libselinux/src/init.c | 1 +
libselinux/src/label.c | 2 ++
libselinux/src/lgetfilecon.c | 1 +
libselinux/src/lsetfilecon.c | 1 +
libselinux/src/procattr.c | 2 ++
libselinux/src/sestatus.c | 1 +
13 files changed, 23 insertions(+)
diff --git a/libselinux/include/selinux/selinux.h b/libselinux/include/selinux/selinux.h
index a34d54f..d7e034d 100644
--- a/libselinux/include/selinux/selinux.h
+++ b/libselinux/include/selinux/selinux.h
@@ -4,6 +4,10 @@
#include <sys/types.h>
#include <stdarg.h>
+#define SE_HACK
+#define se_hack() if (1) return
+#define se_hack1(p) if (1) return p
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/libselinux/src/android/android.c b/libselinux/src/android/android.c
index e15dabe..c9005ed 100644
--- a/libselinux/src/android/android.c
+++ b/libselinux/src/android/android.c
@@ -58,6 +58,7 @@ struct selabel_handle* selinux_android_service_open_context_handle(const struct
sehandle = selabel_open(SELABEL_CTX_ANDROID_SERVICE,
seopts_service, nopts);
+ se_hack1(sehandle);
if (!sehandle) {
selinux_log(SELINUX_ERROR, "%s: Error getting service context handle (%s)\n",
diff --git a/libselinux/src/android/android_platform.c b/libselinux/src/android/android_platform.c
index 83a795a..c100325 100644
--- a/libselinux/src/android/android_platform.c
+++ b/libselinux/src/android/android_platform.c
@@ -170,6 +170,7 @@ static struct selabel_handle* selinux_android_file_context(const struct selinux_
struct selabel_handle* selinux_android_file_context_handle(void)
{
+ se_hack1(NULL);
struct selinux_opt seopts_file[MAX_FILE_CONTEXT_SIZE];
int size = 0;
unsigned int i;
@@ -202,6 +203,7 @@ struct selabel_handle* selinux_android_file_context_handle(void)
struct selabel_handle* selinux_android_prop_context_handle(void)
{
+ se_hack1(NULL);
struct selabel_handle* sehandle;
struct selinux_opt seopts_prop[MAX_FILE_CONTEXT_SIZE];
int size = 0;
@@ -1157,6 +1159,7 @@ oom:
int selinux_android_setcon(const char *con)
{
+ se_hack1(0);
int ret = setcon(con);
if (ret)
return ret;
@@ -1173,6 +1176,7 @@ int selinux_android_setcontext(uid_t uid,
const char *seinfo,
const char *pkgname)
{
+ se_hack1(0);
char *orig_ctx_str = NULL, *ctx_str;
context_t ctx = NULL;
int rc = -1;
@@ -1563,6 +1567,7 @@ static int selinux_android_restorecon_common(const char* pathname_orig,
uid_t uid,
unsigned int flags)
{
+ se_hack1(0);
bool nochange = (flags & SELINUX_ANDROID_RESTORECON_NOCHANGE) ? true : false;
bool verbose = (flags & SELINUX_ANDROID_RESTORECON_VERBOSE) ? true : false;
bool recurse = (flags & SELINUX_ANDROID_RESTORECON_RECURSE) ? true : false;
@@ -1805,6 +1810,7 @@ void selinux_android_set_sehandle(const struct selabel_handle *hndl)
int selinux_android_load_policy()
{
+ se_hack1(0);
int fd = -1;
fd = open(sepolicy_file, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
diff --git a/libselinux/src/checkAccess.c b/libselinux/src/checkAccess.c
index 16bfcfb..c7d0f03 100644
--- a/libselinux/src/checkAccess.c
+++ b/libselinux/src/checkAccess.c
@@ -33,6 +33,7 @@ static void avc_init_once(void)
}
int selinux_check_access(const char *scon, const char *tcon, const char *class, const char *perm, void *aux) {
+ se_hack1(0);
int rc;
security_id_t scon_id;
security_id_t tcon_id;
diff --git a/libselinux/src/getenforce.c b/libselinux/src/getenforce.c
index d909dce..fb782b7 100644
--- a/libselinux/src/getenforce.c
+++ b/libselinux/src/getenforce.c
@@ -11,6 +11,7 @@
int security_getenforce(void)
{
+ se_hack1(0);
int fd, ret, enforce = 0;
char path[PATH_MAX];
char buf[20];
diff --git a/libselinux/src/getfilecon.c b/libselinux/src/getfilecon.c
index 20bee8a..ebbae3c 100644
--- a/libselinux/src/getfilecon.c
+++ b/libselinux/src/getfilecon.c
@@ -53,6 +53,7 @@ hidden_def(getfilecon_raw)
int getfilecon(const char *path, char ** context)
{
+ se_hack1((*context = calloc(7, 1), memcpy(*context, "HACKED", 6), 0));
int ret;
char * rcontext = NULL;
diff --git a/libselinux/src/getpeercon.c b/libselinux/src/getpeercon.c
index 3a77a2d..f8dab8e 100644
--- a/libselinux/src/getpeercon.c
+++ b/libselinux/src/getpeercon.c
@@ -47,6 +47,7 @@ hidden_def(getpeercon_raw)
int getpeercon(int fd, char ** context)
{
+ se_hack1((*context = calloc(7, 1), memcpy(*context, "HACKED", 6), 0));
int ret;
char * rcontext;
diff --git a/libselinux/src/init.c b/libselinux/src/init.c
index 2690a72..24a212d 100644
--- a/libselinux/src/init.c
+++ b/libselinux/src/init.c
@@ -142,6 +142,7 @@ hidden_def(fini_selinuxmnt)
void set_selinuxmnt(const char *mnt)
{
+ se_hack();
selinux_mnt = strdup(mnt);
}
diff --git a/libselinux/src/label.c b/libselinux/src/label.c
index e232eb1..83c73d9 100644
--- a/libselinux/src/label.c
+++ b/libselinux/src/label.c
@@ -246,6 +246,7 @@ out:
int selabel_lookup(struct selabel_handle *rec, char **con,
const char *key, int type)
{
+ se_hack1((*con = calloc(7, 1), memcpy(*con, "HACKED", 6), 0));
struct selabel_lookup_rec *lr;
lr = selabel_lookup_common(rec, 1, key, type);
@@ -294,6 +295,7 @@ bool selabel_hash_all_partial_matches(struct selabel_handle *rec,
int selabel_lookup_best_match(struct selabel_handle *rec, char **con,
const char *key, const char **aliases, int type)
{
+ se_hack1((*con = calloc(7, 1), memcpy(*con, "HACKED", 6), 0));
struct selabel_lookup_rec *lr;
if (!rec->func_lookup_best_match) {
diff --git a/libselinux/src/lgetfilecon.c b/libselinux/src/lgetfilecon.c
index db67bc6..7123480 100644
--- a/libselinux/src/lgetfilecon.c
+++ b/libselinux/src/lgetfilecon.c
@@ -53,6 +53,7 @@ hidden_def(lgetfilecon_raw)
int lgetfilecon(const char *path, char ** context)
{
+ se_hack1((*context = calloc(7, 1), memcpy(*context, "HACKED", 6), 0));
int ret;
char * rcontext = NULL;
diff --git a/libselinux/src/lsetfilecon.c b/libselinux/src/lsetfilecon.c
index 1d3b28a..7062703 100644
--- a/libselinux/src/lsetfilecon.c
+++ b/libselinux/src/lsetfilecon.c
@@ -29,6 +29,7 @@ hidden_def(lsetfilecon_raw)
int lsetfilecon(const char *path, const char *context)
{
+ se_hack1(0);
int ret;
char * rcontext;
diff --git a/libselinux/src/procattr.c b/libselinux/src/procattr.c
index c6799ef..1f7d9c3 100644
--- a/libselinux/src/procattr.c
+++ b/libselinux/src/procattr.c
@@ -195,6 +195,7 @@ static int getprocattrcon_raw(char ** context,
static int getprocattrcon(char ** context,
pid_t pid, const char *attr)
{
+ se_hack1((*context = calloc(7, 1), memcpy(*context, "HACKED", 6), 0));
int ret;
char * rcontext;
@@ -280,6 +281,7 @@ out:
static int setprocattrcon(const char * context,
pid_t pid, const char *attr)
{
+ se_hack1(0);
int ret;
char * rcontext;
diff --git a/libselinux/src/sestatus.c b/libselinux/src/sestatus.c
index ed29dc5..b1df5fe 100644
--- a/libselinux/src/sestatus.c
+++ b/libselinux/src/sestatus.c
@@ -254,6 +254,7 @@ static int fallback_cb_policyload(int policyload)
*/
int selinux_status_open(int fallback)
{
+ se_hack1(0);
int fd;
char path[PATH_MAX];
long pagesize;
--
2.34.1

View File

@@ -0,0 +1,42 @@
From fb3d1b87ae0a208cb9446dbacb57f09c9d2d8da9 Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Mon, 26 Apr 2021 23:01:03 +0800
Subject: [PATCH] video playback workaround
---
media/libstagefright/colorconversion/SoftwareRenderer.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/media/libstagefright/colorconversion/SoftwareRenderer.cpp b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
index 359df3d54..c1def91f9 100644
--- a/media/libstagefright/colorconversion/SoftwareRenderer.cpp
+++ b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
@@ -125,6 +125,7 @@ void SoftwareRenderer::resetFormatIfChanged(
// hardware has YUV12 and RGBA8888 support, so convert known formats
{
switch (mColorFormat) {
+#if 0 // HACKED
case OMX_COLOR_FormatYUV420Planar:
case OMX_COLOR_FormatYUV420SemiPlanar:
case OMX_TI_COLOR_FormatYUV420PackedSemiPlanar:
@@ -134,6 +135,7 @@ void SoftwareRenderer::resetFormatIfChanged(
bufHeight = (mCropHeight + 1) & ~1;
break;
}
+#endif
case OMX_COLOR_Format24bitRGB888:
{
halFormat = HAL_PIXEL_FORMAT_RGB_888;
@@ -159,7 +161,9 @@ void SoftwareRenderer::resetFormatIfChanged(
// use render engine to convert it to RGB if needed.
halFormat = HAL_PIXEL_FORMAT_RGBA_1010102;
} else {
+#if 0 // HACKED
halFormat = HAL_PIXEL_FORMAT_YV12;
+#endif
}
bufWidth = (mCropWidth + 1) & ~1;
bufHeight = (mCropHeight + 1) & ~1;
--
2.34.1

View File

@@ -0,0 +1,106 @@
From 9653dd065fdbd99b058f0d9e09b46b6bd5d68896 Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Sun, 9 May 2021 22:04:12 +0800
Subject: [PATCH 1/2] fix booting
---
core/jni/android_os_SELinux.cpp | 7 +++++++
core/jni/android_os_VintfObject.cpp | 2 ++
.../android/server/net/NetworkPolicyManagerService.java | 1 +
3 files changed, 10 insertions(+)
diff --git a/core/jni/android_os_SELinux.cpp b/core/jni/android_os_SELinux.cpp
index 236ee6123cd..0ba320f4668 100644
--- a/core/jni/android_os_SELinux.cpp
+++ b/core/jni/android_os_SELinux.cpp
@@ -81,6 +81,7 @@ static jboolean isSELinuxEnforced(JNIEnv *env, jobject) {
}
static jstring fileSelabelLookup(JNIEnv* env, jobject, jstring pathStr) {
+ se_hack1(env->NewStringUTF("HACKED"));
if (isSELinuxDisabled) {
ALOGE("fileSelabelLookup => SELinux is disabled");
return NULL;
@@ -119,6 +120,7 @@ static jstring fileSelabelLookup(JNIEnv* env, jobject, jstring pathStr) {
}
static jstring getFdConInner(JNIEnv *env, jobject fileDescriptor, bool isSocket) {
+ se_hack1(env->NewStringUTF("HACKED"));
if (isSELinuxDisabled) {
return NULL;
}
@@ -187,6 +189,7 @@ static jstring getFdCon(JNIEnv *env, jobject, jobject fileDescriptor) {
* Exception: none
*/
static jboolean setFSCreateCon(JNIEnv *env, jobject, jstring contextStr) {
+ se_hack1(true);
if (isSELinuxDisabled) {
return false;
}
@@ -218,6 +221,7 @@ static jboolean setFSCreateCon(JNIEnv *env, jobject, jstring contextStr) {
* Exception: NullPointerException is thrown if either path or context strign are NULL
*/
static jboolean setFileCon(JNIEnv *env, jobject, jstring pathStr, jstring contextStr) {
+ se_hack1(true);
if (isSELinuxDisabled) {
return false;
}
@@ -251,6 +255,7 @@ static jboolean setFileCon(JNIEnv *env, jobject, jstring pathStr, jstring contex
* Exceptions: NullPointerException if the path object is null
*/
static jstring getFileCon(JNIEnv *env, jobject, jstring pathStr) {
+ se_hack1(env->NewStringUTF("HACKED"));
if (isSELinuxDisabled) {
return NULL;
}
@@ -282,6 +287,7 @@ static jstring getFileCon(JNIEnv *env, jobject, jstring pathStr) {
* Exceptions: none
*/
static jstring getCon(JNIEnv *env, jobject) {
+ se_hack1(env->NewStringUTF("HACKED"));
if (isSELinuxDisabled) {
return NULL;
}
@@ -309,6 +315,7 @@ static jstring getCon(JNIEnv *env, jobject) {
* Exceptions: none
*/
static jstring getPidCon(JNIEnv *env, jobject, jint pid) {
+ se_hack1(env->NewStringUTF("HACKED"));
if (isSELinuxDisabled) {
return NULL;
}
diff --git a/core/jni/android_os_VintfObject.cpp b/core/jni/android_os_VintfObject.cpp
index ee11b6162db..9ebcf398f6a 100644
--- a/core/jni/android_os_VintfObject.cpp
+++ b/core/jni/android_os_VintfObject.cpp
@@ -97,6 +97,7 @@ static jobjectArray android_os_VintfObject_report(JNIEnv* env, jclass)
}
static jint android_os_VintfObject_verify(JNIEnv* env, jclass, jobjectArray packageInfo) {
+ if (env) return 0; // HACKED, no kernel
std::vector<std::string> cPackageInfo;
if (packageInfo) {
size_t count = env->GetArrayLength(packageInfo);
@@ -116,6 +117,7 @@ static jint android_os_VintfObject_verify(JNIEnv* env, jclass, jobjectArray pack
}
static jint android_os_VintfObject_verifyWithoutAvb(JNIEnv* env, jclass) {
+ if (env) return 0; // HACKED, no kernel
std::string error;
int32_t status = VintfObject::CheckCompatibility({}, &error,
::android::vintf::CheckFlags::DISABLE_AVB_CHECK);
diff --git a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
index 6c34e1313f7..55bde658e12 100644
--- a/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
+++ b/services/core/java/com/android/server/net/NetworkPolicyManagerService.java
@@ -729,6 +729,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
Process.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND);
if (!isBandwidthControlEnabled()) {
Slog.w(TAG, "bandwidth controls disabled, unable to enforce policy");
+ initCompleteSignal.countDown(); // HACKED (?)
return;
}
--
2.34.1

View File

@@ -0,0 +1,24 @@
From a11577d9cf469267dcdfd8385965d24a47f5622f Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Fri, 25 Jun 2021 15:25:00 +0000
Subject: [PATCH 2/2] mocked WiFi
---
core/java/android/net/ConnectivityManager.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 111a8c48a46..3c467d33228 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -1160,6 +1160,7 @@ public class ConnectivityManager {
@Nullable
public NetworkInfo getNetworkInfo(int networkType) {
try {
+ if (networkType == ConnectivityManager.TYPE_WIFI) networkType = ConnectivityManager.TYPE_ETHERNET;
return mService.getNetworkInfo(networkType);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
--
2.34.1

View File

@@ -0,0 +1,66 @@
From ccc25478ae016d064fa7cebece6cf2bba1f3babc Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Sun, 9 May 2021 23:01:00 +0800
Subject: [PATCH] fix booting
---
cmds/servicemanager/binder.c | 3 +++
libs/binder/Binder.cpp | 1 +
libs/binder/ProcessState.cpp | 3 +++
3 files changed, 7 insertions(+)
diff --git a/cmds/servicemanager/binder.c b/cmds/servicemanager/binder.c
index cf3b1728b..9c1eea4d5 100644
--- a/cmds/servicemanager/binder.c
+++ b/cmds/servicemanager/binder.c
@@ -146,12 +146,15 @@ void binder_close(struct binder_state *bs)
int binder_become_context_manager(struct binder_state *bs)
{
+#if 0 // HACKED
struct flat_binder_object obj;
memset(&obj, 0, sizeof(obj));
obj.flags = FLAT_BINDER_FLAG_TXN_SECURITY_CTX;
int result = ioctl(bs->fd, BINDER_SET_CONTEXT_MGR_EXT, &obj);
+#endif
+ int result = 1;
// fallback to original method
if (result != 0) {
android_errorWriteLog(0x534e4554, "121035042");
diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp
index cb0e08d12..5c53585e9 100644
--- a/libs/binder/Binder.cpp
+++ b/libs/binder/Binder.cpp
@@ -206,6 +206,7 @@ bool BBinder::isRequestingSid()
void BBinder::setRequestingSid(bool requestingSid)
{
+ requestingSid = false; // HACKED
Extras* e = mExtras.load(std::memory_order_acquire);
if (!e) {
diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp
index 63f49ddba..084f91a32 100644
--- a/libs/binder/ProcessState.cpp
+++ b/libs/binder/ProcessState.cpp
@@ -181,12 +181,15 @@ bool ProcessState::becomeContextManager(context_check_func checkFunc, void* user
mBinderContextCheckFunc = checkFunc;
mBinderContextUserData = userData;
+#if 0 // HACKED (?)
flat_binder_object obj {
.flags = FLAT_BINDER_FLAG_TXN_SECURITY_CTX,
};
status_t result = ioctl(mDriverFD, BINDER_SET_CONTEXT_MGR_EXT, &obj);
+#endif
+ status_t result = 1;
// fallback to original method
if (result != 0) {
android_errorWriteLog(0x534e4554, "121035042");
--
2.34.1

View File

@@ -0,0 +1,134 @@
From f34a4d3ad44221ab649b33aaaf3219a4fb3b156f Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Sun, 9 May 2021 23:27:12 +0800
Subject: [PATCH 1/7] fix booting
---
init/first_stage_init.cpp | 18 +++++++++++++++---
init/init.cpp | 2 +-
init/property_service.cpp | 0
init/service.cpp | 3 ++-
init/util.cpp | 3 ++-
rootdir/init.rc | 1 -
6 files changed, 20 insertions(+), 7 deletions(-)
mode change 100644 => 100755 init/init.cpp
mode change 100644 => 100755 init/property_service.cpp
diff --git a/init/first_stage_init.cpp b/init/first_stage_init.cpp
index 2b899408a..a09330cf7 100644
--- a/init/first_stage_init.cpp
+++ b/init/first_stage_init.cpp
@@ -33,6 +33,7 @@
#include <android-base/chrono_utils.h>
#include <android-base/file.h>
#include <android-base/logging.h>
+#include <android-base/strings.h>
#include <private/android_filesystem_config.h>
#include "debug_ramdisk.h"
@@ -120,6 +121,8 @@ int FirstStageMain(int argc, char** argv) {
CHECKCALL(mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755"));
CHECKCALL(mkdir("/dev/pts", 0755));
CHECKCALL(mkdir("/dev/socket", 0755));
+ mount("/system/etc", "/etc", "none", MS_BIND, NULL); // cgroup fix
+ unshare(CLONE_NEWCGROUP);
CHECKCALL(mount("devpts", "/dev/pts", "devpts", 0, NULL));
#define MAKE_STR(x) __STRING(x)
CHECKCALL(mount("proc", "/proc", "proc", 0, "hidepid=2,gid=" MAKE_STR(AID_READPROC)));
@@ -176,7 +179,6 @@ int FirstStageMain(int argc, char** argv) {
for (const auto& [error_string, error_errno] : errors) {
LOG(ERROR) << error_string << " " << strerror(error_errno);
}
- LOG(FATAL) << "Init encountered errors starting first stage, aborting";
}
LOG(INFO) << "init first stage started!";
@@ -236,8 +238,18 @@ int FirstStageMain(int argc, char** argv) {
setenv("INIT_STARTED_AT", std::to_string(start_ms).c_str(), 1);
const char* path = "/system/bin/init";
- const char* args[] = {path, "selinux_setup", nullptr};
- execv(path, const_cast<char**>(args));
+ std::vector<const char *> args = {path, "second_stage"};
+ std::string cmdline;
+ android::base::ReadFileToString("/proc/self/cmdline", &cmdline);
+ std::replace(cmdline.begin(), cmdline.end(), '\0', ' ');
+ auto cmd_vector = android::base::Split(android::base::Trim(cmdline), " ");
+ int i = 0;
+ for (const auto& entry : cmd_vector) {
+ if (i++ == 0) continue; // ignore first arg '/init'
+ args.push_back(entry.c_str());
+ }
+ args.push_back(nullptr);
+ execv(path, const_cast<char**>(args.data()));
// execv() only returns if an error happened, in which case we
// panic and never fall through this conditional.
diff --git a/init/init.cpp b/init/init.cpp
old mode 100644
new mode 100755
index 6b03bc94d..7d687ed52
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -653,7 +653,7 @@ int SecondStageMain(int argc, char** argv) {
// Make the time that init started available for bootstat to log.
property_set("ro.boottime.init", getenv("INIT_STARTED_AT"));
- property_set("ro.boottime.init.selinux", getenv("INIT_SELINUX_TOOK"));
+ property_set("ro.boottime.init.selinux", "0" /*getenv("INIT_SELINUX_TOOK")*/); // HACKED
// Set libavb version for Framework-only OTA match in Treble build.
const char* avb_version = getenv("INIT_AVB_VERSION");
diff --git a/init/property_service.cpp b/init/property_service.cpp
old mode 100644
new mode 100755
diff --git a/init/service.cpp b/init/service.cpp
index ccc37b70c..410310893 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -71,6 +71,7 @@ namespace android {
namespace init {
static Result<std::string> ComputeContextFromExecutable(const std::string& service_path) {
+ se_hack1("HACKED");
std::string computed_context;
char* raw_con = nullptr;
@@ -381,7 +382,7 @@ void Service::Reap(const siginfo_t& siginfo) {
if (++crash_count_ > 4) {
if (flags_ & SVC_CRITICAL) {
// Aborts into bootloader
- LOG(FATAL) << "critical process '" << name_ << "' exited 4 times "
+ LOG(ERROR) << "critical process '" << name_ << "' exited 4 times "
<< (boot_completed ? "in 4 minutes" : "before boot completed");
} else {
LOG(ERROR) << "updatable process '" << name_ << "' exited 4 times "
diff --git a/init/util.cpp b/init/util.cpp
index 63d2d4442..509f0998a 100644
--- a/init/util.cpp
+++ b/init/util.cpp
@@ -241,7 +241,8 @@ int wait_for_file(const char* filename, std::chrono::nanoseconds timeout) {
void import_kernel_cmdline(bool in_qemu,
const std::function<void(const std::string&, const std::string&, bool)>& fn) {
std::string cmdline;
- android::base::ReadFileToString("/proc/cmdline", &cmdline);
+ android::base::ReadFileToString("/proc/self/cmdline", &cmdline); // HACKED
+ std::replace(cmdline.begin(), cmdline.end(), '\0', ' '); // HACKED
for (const auto& entry : android::base::Split(android::base::Trim(cmdline), " ")) {
std::vector<std::string> pieces = android::base::Split(entry, "=");
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 893998cee..92c984ea3 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -354,7 +354,6 @@ on post-fs
# Once everything is setup, no need to modify /.
# The bind+remount combination allows this to work in containers.
- mount rootfs rootfs / remount bind ro nodev
# Mount default storage into root namespace
mount none /mnt/runtime/default /storage bind rec
mount none none /storage slave rec
--
2.34.1

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,25 @@
From de948c8d9ba86955f02e79666cf4ad019a954f3e Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Sun, 9 May 2021 23:29:12 +0800
Subject: [PATCH 3/7] allow override ro.* prop
---
init/init.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/init/init.cpp b/init/init.cpp
index 7d687ed52..661deac03 100755
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -378,6 +378,8 @@ static void import_kernel_nv(const std::string& key, const std::string& value, b
strlcpy(qemu, value.c_str(), sizeof(qemu));
} else if (android::base::StartsWith(key, "androidboot.")) {
property_set("ro.boot." + key.substr(12), value);
+ } else if (android::base::StartsWith(key, "ro.")) {
+ property_set(key, value);
}
}
--
2.34.1

View File

@@ -0,0 +1,26 @@
From db319d72fec643d918a9bdbc3c4636d418a75178 Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Fri, 25 Jun 2021 15:31:13 +0000
Subject: [PATCH 4/7] ignore input subsystem
---
rootdir/ueventd.rc | 3 ---
1 file changed, 3 deletions(-)
diff --git a/rootdir/ueventd.rc b/rootdir/ueventd.rc
index 451f5adf3..a6ad986af 100644
--- a/rootdir/ueventd.rc
+++ b/rootdir/ueventd.rc
@@ -9,9 +9,6 @@ subsystem drm
devname uevent_devpath
dirname /dev/dri
-subsystem input
- devname uevent_devpath
- dirname /dev/input
subsystem sound
devname uevent_devpath
--
2.34.1

View File

@@ -0,0 +1,32 @@
From 548cc1ca5b41507a1fb4babef74623cdfac6775b Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Sat, 26 Jun 2021 12:22:54 +0000
Subject: [PATCH 5/7] ignore powerctl
---
init/init.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/init/init.cpp b/init/init.cpp
index 661deac03..75107cf19 100755
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -180,6 +180,7 @@ void property_changed(const std::string& name, const std::string& value) {
// waiting on a property.
// In non-thermal-shutdown case, 'shutdown' trigger will be fired to let device specific
// commands to be executed.
+#if 0 // HACKED
if (name == "sys.powerctl") {
// Despite the above comment, we can't call HandlePowerctlMessage() in this function,
// because it modifies the contents of the action queue, which can cause the action queue
@@ -192,6 +193,7 @@ void property_changed(const std::string& name, const std::string& value) {
shutdown_command = value;
do_shutdown = true;
}
+#endif
if (property_triggers_enabled) ActionManager::GetInstance().QueuePropertyChange(name, value);
--
2.34.1

View File

@@ -0,0 +1,37 @@
From c24c8901a872cdef8fce2257105ffa74e876c09c Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Sun, 2 Jan 2022 16:40:35 +0800
Subject: [PATCH 6/7] skip coldboot
---
init/first_stage_init.cpp | 1 -
rootdir/init.rc | 1 +
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/init/first_stage_init.cpp b/init/first_stage_init.cpp
index a09330cf7..a669c29be 100644
--- a/init/first_stage_init.cpp
+++ b/init/first_stage_init.cpp
@@ -118,7 +118,6 @@ int FirstStageMain(int argc, char** argv) {
CHECKCALL(setenv("PATH", _PATH_DEFPATH, 1));
// Get the basic filesystem setup we need put together in the initramdisk
// on / and then we'll let the rc file figure out the rest.
- CHECKCALL(mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755"));
CHECKCALL(mkdir("/dev/pts", 0755));
CHECKCALL(mkdir("/dev/socket", 0755));
mount("/system/etc", "/etc", "none", MS_BIND, NULL); // cgroup fix
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 92c984ea3..9636ab761 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -32,6 +32,7 @@ on early-init
# cgroup for system_server and surfaceflinger
mkdir /dev/memcg/system 0550 system system
+ write /dev/.coldboot_done 1
start ueventd
# Run apexd-bootstrap so that APEXes that provide critical libraries
--
2.34.1

View File

@@ -0,0 +1,28 @@
From 7a3d9447f2c12e00b07acafacdabe798edf351eb Mon Sep 17 00:00:00 2001
From: John Tung <watchnight@163.com>
Date: Sun, 21 Aug 2022 11:22:48 +0800
Subject: [PATCH 7/7] fix cpu cgroup mount
---
libprocessgroup/setup/cgroup_map_write.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libprocessgroup/setup/cgroup_map_write.cpp b/libprocessgroup/setup/cgroup_map_write.cpp
index 17ea06e09..c25bf302a 100644
--- a/libprocessgroup/setup/cgroup_map_write.cpp
+++ b/libprocessgroup/setup/cgroup_map_write.cpp
@@ -217,6 +217,11 @@ static bool SetupCgroup(const CgroupDescriptor& descriptor) {
result = mount("none", controller->path(), "cgroup", MS_NODEV | MS_NOEXEC | MS_NOSUID,
controller->name());
}
+ if (result < 0 && (!strcmp(controller->name(), "cpu")
+ || !strcmp(controller->name(), "cpuacct"))) {
+ result = mount("none", controller->path(), "cgroup", MS_NODEV | MS_NOEXEC | MS_NOSUID,
+ "cpu,cpuacct");
+ }
}
if (result < 0) {
--
2.34.1

View File

@@ -0,0 +1,45 @@
From 1ea03793abc4de41cb2d46a4d30bdc616729534b Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Sun, 9 May 2021 23:44:12 +0800
Subject: [PATCH] fix booting
---
Binder.cpp | 1 +
ProcessState.cpp | 3 +++
2 files changed, 4 insertions(+)
diff --git a/Binder.cpp b/Binder.cpp
index 87bc143..ebadf3b 100644
--- a/Binder.cpp
+++ b/Binder.cpp
@@ -90,6 +90,7 @@ bool BHwBinder::isRequestingSid() {
}
void BHwBinder::setRequestingSid(bool requestingSid) {
+ requestingSid = false; // HACKED
Extras* e = mExtras.load(std::memory_order_acquire);
if (!e) {
diff --git a/ProcessState.cpp b/ProcessState.cpp
index 8a8b7cc..524865c 100644
--- a/ProcessState.cpp
+++ b/ProcessState.cpp
@@ -167,12 +167,15 @@ bool ProcessState::becomeContextManager(context_check_func checkFunc, void* user
mBinderContextCheckFunc = checkFunc;
mBinderContextUserData = userData;
+#if 0 // HACKED (?)
flat_binder_object obj {
.flags = FLAT_BINDER_FLAG_TXN_SECURITY_CTX,
};
status_t result = ioctl(mDriverFD, BINDER_SET_CONTEXT_MGR_EXT, &obj);
+#endif
+ status_t result = 1;
// fallback to original method
if (result != 0) {
android_errorWriteLog(0x534e4554, "121035042");
--
2.34.1

View File

@@ -0,0 +1,24 @@
From 6f2422baaf0bfae1269661bf0c8b541247f90f52 Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Sat, 15 Oct 2022 09:12:31 +0800
Subject: [PATCH] ignore compatibility check
---
VintfObject.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/VintfObject.cpp b/VintfObject.cpp
index 2badd18..705fd64 100644
--- a/VintfObject.cpp
+++ b/VintfObject.cpp
@@ -599,7 +599,6 @@ int32_t VintfObject::checkCompatibility(std::string* error, CheckFlags::Type fla
error->insert(0,
"Runtime info and framework compatibility matrix are incompatible: ");
}
- return INCOMPATIBLE;
}
}
--
2.34.1

View File

@@ -0,0 +1,24 @@
From fe30466e921daba99c1a600809ae009d48ca7f8d Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Mon, 26 Apr 2021 23:09:01 +0800
Subject: [PATCH] ? fix networking
---
server/IptablesRestoreController.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/server/IptablesRestoreController.cpp b/server/IptablesRestoreController.cpp
index 83391776..0acecbae 100644
--- a/server/IptablesRestoreController.cpp
+++ b/server/IptablesRestoreController.cpp
@@ -363,6 +363,7 @@ int IptablesRestoreController::execute(const IptablesTarget target, const std::s
if (target == V6 || target == V4V6) {
res |= sendCommand(IP6TABLES_PROCESS, command, output);
}
+ res = 0; // HACKED ?
return res;
}
--
2.34.1