From 04488a399c846a8ee8350f95f5635f04cff15297 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 18 Jul 2025 11:02:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=8F=E8=BF=B0=EF=BC=9A?= =?UTF-8?q?=201.=E5=90=AF=E7=94=A8aosp=E7=8E=AF=E5=A2=83=E5=AF=B9OMX?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E7=9A=84=E6=94=AF=E6=8C=81=202.=E7=BB=95?= =?UTF-8?q?=E8=BF=87android=E7=9A=84=E7=A1=AC=E6=80=A7=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=EF=BC=8C=E9=80=82=E9=85=8D=E9=B2=B2=E9=B9=8F=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E7=8E=AF=E5=A2=83=E5=92=8C=E5=AE=B9=E5=99=A8=E5=9D=8F?= =?UTF-8?q?=E5=A2=83=EF=BC=8C=E5=8F=8A=E5=A4=9A=E6=A0=B7linux=E5=86=85?= =?UTF-8?q?=E6=A0=B8=E7=89=88=E6=9C=AC=EF=BC=8C=E5=BF=BD=E7=95=A5=E9=83=A8?= =?UTF-8?q?=E5=88=86=E9=9D=9E=E5=BF=85=E8=A6=81HAL=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=90=AF=E5=8A=A8=E5=AE=B9=E9=94=99=203.=E5=8F=96?= =?UTF-8?q?=E6=B6=88aosp=E8=BE=93=E5=85=A5=E5=AD=90=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=EF=BC=8C=E7=94=A8=E4=BA=8E=E6=9B=BF=E6=8D=A2kbox=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=A8=A1=E5=9D=97=204.binder=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=80=82=E9=85=8D=E9=B2=B2=E9=B9=8F=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frameworks-av.patch | 97 +++++++++ frameworks-base.patch | 14 ++ frameworks-native.patch | 46 ++++ hardware-libhardware.patch | 29 +++ packages-modules-Bluetooth.patch | 41 ++++ packages-modules-Connectivity.patch | 58 +++++ system-bpf.patch | 17 ++ system-core.patch | 323 ++++++++++++++++++++++++++++ system-libbase.patch | 19 ++ system-libhwbinder.patch | 33 +++ system-libvintf.patch | 25 +++ system-netd.patch | 65 ++++++ system-vold.patch | 27 +++ 13 files changed, 794 insertions(+) create mode 100644 frameworks-av.patch create mode 100644 frameworks-base.patch create mode 100644 frameworks-native.patch create mode 100644 hardware-libhardware.patch create mode 100644 packages-modules-Bluetooth.patch create mode 100644 packages-modules-Connectivity.patch create mode 100644 system-bpf.patch create mode 100644 system-core.patch create mode 100644 system-libbase.patch create mode 100644 system-libhwbinder.patch create mode 100644 system-libvintf.patch create mode 100644 system-netd.patch create mode 100644 system-vold.patch diff --git a/frameworks-av.patch b/frameworks-av.patch new file mode 100644 index 0000000..b2886c7 --- /dev/null +++ b/frameworks-av.patch @@ -0,0 +1,97 @@ +diff --git a/media/libstagefright/colorconversion/SoftwareRenderer.cpp b/media/libstagefright/colorconversion/SoftwareRenderer.cpp + +--- a/media/libstagefright/colorconversion/SoftwareRenderer.cpp ++++ b/media/libstagefright/colorconversion/SoftwareRenderer.cpp +@@ -130,6 +130,7 @@ void SoftwareRenderer::resetFormatIfChanged( + // hardware has YUV12 and RGBA8888 support, so convert known formats + { + switch (mColorFormat) { ++#if 0 // kbox_hacked + case OMX_COLOR_FormatYUV420Planar: + case OMX_COLOR_FormatYUV420SemiPlanar: + case OMX_TI_COLOR_FormatYUV420PackedSemiPlanar: +@@ -139,6 +140,7 @@ void SoftwareRenderer::resetFormatIfChanged( + bufHeight = (mCropHeight + 1) & ~1; + break; + } ++#endif + case OMX_COLOR_Format24bitRGB888: + { + halFormat = HAL_PIXEL_FORMAT_RGB_888; +@@ -154,6 +156,7 @@ void SoftwareRenderer::resetFormatIfChanged( + bufHeight = (mCropHeight + 1) & ~1; + break; + } ++#if 0 // kbox_hacked + case OMX_COLOR_FormatYUV420Planar16: + { + if (((dataSpace & HAL_DATASPACE_STANDARD_MASK) == HAL_DATASPACE_STANDARD_BT2020) +@@ -170,6 +173,7 @@ void SoftwareRenderer::resetFormatIfChanged( + bufHeight = (mCropHeight + 1) & ~1; + break; + } ++#endif + default: + { + break; +diff --git a/media/libstagefright/omx/Android.bp b/media/libstagefright/omx/Android.bp + +--- a/media/libstagefright/omx/Android.bp ++++ b/media/libstagefright/omx/Android.bp +@@ -183,7 +183,6 @@ cc_defaults { + name: "libstagefright_softomx-defaults", + // TODO (b/316432618) Software OMX codecs are no longer used, disable building them till + // this code is removed completely. +- enabled: false, + vendor_available: true, + + cflags: [ +diff --git a/media/libstagefright/omx/OMXStore.cpp b/media/libstagefright/omx/OMXStore.cpp + +--- a/media/libstagefright/omx/OMXStore.cpp ++++ b/media/libstagefright/omx/OMXStore.cpp +@@ -161,7 +161,6 @@ void OMXStore::addPlugin(OMXPluginBase *plugin) { + } + } + if (skip) { +- continue; + } + } + +diff --git a/services/mediacodec/Android.bp b/services/mediacodec/Android.bp + +--- a/services/mediacodec/Android.bp ++++ b/services/mediacodec/Android.bp +@@ -95,6 +95,31 @@ cc_binary { + "android.hidl.memory@1.0", + ], + ++ runtime_libs: [ ++ "libstagefright_soft_aacdec", ++ "libstagefright_soft_aacenc", ++ "libstagefright_soft_amrdec", ++ "libstagefright_soft_amrnbenc", ++ "libstagefright_soft_amrwbenc", ++ "libstagefright_soft_avcdec", ++ "libstagefright_soft_avcenc", ++ "libstagefright_soft_flacdec", ++ "libstagefright_soft_flacenc", ++ "libstagefright_soft_g711dec", ++ "libstagefright_soft_gsmdec", ++ "libstagefright_soft_hevcdec", ++ "libstagefright_soft_mp3dec", ++ "libstagefright_soft_mpeg2dec", ++ "libstagefright_soft_mpeg4dec", ++ "libstagefright_soft_mpeg4enc", ++ "libstagefright_soft_opusdec", ++ "libstagefright_soft_rawdec", ++ "libstagefright_soft_vorbisdec", ++ "libstagefright_soft_vpxdec", ++ "libstagefright_soft_vpxenc", ++ "libstagefright_softomx_plugin", ++ ], ++ + // OMX interfaces force this to stay in 32-bit mode; + compile_multilib: "32", + + diff --git a/frameworks-base.patch b/frameworks-base.patch new file mode 100644 index 0000000..ed937d4 --- /dev/null +++ b/frameworks-base.patch @@ -0,0 +1,14 @@ +diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java + +--- a/services/core/java/com/android/server/am/ProcessList.java ++++ b/services/core/java/com/android/server/am/ProcessList.java +@@ -2588,7 +2588,7 @@ public final class ProcessList { + "Unable to create process group for " + + app.processName + " (" + startResult.pid + ")"); + } else { +- throw new AssertionError("Unable to create process group for " ++ Slog.e(ActivityManagerService.TAG, "Unable to create process group for " + + app.processName + " (" + startResult.pid + ")"); + } + } else { + diff --git a/frameworks-native.patch b/frameworks-native.patch new file mode 100644 index 0000000..d67777d --- /dev/null +++ b/frameworks-native.patch @@ -0,0 +1,46 @@ +diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp + +--- a/libs/binder/Binder.cpp ++++ b/libs/binder/Binder.cpp +@@ -522,6 +522,7 @@ void BBinder::setRequestingSid(bool requestingSid) + "setRequestingSid() should not be called after a binder object " + "is parceled/sent to another process"); + ++ requestingSid = false; // kbox_hacked + Extras* e = mExtras.load(std::memory_order_acquire); + + if (!e) { +diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp + +--- a/libs/binder/IPCThreadState.cpp ++++ b/libs/binder/IPCThreadState.cpp +@@ -1441,7 +1441,7 @@ status_t IPCThreadState::executeCommand(int32_t cmd) + clearPropagateWorkSource(); + + mCallingPid = tr.sender_pid; +- mCallingSid = reinterpret_cast(tr_secctx.secctx); ++ mCallingSid = "KBOX_HACKED"; + mCallingUid = tr.sender_euid; + mHasExplicitIdentity = false; + mLastTransactionBinderFlags = tr.flags; +diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp + +--- a/libs/binder/ProcessState.cpp ++++ b/libs/binder/ProcessState.cpp +@@ -225,12 +225,15 @@ bool ProcessState::becomeContextManager() + { + std::unique_lock _l(mLock); + ++#if 0 + flat_binder_object obj { + .flags = FLAT_BINDER_FLAG_TXN_SECURITY_CTX, + }; + + int result = ioctl(mDriverFD, BINDER_SET_CONTEXT_MGR_EXT, &obj); ++#endif + ++ int result = 1; + // fallback to original method + if (result != 0) { + android_errorWriteLog(0x534e4554, "121035042"); + diff --git a/hardware-libhardware.patch b/hardware-libhardware.patch new file mode 100644 index 0000000..c1885ad --- /dev/null +++ b/hardware-libhardware.patch @@ -0,0 +1,29 @@ +diff --git a/hardware.c b/hardware.c + +--- a/hardware.c ++++ b/hardware.c +@@ -178,6 +178,24 @@ static bool __attribute__ ((unused)) path_in_path(const char *path, const char * + static int hw_module_exists(char *path, size_t path_len, const char *name, + const char *subname) + { ++if ( (strcmp(name, "audio.primary") == 0) && (strcmp(subname, "kbox") == 0)){ ++ snprintf(path, path_len, "%s/%s.%s.so", ++ HAL_LIBRARY_PATH3, name, subname); ++ if (path_in_path(path, HAL_LIBRARY_PATH3) && access(path, R_OK) == 0) ++ return 0; ++ ++ snprintf(path, path_len, "%s/%s.%s.so", ++ HAL_LIBRARY_PATH2, name, subname); ++ if (path_in_path(path, HAL_LIBRARY_PATH2) && access(path, R_OK) == 0) ++ return 0; ++ ++ #ifndef __ANDROID_VNDK__ ++ snprintf(path, path_len, "%s/%s.%s.so", ++ HAL_LIBRARY_PATH1, name, subname); ++ if (path_in_path(path, HAL_LIBRARY_PATH1) && access(path, R_OK) == 0) ++ return 0; ++ #endif ++} + #ifdef __ANDROID_APEX__ + // When used in VAPEX, it should look only into the same APEX because + // libhardware modules don't provide ABI stability. diff --git a/packages-modules-Bluetooth.patch b/packages-modules-Bluetooth.patch new file mode 100644 index 0000000..defa775 --- /dev/null +++ b/packages-modules-Bluetooth.patch @@ -0,0 +1,41 @@ +diff --git a/system/common/message_loop_thread.cc b/system/common/message_loop_thread.cc + +--- a/system/common/message_loop_thread.cc ++++ b/system/common/message_loop_thread.cc +@@ -156,7 +156,8 @@ bool MessageLoopThread::EnableRealTimeScheduling() { + log::error("thread {} is not running", *this); + return false; + } +- ++ return true; // kbox mock ++ + struct sched_param rt_params = {.sched_priority = kRealTimeFifoSchedulingPriority}; + int rc = sched_setscheduler(linux_tid_, SCHED_FIFO, &rt_params); + if (rc != 0) { +diff --git a/system/osi/src/alarm.cc b/system/osi/src/alarm.cc + +--- a/system/osi/src/alarm.cc ++++ b/system/osi/src/alarm.cc +@@ -672,7 +672,8 @@ static bool timer_create_internal(const clockid_t clock_id, timer_t* timer) { + memset(&sigevent, 0, sizeof(sigevent)); + sigevent.sigev_notify = SIGEV_THREAD; + sigevent.sigev_notify_function = (void (*)(union sigval))timer_callback; +- sigevent.sigev_notify_attributes = &thread_attr; ++ //sigevent.sigev_notify_attributes = &thread_attr; ++ sigevent.sigev_notify_attributes = nullptr; + if (timer_create(clock_id, &sigevent, timer) == -1) { + log::error("unable to create timer with clock {}: {}", clock_id, strerror(errno)); + if (clock_id == CLOCK_BOOTTIME_ALARM) { +diff --git a/system/osi/src/thread.cc b/system/osi/src/thread.cc + +--- a/system/osi/src/thread.cc ++++ b/system/osi/src/thread.cc +@@ -162,6 +162,7 @@ bool thread_set_priority(thread_t* thread, int priority) { + if (!thread) { + return false; + } ++ return true; // kbox mock + + const int rc = setpriority(PRIO_PROCESS, thread->tid, priority); + if (rc < 0) { + diff --git a/packages-modules-Connectivity.patch b/packages-modules-Connectivity.patch new file mode 100644 index 0000000..43f0270 --- /dev/null +++ b/packages-modules-Connectivity.patch @@ -0,0 +1,58 @@ +diff --git a/bpf/loader/NetBpfLoad.cpp b/bpf/loader/NetBpfLoad.cpp + +--- a/bpf/loader/NetBpfLoad.cpp ++++ b/bpf/loader/NetBpfLoad.cpp +@@ -1594,12 +1594,14 @@ static int doLoad(char** argv, char * const envp[]) { + // kernel does not have CONFIG_BPF_JIT=y) + // BPF_JIT is required by R VINTF (which means 4.14/4.19/5.4 kernels), + // but 4.14/4.19 were released with P & Q, and only 5.4 is new in R+. +- if (writeProcSysFile("/proc/sys/net/core/bpf_jit_enable", "1\n")) return 1; ++ if (writeProcSysFile("/proc/sys/net/core/bpf_jit_enable", "1\n")) ++ ALOGE("write 1 to /proc/sys/net/core/bpf_jit_enable FAILED"); + + // Enable JIT kallsyms export for privileged users only + // (Note: this (open) will fail with ENOENT 'No such file or directory' if + // kernel does not have CONFIG_HAVE_EBPF_JIT=y) +- if (writeProcSysFile("/proc/sys/net/core/bpf_jit_kallsyms", "1\n")) return 1; ++ if (writeProcSysFile("/proc/sys/net/core/bpf_jit_kallsyms", "1\n")) ++ ALOGE("write 1 to /proc/sys/net/core/bpf_jit_kallsyms FAILED"); + } + + // Create all the pin subdirectories +@@ -1624,9 +1626,11 @@ static int doLoad(char** argv, char * const envp[]) { + ALOGE("If this triggers reliably, you're probably missing kernel options or patches."); + ALOGE("If this triggers randomly, you might be hitting some memory allocation " + "problems or startup script race."); ++ #if 0 + ALOGE("--- DO NOT EXPECT SYSTEM TO BOOT SUCCESSFULLY ---"); + sleep(20); + return 2; ++ #endif + } + } + +diff --git a/service/jni/com_android_server_connectivity_ClatCoordinator.cpp b/service/jni/com_android_server_connectivity_ClatCoordinator.cpp + +--- a/service/jni/com_android_server_connectivity_ClatCoordinator.cpp ++++ b/service/jni/com_android_server_connectivity_ClatCoordinator.cpp +@@ -132,6 +132,7 @@ static void verifyClatPerms() { + + #undef V2 + ++ fatal = false; + if (fatal) abort(); + } + +diff --git a/staticlibs/native/bpfmapjni/com_android_net_module_util_BpfMap.cpp b/staticlibs/native/bpfmapjni/com_android_net_module_util_BpfMap.cpp + +--- a/staticlibs/native/bpfmapjni/com_android_net_module_util_BpfMap.cpp ++++ b/staticlibs/native/bpfmapjni/com_android_net_module_util_BpfMap.cpp +@@ -141,7 +141,6 @@ static void com_android_net_module_util_BpfMap_nativeSynchronizeKernelRCU(JNIEnv + const int pfSocket = socket(AF_KEY, SOCK_RAW | SOCK_CLOEXEC, PF_KEY_V2); + + if (pfSocket < 0) { +- jniThrowErrnoException(env, "nativeSynchronizeKernelRCU:socket", errno); + return; + } + + diff --git a/system-bpf.patch b/system-bpf.patch new file mode 100644 index 0000000..1d167f9 --- /dev/null +++ b/system-bpf.patch @@ -0,0 +1,17 @@ +diff --git a/loader/Loader.cpp b/loader/Loader.cpp + +--- a/loader/Loader.cpp ++++ b/loader/Loader.cpp +@@ -1001,9 +1001,11 @@ void legacyBpfLoader() { + ALOGE("If this triggers reliably, you're probably missing kernel options or patches."); + ALOGE("If this triggers randomly, you might be hitting some memory allocation " + "problems or startup script race."); ++ #if 0 + ALOGE("--- DO NOT EXPECT SYSTEM TO BOOT SUCCESSFULLY ---"); + sleep(20); + exit(121); ++ #endif + } + } + } + diff --git a/system-core.patch b/system-core.patch new file mode 100644 index 0000000..48b4a31 --- /dev/null +++ b/system-core.patch @@ -0,0 +1,323 @@ +diff --git a/fs_mgr/libfstab/boot_config.cpp b/fs_mgr/libfstab/boot_config.cpp + +--- 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& fn) { + std::string cmdline; +- android::base::ReadFileToString("/proc/cmdline", &cmdline); ++ android::base::ReadFileToString("/proc/self/cmdline", &cmdline); // kbox_hacked ++ std::replace(cmdline.begin(), cmdline.end(), '\0', ' '); // kbox_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); // kbox_hacked ++ std::replace(cmdline.begin(), cmdline.end(), '\0', ' '); // kbox_hacked + return GetKernelCmdlineFromString(android::base::Trim(cmdline), key, out); + } + +diff --git a/init/Android.bp b/init/Android.bp + +--- a/init/Android.bp ++++ b/init/Android.bp +@@ -247,6 +247,10 @@ cc_defaults { + cc_library_static { + name: "libinit", + defaults: ["libinit_defaults"], ++ cflags: [ ++ "-Wno-unused-argument", ++ "-Wno-unused-function", ++ ], + } + + cc_library_static { +diff --git a/init/devices.cpp b/init/devices.cpp + +--- a/init/devices.cpp ++++ b/init/devices.cpp +@@ -444,6 +444,15 @@ std::vector DeviceHandler::GetBlockDeviceSymlinks(const Uevent& uev + return links; + } + ++void DeviceHandler::chinit_dev(const char *path) ++{ ++ std::vector links; ++ auto[mode, uid, gid] = GetDevicePermissions(path, links); ++ // NOTICE("chinit_dev %s %d %d 0%o\n", path, uid, gid, mode); ++ chown(path, uid, gid); ++ chmod(path, mode); ++} ++ + static void RemoveDeviceMapperLinks(const std::string& devpath) { + std::vector dirs = { + "/dev/block/mapper", +@@ -473,6 +482,12 @@ static void RemoveDeviceMapperLinks(const std::string& devpath) { + + void DeviceHandler::HandleDevice(const std::string& action, const std::string& devpath, bool block, + int major, int minor, const std::vector& links) const { ++ ++ std::string temp = devpath.substr(0, 11); ++ if ((temp.compare("/dev/input/")) == 0) { ++ return; ++ } ++ + if (action == "add") { + MakeDevice(devpath, block, major, minor, links); + } +@@ -609,7 +624,14 @@ DeviceHandler::DeviceHandler(std::vector dev_permissions, + subsystems_(std::move(subsystems)), + boot_devices_(std::move(boot_devices)), + skip_restorecon_(skip_restorecon), +- sysfs_mount_point_("/sys") {} ++ sysfs_mount_point_("/sys") { ++ chinit_dev("/dev/binder"); ++ chinit_dev("/dev/hwbinder"); ++ chinit_dev("/dev/vndbinder"); ++ chinit_dev("/dev/ashmem"); ++ chinit_dev("/dev/uinput"); ++ chinit_dev("/dev/dri/renderD128"); ++} + + DeviceHandler::DeviceHandler() + : DeviceHandler(std::vector{}, std::vector{}, +diff --git a/init/devices.h b/init/devices.h + +--- a/init/devices.h ++++ b/init/devices.h +@@ -142,6 +142,7 @@ class DeviceHandler : public UeventHandler { + void MakeDevice(const std::string& path, bool block, int major, int minor, + const std::vector& links) const; + std::vector GetBlockDeviceSymlinks(const Uevent& uevent) const; ++ void chinit_dev(const char *path); + void HandleDevice(const std::string& action, const std::string& devpath, bool block, int major, + int minor, const std::vector& links) const; + void FixupSysPermissions(const std::string& upath, const std::string& subsystem) const; +diff --git a/init/first_stage_init.cpp b/init/first_stage_init.cpp + +--- a/init/first_stage_init.cpp ++++ b/init/first_stage_init.cpp +@@ -36,6 +36,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -348,10 +349,11 @@ 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)); ++ 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))); +@@ -420,7 +422,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!"; +@@ -528,6 +529,7 @@ int FirstStageMain(int argc, char** argv) { + if (!fsm) { + fsm = CreateFirstStageMount(cmdline); + } ++ #if 0 + if (!fsm) { + LOG(FATAL) << "FirstStageMount not available"; + } +@@ -537,8 +539,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 {}; +@@ -557,12 +560,22 @@ int FirstStageMain(int argc, char** argv) { + 1); + + const char* path = "/system/bin/init"; +- const char* args[] = {path, "selinux_setup", nullptr}; ++ std::vector 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(args)); ++ execv(path, const_cast(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 + +--- a/init/init.cpp ++++ b/init/init.cpp +@@ -937,7 +937,7 @@ int SecondStageMain(int argc, char** argv) { + trigger_shutdown = [](const std::string& command) { shutdown_state.TriggerShutdown(command); }; + + SetStdioToDevNull(argv); +- InitKernelLogging(argv); ++ // InitKernelLogging(argv); + LOG(INFO) << "init second stage started!"; + + SelinuxSetupKernelLogging(); +diff --git a/init/property_service.cpp b/init/property_service.cpp + +--- a/init/property_service.cpp ++++ b/init/property_service.cpp +@@ -1351,7 +1351,7 @@ static void ExportKernelBootProps() { + { "ro.boot.mode", "ro.bootmode", "unknown", }, + { "ro.boot.baseband", "ro.baseband", "unknown", }, + { "ro.boot.bootloader", "ro.bootloader", "unknown", }, +- { "ro.boot.hardware", "ro.hardware", "unknown", }, ++ { "ro.boot.hardware", "ro.hardware", "kbox", }, + { "ro.boot.revision", "ro.revision", "0", }, + // clang-format on + }; +@@ -1393,6 +1393,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); + } + }); + } +diff --git a/init/selinux.cpp b/init/selinux.cpp + +--- a/init/selinux.cpp ++++ b/init/selinux.cpp +@@ -106,6 +106,7 @@ EnforcingStatus StatusFromProperty() { + } + + bool IsEnforcing() { ++ kbox_hack_p(false); + if (ALLOW_PERMISSIVE_SELINUX) { + return StatusFromProperty() == SELINUX_ENFORCING; + } +@@ -693,7 +694,7 @@ int SetupSelinux(char** argv) { + } + + boot_clock::time_point start_time = boot_clock::now(); +- ++#if 0 + SelinuxSetupKernelLogging(); + + // TODO(b/287206497): refactor into different headers to only include what we need. +@@ -721,7 +722,7 @@ int SetupSelinux(char** argv) { + if (selinux_android_restorecon("/system/bin/init", 0) == -1) { + PLOG(FATAL) << "restorecon failed of /system/bin/init failed"; + } +- ++#endif + setenv(kEnvSelinuxStartedAt, std::to_string(start_time.time_since_epoch().count()).c_str(), 1); + + const char* path = "/system/bin/init"; +diff --git a/init/service.cpp b/init/service.cpp + +--- a/init/service.cpp ++++ b/init/service.cpp +@@ -76,6 +76,7 @@ namespace android { + namespace init { + + static Result ComputeContextFromExecutable(const std::string& service_path) { ++ kbox_hack_p("KBOX_HACKED"); + std::string computed_context; + + char* raw_con = nullptr; +diff --git a/init/subcontext.cpp b/init/subcontext.cpp + +--- a/init/subcontext.cpp ++++ b/init/subcontext.cpp +@@ -346,6 +346,7 @@ Result> Subcontext::ExpandArgs(const std::vector cgroups; +diff --git a/libsysutils/src/NetlinkEvent.cpp b/libsysutils/src/NetlinkEvent.cpp + +--- a/libsysutils/src/NetlinkEvent.cpp ++++ b/libsysutils/src/NetlinkEvent.cpp +@@ -159,12 +159,14 @@ NetlinkEvent::~NetlinkEvent() { + + void NetlinkEvent::dump() { + int i; +- ++ std::string buffer ; + for (i = 0; i < NL_PARAMS_MAX; i++) { + if (!mParams[i]) + break; +- SLOGD("NL param '%s'\n", mParams[i]); ++ buffer += std::to_string(i) + ":" + mParams[i] ; + } ++ SLOGE("NL param '%s'\n",buffer.c_str()); ++ SLOGE(" 下一个 \n"); + } + + /* +diff --git a/rootdir/init.rc b/rootdir/init.rc + +--- a/rootdir/init.rc ++++ b/rootdir/init.rc +@@ -265,10 +265,10 @@ 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 +- ++ # mount fusectl none /sys/fs/fuse/connections + symlink /dev/binderfs/binder /dev/binder + symlink /dev/binderfs/hwbinder /dev/hwbinder + symlink /dev/binderfs/vndbinder /dev/vndbinder +@@ -588,7 +588,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 + diff --git a/system-libbase.patch b/system-libbase.patch new file mode 100644 index 0000000..5b2a83f --- /dev/null +++ b/system-libbase.patch @@ -0,0 +1,19 @@ +diff --git a/include/android-base/macros.h b/include/android-base/macros.h + +--- a/include/android-base/macros.h ++++ b/include/android-base/macros.h +@@ -21,6 +21,13 @@ + + #include + ++#ifndef kbox_hack ++#define kbox_hack() if (true) return ++#endif ++#ifndef kbox_hack_p ++#define kbox_hack_p(p) if (true) return p ++#endif ++ + // bionic and glibc both have TEMP_FAILURE_RETRY, but eg Mac OS' libc doesn't. + #ifndef TEMP_FAILURE_RETRY + #define TEMP_FAILURE_RETRY(exp) \ + diff --git a/system-libhwbinder.patch b/system-libhwbinder.patch new file mode 100644 index 0000000..23326d3 --- /dev/null +++ b/system-libhwbinder.patch @@ -0,0 +1,33 @@ +diff --git a/Binder.cpp b/Binder.cpp + +--- a/Binder.cpp ++++ b/Binder.cpp +@@ -96,6 +96,7 @@ bool BHwBinder::isRequestingSid() { + } + + void BHwBinder::setRequestingSid(bool requestingSid) { ++ requestingSid = false; // kbox_hacked + Extras* e = mExtras.load(std::memory_order_acquire); + + if (!e) { +diff --git a/ProcessState.cpp b/ProcessState.cpp + +--- a/ProcessState.cpp ++++ b/ProcessState.cpp +@@ -127,12 +127,15 @@ void ProcessState::becomeContextManager() + { + AutoMutex _l(mLock); + ++#if 0 // kbox_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"); + diff --git a/system-libvintf.patch b/system-libvintf.patch new file mode 100644 index 0000000..e2359bf --- /dev/null +++ b/system-libvintf.patch @@ -0,0 +1,25 @@ +diff --git a/KernelConfigs.cpp b/KernelConfigs.cpp + +--- a/KernelConfigs.cpp ++++ b/KernelConfigs.cpp +@@ -34,6 +34,7 @@ status_t LoadKernelConfigs(std::map* configs) { + gzFile f = gzopen("/proc/config.gz", "rb"); + if (f == NULL) { + LOG(ERROR) << "Could not open /proc/config.gz: " << errno; ++ errno = 0; // kbox_hacked + return -errno; + } + +diff --git a/VintfObject.cpp b/VintfObject.cpp + +--- 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; + } + } + + diff --git a/system-netd.patch b/system-netd.patch new file mode 100644 index 0000000..d33f1c3 --- /dev/null +++ b/system-netd.patch @@ -0,0 +1,65 @@ +diff --git a/server/BandwidthController.cpp b/server/BandwidthController.cpp + +--- 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; // kbox_hacked + return -res; + } + // TODO: should we propagate this error? +diff --git a/server/Controllers.cpp b/server/Controllers.cpp + +--- 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 + +--- 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; + } + +diff --git a/server/TetherController.cpp b/server/TetherController.cpp + +--- a/server/TetherController.cpp ++++ b/server/TetherController.cpp +@@ -913,9 +913,11 @@ StatusOr 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 + } + } + +diff --git a/server/main.cpp b/server/main.cpp + +--- 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"); + + diff --git a/system-vold.patch b/system-vold.patch new file mode 100644 index 0000000..ad2a66f --- /dev/null +++ b/system-vold.patch @@ -0,0 +1,27 @@ +diff --git a/Utils.cpp b/Utils.cpp + +--- 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; + } +diff --git a/VolumeManager.cpp b/VolumeManager.cpp + +--- a/VolumeManager.cpp ++++ b/VolumeManager.cpp +@@ -210,7 +210,9 @@ void VolumeManager::handleBlockEvent(NetlinkEvent* evt) { + std::string devType(evt->findParam("DEVTYPE") ? evt->findParam("DEVTYPE") : ""); + + if (devType != "disk") return; +- ++ if(evt->findParam("MAJOR") == nullptr){ ++ return; ++ } + int major = std::stoi(evt->findParam("MAJOR")); + int minor = std::stoi(evt->findParam("MINOR")); + dev_t device = makedev(major, minor); -- Gitee