Commit Graph

342 Commits

Author SHA1 Message Date
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.
v1.0.0-rc.2
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
00345eea7f improve: unify symtabs loading in elf_util.c
This commit improves the code in "elf_util.c" by unifying the code that loads the symtabs information in ElfImg structure.
2025-04-25 02:06:59 -03:00
ThePedroo
aac0046061 fix: memory leak in rezygisk_get_info
This commit fixes a memory leak in "rezygisk_get_info" as it would read a string from ReZygiskd but would never "free" after using it. Also call "free_rezygisk_info" instead of manually cleanup in ptracer.
2025-04-25 02:05:29 -03:00
ThePedroo
2f4f5af206 fix: missing vdso lead to unoperating SoList hiding
This commit fixes the issue where the could would return when "__dl__ZL4vdso*" wasn't found, leaving traces in SoList.
2025-04-25 02:03:58 -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
a460c54d08 improve: update_mnt_ns logging; add: comment about "rooted denylisted" apps
This commit improves logging for "update_mnt_ns" function, which now specifies which state it will update the mns to, for easier debugging. It also adds a note about the possibility of having apps with rooted permissions and also be denylisted in Magisk, causing weird behavior.
2025-04-24 01:33:53 -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
Pedro.js
2ff4cb6401 merge: port of more of the codebase; fix: memory and general mount bugs (#122)
This commit merges the PR that both ports common, ptracer and include (SoList) to C, and also fixes memory bugs and mount bugs.
2025-04-22 23:58:34 -03:00
ThePedroo
61ece7ee4f remove: ccache from workflows
This commit removes ccache since it doesn't provide any benefit in workflows, and makes them slower.
2025-04-21 20:04:16 -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
bd5eb4c795 fix: unexpected /data/adb umount before loading modules
This commit fixes the issue where ReZygisk would change the mount namespace (mns) before the modules were loaded, thus failing, as "/data/adb/modules" wouldn't be mounted.
2025-04-21 19:37:09 -03:00
ThePedroo
8949561ac8 fix: logging tag for ptracer, out-of-bounds access in allowed_fds
This commit fixes the logging tag for ptracer command-line tool, which would show as "zygisk-core64", the one from libzygisk, and an out-of-bounds access in "allowed_fds" array, which then the readdir returned the "." and "..", the "parse_int" would return -1, and would try to access it in "allowed_fds" without checking if it is negative, or bigger, first.
2025-04-21 15:46:28 -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
GhostFRR
221b4fc997 add: French README.md translations (#129)
This commit adds the translations for French of the "README.md" file.

Signed-off-by: GhostFRR <ghost.game.fr@gmail.com>
2025-04-17 14:07:37 -03:00
Md Arif
622e23e7ec fix: wrong JNI function signature for GrapheneOS (#99)
This commit fixes the wrong signature for JNI functions of GrapheneOS's Zygote, leading to it not working on GrapheneOS.
2025-04-17 12:46:09 -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
8f70a1a451 remove: unused mazoku file
This commit removes the "mazoku" file, which is only used by Zygisk Next/Shamiko for module integrity and signing, and is not used in ReZygisk.
2025-04-16 02:12:34 -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
1a3f497e1a improve: port common code to C
This commit ports even more C++ code to C99, now, the codes available in the "common" folder.
2025-04-14 00:54:24 -03:00
Breathleas
c37a5b1c8e fix: missing status32 exit check (#128)
This commit fixes the issue where 32-bit daemon wouldn't be checked for exits, as the macro hardcoded "status64".

Signed-off-by: Breathleas <39123978+Breathleas@users.noreply.github.com>
Co-authored-by: anyusec <145352653+anyusec@users.noreply.github.com>
Co-authored-by: Pedro.js <pedroolimpioguerra@gmail.com>
2025-04-13 19:12:08 -03:00
Stillhard
2d80ce6935 fix: SELinux rules (#130)
This commit allows Zygote to access files in /data/adb, so that it can load the Zygisk modules.

Signed-off-by: Stillhard <indofreeserver@yahoo.co.id>
2025-04-12 23:54:35 -03:00
ThePedroo
5b3d9c75fd remove: open file helpers
This commit remove the `open_...` and `xopen_...` helpers, making the code simpler and more direct.
2025-04-12 23:26:17 -03:00
ThePedroo
4625587ea9 improve: ELF utils and SoList code
This commit improves the code related to ELF and SoList, porting them to C.
2025-04-08 16:26:19 -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
9aafc279d5 improve: use all threads for compiling (#118)
This commit speeds up the build process by almost 50% when building with github actions by using all system threads to compile ReZygisk.
2025-03-23 15:11:33 -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
Berk Mirsat
bc6cf67c7b add: Turkish README.md (#114)
This commit adds README translations for Turkey's launguage.
2025-01-27 08:40:28 -03:00
Pedro.js
cfd4a92b31 add: Brazilian Portuguese README.md (#112)
This commit adds the language from Brazil to the list of available translations of README.md file
2025-01-11 07:05:52 -03:00
Arisu: Rain
3bc3b478ff add: vietnamese README (#110)
This commit adds Vietnam language README to the repository.
2025-01-11 06:37:28 -03:00
Lucky Kiddos
e56cc85948 add: Indonesian README.md (#108)
This commit adds Indonesian translation for README.

Signed-off-by: Lucky Kiddos <95188840+GuitarHeroStyles@users.noreply.github.com>
2025-01-11 06:37:27 -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
b0a296fc29 add: support for magic mount in KSU and APatch
This commit allows ReZygisk to u(n)mount mounted paths in KSU and APatch environments using magic mount.
2025-01-11 06:37:24 -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
95073d9f4a fix: checking malloc against non NULL not NULL
This commit fixes an issue where one of the "malloc", a libc function to allocate dynamic memory, "if"s were checking its return against non-NULL instead of NULL, making it seem to have failed when it didn't.
2024-12-18 13:07:06 -03:00
Pedro.js
4b7618ddf9 merge: Clean up injection traces of ReZygisk (#101)
This merge commit merges the Pull Request by JingMatrix that cleans up the rest of detection points of ReZygisk in non-KSU environments.
2024-12-18 03:26:41 -03:00
JingMatrix
0671f2e497 improve: reset linker module counters
Two counters for module loading and unloading are introduced in the commit a2e83ab348. To remove linker traces of libzygisk.so and Zygisk modules, we should reset them properly.
2024-12-18 07:21:03 +01:00
JingMatrix
5e072bd919 improve: cache scanned virtual maps
Reading the file `/proc/self/maps` is detectable by the target process.
Hence, we should cache scanned virtual maps after `libart.so` is loaded for later plt hooks in the target process.
2024-12-18 07:21:03 +01:00
JingMatrix
2814aaf67f remove: unnecessary memory mapping renaming
Note that it is impossible to hide injecting trace of virtual memory maps from the hooked target process.
ReZygisk will only focus on removing its trace for approcess that are not hooked by modules.
2024-12-18 07:19:41 +01:00
JingMatrix
b7138d6353 add: drop soinfo for libzygisk.so
1. fix typo vsdo -> vdso and allow this symbol to be not found, which is the case for the 32bit linkers on some devices
2. use soinfo_free to fully remove the soinfo record of libzygisk.so
3. set `soinfo.size = 0` to avoid the library being unmapped while removing its soinfo record
4. add more debug logs for troubleshooting
2024-12-15 16:28:49 +01:00
JingMatrix
5e43e4a71b improve: hook pthread_attr_setstacksize
Relying on dlclose to unload libzygisk.so will block us to clean its trace in the solist.
This commit allows us to unmap libzygisk.so without using dlclose.
To call munmap, we use the function pthread_attr_setstacksize instead of pthread_attr_destroy, so that tail-call can still be applied here since it has the same signature as munmap.
2024-12-15 16:25:06 +01: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
Md Arif
060a1f3cf9 add: GrapheneOS support (#53)
This commit adds support for devices that run GrapheneOS by hooking on JNI methods they renamed.

Signed-off-by: Md Arif <111168803+sabamdarif@users.noreply.github.com>
2024-12-07 19:03:22 +00:00
Pedro.js
6cb8f305bc merge: Improve SoList hiding (#95, #96)
This commit merges the pull request by JingMatrix that includes improvements for clangd users, fixes for devices which have llvm suffix in SoList related symbols, and improved hiding related to the SoList.
2024-12-05 20:07:50 -03:00
JingMatrix
6c41a8188d improve: drop soinfo records of loaded modules
In Bionic linker, the `soinfo` structure has a field `next`, which points to the next loaded library in a linked list consisting of all loaded libraries.
Hence, an injected process can easily find all loaded libraries.
Previously in ReZygisk, module library records are hidden by setting the `pathname` field to be empty, which is futile but easier to detect.
Current idea of dropping record can be found in the following commit:
5d635e8c66
2024-12-06 00:02:29 +01:00