From fa7ddd9b7b06f43a94b0d743f9a712f580660364 Mon Sep 17 00:00:00 2001 From: opa334 Date: Thu, 21 Sep 2023 21:20:44 +0200 Subject: [PATCH] Fix spinlock panics (frfrfr) --- BaseBin/launchdhook/src/dsc_hook.h | 1 + BaseBin/launchdhook/src/dsc_hook.m | 17 +++++++++++++++++ BaseBin/launchdhook/src/main.m | 2 ++ 3 files changed, 20 insertions(+) create mode 100644 BaseBin/launchdhook/src/dsc_hook.h create mode 100644 BaseBin/launchdhook/src/dsc_hook.m diff --git a/BaseBin/launchdhook/src/dsc_hook.h b/BaseBin/launchdhook/src/dsc_hook.h new file mode 100644 index 000000000..c91b5eb8f --- /dev/null +++ b/BaseBin/launchdhook/src/dsc_hook.h @@ -0,0 +1 @@ +void initDSCHooks(void); \ No newline at end of file diff --git a/BaseBin/launchdhook/src/dsc_hook.m b/BaseBin/launchdhook/src/dsc_hook.m new file mode 100644 index 000000000..5447ed181 --- /dev/null +++ b/BaseBin/launchdhook/src/dsc_hook.m @@ -0,0 +1,17 @@ +#import +#import +#import "substrate.h" + +int (*sysctlbyname_orig)(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen); +int sysctlbyname_hook(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen) +{ + if (!strcmp(name, "vm.shared_region_pivot")) { + return 0; + } + return sysctlbyname_orig(name, oldp, oldlenp, newp, newlen); +} + +void initDSCHooks(void) +{ + MSHookFunction(sysctlbyname, (void *)sysctlbyname_hook, (void **)&sysctlbyname_orig); +} \ No newline at end of file diff --git a/BaseBin/launchdhook/src/main.m b/BaseBin/launchdhook/src/main.m index 01e8960cb..71a2274d7 100644 --- a/BaseBin/launchdhook/src/main.m +++ b/BaseBin/launchdhook/src/main.m @@ -12,6 +12,7 @@ #import "xpc_hook.h" #import "daemon_hook.h" #import "ipc_hook.h" +#import "dsc_hook.h" #import "crashreporter.h" #import "../systemhook/src/common.h" @@ -104,6 +105,7 @@ initDaemonHooks(); initSpawnHooks(); initIPCHooks(); + initDSCHooks(); // This will ensure launchdhook is always reinjected after userspace reboots // As this launchd will pass environ to the next launchd...