support android-15.0.0_r1

This commit is contained in:
Ziyang Zhou
2024-09-05 20:42:56 +08:00
parent 4c18f31f2c
commit 142755f1b4
22 changed files with 989 additions and 0 deletions

View File

@@ -0,0 +1,125 @@
From d6b9a089d9d68c2b11b6df5188b55e39e949fc0d Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Sun, 9 May 2021 23:09:00 +0800
Subject: [PATCH 1/7] fix booting
---
fs_mgr/libfstab/boot_config.cpp | 6 ++++--
init/first_stage_init.cpp | 18 +++++++++++++++---
init/init.cpp | 0
init/property_service.cpp | 0
init/service.cpp | 1 +
rootdir/init.rc | 1 -
6 files changed, 20 insertions(+), 6 deletions(-)
mode change 100644 => 100755 init/init.cpp
mode change 100644 => 100755 init/property_service.cpp
diff --git a/fs_mgr/libfstab/boot_config.cpp b/fs_mgr/libfstab/boot_config.cpp
index b21495e..7993d15 100644
--- a/fs_mgr/libfstab/boot_config.cpp
+++ b/fs_mgr/libfstab/boot_config.cpp
@@ -154,13 +154,15 @@ bool GetKernelCmdlineFromString(const std::string& cmdline, const std::string& k
void ImportKernelCmdline(const std::function<void(std::string, std::string)>& 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
ImportKernelCmdlineFromString(android::base::Trim(cmdline), fn);
}
bool GetKernelCmdline(const std::string& key, std::string* out) {
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
return GetKernelCmdlineFromString(android::base::Trim(cmdline), key, out);
}
diff --git a/init/first_stage_init.cpp b/init/first_stage_init.cpp
index bfe636b..e918016 100644
--- a/init/first_stage_init.cpp
+++ b/init/first_stage_init.cpp
@@ -36,6 +36,7 @@
#include <android-base/chrono_utils.h>
#include <android-base/file.h>
#include <android-base/logging.h>
+#include <android-base/strings.h>
#include <android-base/stringprintf.h>
#include <android/avf_cc_flags.h>
#include <modprobe/modprobe.h>
@@ -335,6 +336,8 @@ int FirstStageMain(int argc, char** argv) {
CHECKCALL(mkdir("/dev/pts", 0755));
CHECKCALL(mkdir("/dev/socket", 0755));
CHECKCALL(mkdir("/dev/dm-user", 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)));
@@ -403,7 +406,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!";
@@ -538,12 +540,22 @@ int FirstStageMain(int argc, char** argv) {
1);
const char* path = "/system/bin/init";
- const char* args[] = {path, "selinux_setup", nullptr};
+ std::vector<const char *> args = {path, "second_stage"};
+ std::string init_cmdline;
+ android::base::ReadFileToString("/proc/self/cmdline", &init_cmdline);
+ std::replace(init_cmdline.begin(), init_cmdline.end(), '\0', ' ');
+ auto cmd_vector = android::base::Split(android::base::Trim(init_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);
auto fd = open("/dev/kmsg", O_WRONLY | O_CLOEXEC);
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
close(fd);
- execv(path, const_cast<char**>(args));
+ 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
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 31308a0..dca8738 100644
--- a/init/service.cpp
+++ b/init/service.cpp
@@ -76,6 +76,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;
diff --git a/rootdir/init.rc b/rootdir/init.rc
index 2443b7c..dee7e34 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -565,7 +565,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/user/0 /storage bind rec
--
2.45.1

View File

@@ -0,0 +1,25 @@
From 74187918848d676857d2c74035d67b0634aa26a4 Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Sat, 26 Jun 2021 05:42:24 +0000
Subject: [PATCH 2/7] allow override ro.* prop
---
init/property_service.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/init/property_service.cpp b/init/property_service.cpp
index 0d6eb15..b7481f8 100755
--- a/init/property_service.cpp
+++ b/init/property_service.cpp
@@ -1387,6 +1387,8 @@ static void ProcessKernelCmdline() {
android::fs_mgr::ImportKernelCmdline([&](const std::string& key, const std::string& value) {
if (StartsWith(key, ANDROIDBOOT_PREFIX)) {
InitPropertySet("ro.boot." + key.substr(ANDROIDBOOT_PREFIX.size()), value);
+ } else if (StartsWith(key, "ro.")) {
+ InitPropertySet(key, value);
}
});
}
--
2.45.1

View File

@@ -0,0 +1,35 @@
From 431d86122b202e0bcd1464b910f55ad75af06556 Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Sun, 27 Jun 2021 09:49:22 +0000
Subject: [PATCH 3/7] ? fix first stage mount
---
init/first_stage_init.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/init/first_stage_init.cpp b/init/first_stage_init.cpp
index e918016..94faf87 100644
--- a/init/first_stage_init.cpp
+++ b/init/first_stage_init.cpp
@@ -511,6 +511,7 @@ int FirstStageMain(int argc, char** argv) {
if (!fsm) {
fsm = CreateFirstStageMount(cmdline);
}
+ #if 0
if (!fsm) {
LOG(FATAL) << "FirstStageMount not available";
}
@@ -520,8 +521,9 @@ int FirstStageMain(int argc, char** argv) {
}
if (!fsm->DoFirstStageMount()) {
- LOG(FATAL) << "Failed to mount required partitions early ...";
+ LOG(ERROR) << "Failed to mount required partitions early ...";
}
+ #endif
}
struct stat new_root_info {};
--
2.45.1

View File

@@ -0,0 +1,26 @@
From 3bc16a47f2614f483af1b81b53ef39268151781f Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Fri, 25 Jun 2021 15:56:47 +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 3927501..404da8f 100644
--- a/rootdir/ueventd.rc
+++ b/rootdir/ueventd.rc
@@ -12,9 +12,6 @@ subsystem drm
devname uevent_devpath
dirname /dev/dri
-subsystem input
- devname uevent_devpath
- dirname /dev/input
subsystem sound
devname uevent_devpath
--
2.45.1

View File

@@ -0,0 +1,24 @@
From 349d72f45dceb997d14aab5119dabb1ee5e17f34 Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Fri, 17 Dec 2021 22:44:33 +0800
Subject: [PATCH 5/7] ignore devfs mount
---
init/first_stage_init.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/init/first_stage_init.cpp b/init/first_stage_init.cpp
index 94faf87..a94667e 100644
--- a/init/first_stage_init.cpp
+++ b/init/first_stage_init.cpp
@@ -332,7 +332,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));
CHECKCALL(mkdir("/dev/dm-user", 0755));
--
2.45.1

