171 Commits

Author SHA1 Message Date
ThePedroo
d2ebb2bfed improve: ReZygisk state in module description
This commit improves how ReZygisk state is shown in the module description, reducing its size in favor of the same amount of information but in the WebUI, as all root implementations have WebUI available, even if it's through external applications due to incompetency, such as Magisk.

closes #28
2025-08-13 21:34:13 -03:00
ThePedroo
08513b17e8 fix: memory leak, unitialized memory access, FILE pointer leak bugs
This commit fixes numerous general code bugs, improving reliability and consistency of ReZygisk.
2025-08-10 17:06:48 -03:00
ThePedroo
bf3c73d72b fix: not extracting any binaries in some devices
The commit fixes the issue that in devices that "ro.system.product.cpu.abilist" doesn't exist, it will cause ReZygisk "customize.sh" to not extract any binaries. Because of that, we'll fallback to the old "ro.product.cpu.abilist" when "ro.system.product.cpu.abilist" doesn't exist.
2025-07-20 14:10:56 -03:00
ThePedroo
510e8a2de4 fix: not extracting 32-bit binaries in systems using Tango
This commit fixes an issue where ReZygisk would not extract the 32-bit libraries in systems that utilize Tango (binary translation) to run 32-bit applications, as "ro.product.cpu.abilist" will only show the CPU supported architectures, not the system ones, resulting in only extracting 64-bit libzygisk.so and ReZygiskd despite having 32-bit app_process (Zygote).
2025-07-20 02:43:51 -03:00
ThePedroo
90da42a10b fix: passing invalid address to reply_ok in KernelSU prctl
This commit fixes an issue that was caused by ReZygiskd passing NULL (an invalid address) in "reply_ok" to KernelSU driver, which expects it to be a valid address to pass if the request was successful, causing it to spam the dmesg with error logs.
2025-07-15 05:12:33 -03:00
Rifat Azad
bc1b757bb8 update: CMD_HOOK_MODE and CMD_GET_MANAGER_UID values (#200)
This commit updates the values for "CMD_HOOK_MODE" to match newest KernelSU Next value and "CMD_GET_MANAGER_UID", now unified in both KernelSU and KernelSU Next.

Signed-off-by: Rifat Azad <33044977+rifsxd@users.noreply.github.com>
2025-07-11 09:32:17 -03:00
ThePedroo
b6f02b39b3 fix: runtime KSUN manager switch detection
This commit fixes the issue where the new KernelSU Next manager wouldn't be recognized if it was changed without a reboot.
2025-07-01 14:31:06 -03:00
ThePedroo
e036b1f40a add: KernelSU Next spoofed manager recognition support
This commit adds support for ReZygiskd to identify which app is the manager in KSUN (KernelSU Next) builds with spoofed manager package name.
2025-07-01 14:11:39 -03:00
ThePedroo
9a3b2f4a79 fix: KernelSU variant detection
This commit fixes the KSU variant detection, which previously was hardcoded on accident to always set it to KernelSU Next.
2025-06-29 14:23:04 -03:00
ThePedroo
a75b2fe2b8 add: KernelSU Next recognition support
This commit adds support for recognizing KernelSU (KSUN) manager to ReZygiskd.
2025-06-27 14:39:21 -03:00
ThePedroo
48238521df fix: root related mounts leak in KernelSU in isolated services
This commit fixes the leak of mounts in KernelSU with global umount disabled in isolated services. This happens because KernelSU doesn't handle isolated services in kernel side, so we must find the main app UID and see if that UID is in denylist instead. With that, also improve APatch detection to take advantage of faster integer/UID comparison rather than always check process/string comparison, and only fallback to process name based if UID is not found.

Co-Authored-By: nampud <nampud@users.noreply.github.com>
2025-06-24 19:21:26 -03:00
ThePedroo
6c05527ffa fix: Zygisk modules not being recognized in WSA
This commit fixes the issue where due to ARM architectures having priority in ReZygiskd code, ReZygisk, running on emulators, wouldn't be capable of recognizing Zygisk modules. This order is important, Zygisk modules should always give priority to the native architecture over the emulated one, since WSA runs Zygote in x64/x86.
2025-06-22 17:09:37 -03:00
ThePedroo
aff2ad8d3c add: SIGPIPE handling in ReZygiskd
This commit adds "SIGPIPE" signal handling in ReZygiskd. Some processes might die while ReZygiskd is still processing the response, and it will fail to write to the reader, now dead, resulting in a "SIGPIPE". Without proper handling, the process (ReZygiskd) would die, and this commit properly handled it to gracefully log it instead of dying.
2025-06-22 02:10:43 -03:00
ThePedroo
b7fe7b3dbe fix: root related mounts leak in APatch in isolated services
This commit fixes the issue where mounts related to APatch and ReZygisk would be leaked in isolated services for APatch environments as the UID between the main process and isolated service is different, resulting it to not be found in "package_config" and default to not switch to clean mount namespace.
2025-06-21 14:29:03 -03:00
ThePedroo
cd4784376e fix: ReZygiskd out-of-bounds write due to too small system_arch buffer
This commit fixes the issue where when the "ro.product.cpu.abilist" prop has a value bigger than 31 characters, which mostly happens in WSA (Windows Subsystem For Android) as it can support 5+ architectures, it will write outside the buffer, leading to undefined behavior, but most of the time crashes.
2025-06-10 19:32:35 -03:00
ThePedroo
57f985292e fix: leak of dir fd in ReZygiskd
This commit fixes the leak of dir fd caused due to not calling "closedir" after dir being used.
2025-06-09 14:35:04 -03:00
ThePedroo
6272e0a2ac improve: ReZygiskd umount code by unifying; improve: umount system by making umount if less strict
This commit both improves ReZygiskd umount system by unifying all root implementations code into a single one, and also by making it less strict to umount.
2025-05-20 14:25:39 -03:00
ThePedroo
98f88916b8 update: module id
Historically "zygisksu" is the ZygiskOnKernelSU (known as Zygisk Next) module id, which due to ReZygisk being a fork of Zygisk Next, was used by it. To avoid conflicts in systems like MMRL, we decided to change it to "rezygisk". This, however, will allow both to be installed in the same system, although causing problems, as a side effect. The old module, with the old module id, must be uninstalled while the new one is installed.

closes #113
2025-05-18 20:10:14 -03:00
ThePedroo
96123aa53c add: 32-bit only environment support
This commit adds support for devices that are only capable of running 32-bit code, be it due to Android ROM limitations of CPU limitations. It also makes ReZygisk only install necessary libraries, so if a device is 64-bit only, it won't extract 32-bit libraries.
2025-05-07 01:56:05 -03:00
ThePedroo
0d60dc0ec0 fix: ReZygiskd sending data to closed fd
This commit fixes an issue where ReZygiskd would use, in a forked child, the fd that was meant for the parent to use, and vice-versa, causing issues.
2025-04-28 23:46:18 -03:00
ThePedroo
0930c8cca4 fix: ReZygiskd Magisk DenyList not checking against process
This commit improves the precision of ReZygiskd check for Magisk if a process is in DenyList/SuList, as previously it used "package_name" instead of the correct "process" field.
2025-04-27 19:55:32 -03:00
ThePedroo
0c0f65998d remove: ReZygiskd dl.c
This commit removes the "dl.c" file, which was used for using "android_dlopen_ext" in a new namespace, used to isolate libraries, which is not necessary here as they are on different processes, hence "dlopen" can be used.
2025-04-26 06:02:03 -03:00
ThePedroo
dd38f230c0 fix: partially fd leak in Kitsune
This commit partially fixes the issue in Kitsune where fd would leak as MagiskSU would never be found in mounts. According to Magisk Kitsune code, it is only mounted after boot is completed. It sets a callback to call "magisk --boot-completed" when "sys.boot_completed" is 1, which mounts MagiskSU. Hence we check the same prop to see if the mns of the app is appropriate to be cached, and if boot is completed, it will cache that "ns_fd". This, however, doesn't fully fix the issue, since apps that are loaded before boot is completed, will have the fds leaking, since we cannot close them (easily), see code comments.
2025-04-26 01:54:54 -03:00
ThePedroo
d0b044a31d remove: Rooted mns state for simplification
This commit removes the "Rooted" mount namespace state, as it wouldn't fit in the categories made by root implementations. The three major root implementations divide apps into three categories: SU, Umounted, (with) Mounts. The SU one consists of apps that are allowed to elevate privileges, those don't have their mounts modified, and keep root mounts. As for Umounted, it consists of apps that will have root-related mounts umounted before being executed. And finally (with) mounts which are apps that although are not allowed to elevate privileges, still have the root-related mounts kept.
Knowing that we can merge both SU and (with) Mounts into the same category: No modification to mounts/Keep root-related mounts. With that, "Mounts" mns state is also unmodified, compared to old "Modules" mns state.

Those changes also reflect on the issue where new apps couldn't ask Magisk for root as they would have SU mount umounted, which now, as ReZygisk leave them unmodified, they can.
2025-04-25 02:11:57 -03:00
ThePedroo
a4c9794de0 add: error handling for UpdateMountNamespace
This commit adds the missing error handling for "UpdateMountNamespace" in both libzygisk.so and ReZygiskd, as before it would send a -1 as unsigned, leading to issues.
2025-04-25 02:02:29 -03:00
ThePedroo
b24c74ac0d fix: not umounting KSU-specific /system mounts
This commit fixes the issue that ReZygisk would skip all "/system" mounts, and not only the ones made by modules, leaving unexpected mounts mounted in app processes. KernelSU itself create some mounts such as "/system/app", which need to be umounted. To fix that, we will check if they come from "/data/modules", and if so, skip and not umount. That's not needed in Magisk as it doesn't create such mounts as far as I am aware.
2025-04-23 13:55:22 -03:00
ThePedroo
7046c1d9c1 fix: merge conflicts
This commit fixes merge conflicts while merging to main.
2025-04-21 19:50:50 -03:00
ThePedroo
bb8e860e3e improve: match libzygisk.so daemon action name with ReZygiskd's
This commit makes the action name for updating mnt in ReZygiskd side to match libzygisk name one.
2025-04-21 15:41:48 -03:00
ThePedroo
032cd68916 improve: magisk binary check code
This commit improves and simplifies the code that checks in which path the "magisk" binary is by using loops instead of hardcoded "if"s.
2025-04-16 02:15:52 -03:00
ThePedroo
db24c1c439 improve: not umount modules /system mounts
This commit creates a new behavior in ReZygisk umounting system where it now ignores "/system/..." mounts, as umounting them generally leads to unbootable system.
2025-04-16 02:06:21 -03:00
ThePedroo
b94ea0c5f5 improve: port ptracer to C
This commit ports the C++ to C99 from zygisk-ptracer code, allowing a ~3x size reduce in its binary.
2025-04-16 02:02:26 -03:00
ThePedroo
52885faf8b remove: dl.cpp file and replace with "dlopen"
This commit replaces DlopenMem for dlopen, removing the need for "dl.cpp" file.
2025-04-05 15:52:47 -03:00
Pedro.js
886e2f8396 improve: mounting system, compatibility; remove: logging on release (#111)
This commit adds numerous improvements to the state of hidden'ility of ReZygisk, and also for compatibility. Recommended to check #111 for more information.
2025-03-29 12:17:57 -03:00
Reveny
92e2f528a9 add: Android 9 support (#117)
This commit makes ReZygisk load Zygisk libraries directly, not utilizing memfd, as it doesn't exist in older versions of Android.
2025-03-22 19:12:24 -03:00
ThePedroo
d8034b7bde add: Magisk Kitsune SuList support
This commit adds support for the Kitsune SuList, a denylist in whitelist mode.
2025-01-11 06:37:26 -03:00
Pedro.js
3605857d84 improve: companion handler fd closing; fix: PIPE signal handling (#103)
This commit improves how we decide to close the fd that connects the injected module with the companion, avoiding both double close and fd leaks.
2025-01-11 06:37:25 -03:00
ThePedroo
7a892e0d62 improve: companion.c, dl.c and utils.c code
This commit improves the code for multiple files by making "read_string" function already make the string NULL-terminated, avoiding code duplication. Also for "companion.c" fixes an "if" where it would read "client_fd" and check if "fd" is equal to "-1", instead of "client_fd", also does some overall code improvements there like detaching the thread, avoiding memory leaks in the exit, of the thread itself.
2025-01-11 06:37:22 -03:00
ThePedroo
6b0b71a690 fix: Zygiskd remote read types
This commit fixes the mismatch between types sent by lizygisk.so and read by Zygiskd, causing issues.
2025-01-11 06:37:21 -03:00
ThePedroo
8fb5d9197a fix: magisk file detection
This commit fixes the detection for the "magisk" file which can be in 2 different folders, with 3 possible different names.
2024-12-13 13:56:27 -03:00
ThePedroo
f4af759aab fix: free in garbage data pointer; fix: Zygiskd wrong message length
This commit fixes the issue where "free" would be executed in a pointer which has garbage data, leading to crashes. This was fixed by setting to NULL, so that it's clean.
It also fixes the issue where Zygiskd messages for "DAEMON_SET_INFO" would not count the NULL-terminator, causing crashes.
2024-11-12 20:38:28 -03:00
ThePedroo
519d1db6a0 fix: space indentation in macros
This commit fixes the space indentation done in the "ASSURE_*" macros.
2024-11-10 23:11:50 -03:00
ThePedroo
66e98cf007 fix: possible out-of-bounds write; remove: unnecessary logging
This commit both fixes a possible out-of-bounds write by using "snprintf" over "sprintf" and also removes a unnecessary logging which was meant to be removed commits ago.
2024-11-10 23:09:51 -03:00
ThePedroo
47d46e305c fix: fd leak and out-of-bounds access in exec_command
This commit fixes both fd leak and out-of-bounds access in the "exec_command" function, which can happen when execution of the command fails, leading to crashes on Magisk-rooted devices, and possibly APatch-rooted devices too.
2024-11-10 23:09:50 -03:00
ThePedroo
8892eca4a7 fix: wrong longest root implementation name macro value
This commit fixes the value of the macro that defines the size of the longest root implementation name, leading to Zygiskd crashes on Magisk Official.
2024-11-10 23:09:49 -03:00
ThePedroo
a6124a6a5e improve: Zygiskd Magisk code
This commit improves the Zygiskd Magisk code by avoiding redundant code and reducing complexity.
2024-11-10 23:09:47 -03:00
ThePedroo
3265bcb581 fix: module name in Zygiskd log
This commit fixes the module name in Zygiskd log which would only show a letter.
2024-11-10 23:09:46 -03:00
ThePedroo
c4ab77ed9e fix: memory leak and use-after-free in APatch Zygiskd code
This commit fixes a memory leak and a user-after-free vulnerability in APatch code of Zygiskd.
2024-11-10 23:09:45 -03:00
ThePedroo
135ebbb9ba add: Magisk variant status; improve: KSU detection
This commit adds the Magisk variant to module description, and also improves KernelSU detection by requiring the userspace part of it to be installed, AKA "ksud".
2024-11-10 23:09:44 -03:00
ThePedroo
e0d0bd0d76 fix: Zygiskd C99 not properly detecting Magisk DenyList
This commit fixes the Magisk part of Zygiskd C99 which used to mark all apps as outside DenyList.
2024-11-10 23:09:41 -03:00
ThePedroo
182c0293ca fix: compiling errors
This commit fixes compiling errors from missing declaration of variables and missing macros.
2024-11-10 23:09:38 -03:00