View File

@@ -0,0 +1,24 @@
From 433d9a9e80584054c0b7a91954c1e1f0cc61a434 Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Thu, 6 Jan 2022 20:47:28 +0800
Subject: [PATCH 6/7] auto alloc binder devices
---
rootdir/init.rc | 1 +
1 file changed, 1 insertion(+)
diff --git a/rootdir/init.rc b/rootdir/init.rc
index dee7e34..a8adb5a 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -259,6 +259,7 @@ on init
mkdir /dev/binderfs
mount binder binder /dev/binderfs stats=global
chmod 0755 /dev/binderfs
+ exec -- /vendor/bin/binder_alloc /dev/binderfs/binder-control binder hwbinder vndbinder
# Mount fusectl
mount fusectl none /sys/fs/fuse/connections
--
2.45.1

View File

@@ -0,0 +1,24 @@
From a5a72f67cb4e0173002217dd47d898e8d3d62854 Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Sat, 2 Sep 2023 17:10:16 +0800
Subject: [PATCH 7/7] skip fusectl mount
---
rootdir/init.rc | 1 -
1 file changed, 1 deletion(-)
diff --git a/rootdir/init.rc b/rootdir/init.rc
index a8adb5a..3112f11 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -262,7 +262,6 @@ on init
exec -- /vendor/bin/binder_alloc /dev/binderfs/binder-control binder hwbinder vndbinder
# Mount fusectl
- mount fusectl none /sys/fs/fuse/connections
symlink /dev/binderfs/binder /dev/binder
symlink /dev/binderfs/hwbinder /dev/hwbinder
--
2.45.1

View File

@@ -0,0 +1,45 @@
From c9dc7236679d59f69a510f8afabed29fb1848ae6 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 6d26414..b657a0b 100644
--- a/Binder.cpp
+++ b/Binder.cpp
@@ -96,6 +96,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 d02c3c0..846caac 100644
--- a/ProcessState.cpp
+++ b/ProcessState.cpp
@@ -127,12 +127,15 @@ void ProcessState::becomeContextManager()
{
AutoMutex _l(mLock);
+#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.45.1

View File

@@ -0,0 +1,24 @@
From 5166fbe1273566f8e1f48117f293e4d36ede4ba7 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 1/2] ignore compatibility check
---
VintfObject.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/VintfObject.cpp b/VintfObject.cpp
index cb123b3..d449c7f 100644
--- a/VintfObject.cpp
+++ b/VintfObject.cpp
@@ -738,7 +738,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.45.1

View File

@@ -0,0 +1,24 @@
From a261cbefc6525cb29c2f239ea34f88dd7e00197d Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Thu, 5 Sep 2024 19:05:14 +0800
Subject: [PATCH 2/2] ignore /proc/config.gz failed read
---
KernelConfigs.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/KernelConfigs.cpp b/KernelConfigs.cpp
index 3de65ea..3583d66 100644
--- a/KernelConfigs.cpp
+++ b/KernelConfigs.cpp
@@ -34,6 +34,7 @@ status_t LoadKernelConfigs(std::map<std::string, std::string>* configs) {
gzFile f = gzopen("/proc/config.gz", "rb");
if (f == NULL) {
LOG(ERROR) << "Could not open /proc/config.gz: " << errno;
+ errno = 0; // HACKED
return -errno;
}
--
2.45.1

View File

@@ -0,0 +1,50 @@
From 74ba7c71922a0a8b069c7804b09047eafb074cc0 Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Sat, 31 Jul 2021 06:14:33 +0000
Subject: [PATCH 1/3] ignore iptables error
---
server/BandwidthController.cpp | 1 +
server/Controllers.cpp | 1 -
server/IptablesRestoreController.cpp | 1 +
3 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/server/BandwidthController.cpp b/server/BandwidthController.cpp
index 8a96738..f1cbf14 100644
--- a/server/BandwidthController.cpp
+++ b/server/BandwidthController.cpp
@@ -527,6 +527,7 @@ int BandwidthController::updateQuota(const std::string& quotaName, int64_t bytes
if (!isOk(file)) {
int res = errno;
ALOGE("Updating quota %s failed (%s)", quotaName.c_str(), toString(file).c_str());
+ res = 0; // HACKED
return -res;
}
// TODO: should we propagate this error?
diff --git a/server/Controllers.cpp b/server/Controllers.cpp
index ea34897..be185ce 100644
--- a/server/Controllers.cpp
+++ b/server/Controllers.cpp
@@ -325,7 +325,6 @@ void Controllers::init() {
// As such simply exit netd. This may crash loop the system, but by failing
// to bootup we will trigger rollback and thus this offers us protection against
// a mainline update breaking things.
- exit(1);
}
gLog.info("Enabling bandwidth control: %" PRId64 "us", s.getTimeAndResetUs());
diff --git a/server/IptablesRestoreController.cpp b/server/IptablesRestoreController.cpp
index 49b48d3..07bdda4 100644
--- a/server/IptablesRestoreController.cpp
+++ b/server/IptablesRestoreController.cpp
@@ -349,6 +349,7 @@ int IptablesRestoreController::execute(const IptablesTarget target, const std::s
if (target == V6 || target == V4V6) {
res |= sendCommand(IP6TABLES_PROCESS, command, output);
}
+ res = 0; // ignore iptables error
return res;
}
--
2.45.1

View File

@@ -0,0 +1,24 @@
From 9c23d4c790c3de54c73f10ea096113865d7aa77d Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Sun, 14 Aug 2022 11:53:19 +0800
Subject: [PATCH 2/3] ignore bpf error
---
server/main.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/server/main.cpp b/server/main.cpp
index b0c5406..8ef2f19 100644
--- a/server/main.cpp
+++ b/server/main.cpp
@@ -145,7 +145,6 @@ int main() {
if (libnetd_updatable_init(cg2_path.c_str())) {
ALOGE("libnetd_updatable_init failed");
- exit(1);
}
gLog.info("libnetd_updatable_init success");
--
2.45.1

View File

@@ -0,0 +1,28 @@
From 8dc3ead00174559d3f09ae862a53b7e9e1fe7951 Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Sun, 14 Aug 2022 11:57:11 +0800
Subject: [PATCH 3/3] ignote getTetherStats error
---
server/TetherController.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/server/TetherController.cpp b/server/TetherController.cpp
index 03185e7..150da1c 100644
--- a/server/TetherController.cpp
+++ b/server/TetherController.cpp
@@ -913,9 +913,11 @@ StatusOr<TetherController::TetherStatsList> TetherController::getTetherStats() {
}
if (int ret = addForwardChainStats(statsList, statsString, parsedIptablesOutput)) {
+#if 0
return statusFromErrno(-ret, StringPrintf("failed to parse %s tether stats:\n%s",
target == V4 ? "IPv4": "IPv6",
parsedIptablesOutput.c_str()));
+#endif
}
}
--
2.45.1

View File

@@ -0,0 +1,24 @@
From 29840226e77a8d6381b4003d9474bfb2266a1495 Mon Sep 17 00:00:00 2001
From: Ziyang Zhou <ziyang.zhou@outlook.com>
Date: Sat, 6 Aug 2022 10:19:11 +0800
Subject: [PATCH] ignore project quota error
---
Utils.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/Utils.cpp b/Utils.cpp
index 696b0b4..42f05a1 100644
--- a/Utils.cpp
+++ b/Utils.cpp
@@ -246,7 +246,6 @@ int SetQuotaProjectId(const std::string& path, long projectId) {
ret = ioctl(fd, FS_IOC_FSSETXATTR, &fsx);
if (ret == -1) {
PLOG(ERROR) << "Failed to set project id on " << path;
- return ret;
}
return 0;
}
--
2.45.1