Commit Graph

537 Commits

Author SHA1 Message Date
85d9756f62 Update Zygisk API documentation 2023-02-26 03:16:13 -08:00
d7158131e4 No need to manually parse mount flags 2023-02-26 01:15:18 -08:00
3d3082bc82 Minor optimizations 2023-02-26 01:14:10 -08:00
744ebca206 Don't let inter_node upgrade to module_node 2023-02-25 22:05:50 -08:00
92077ebe53 Refactor module and node implementation 2023-02-25 18:19:46 -08:00
78ca682bc5 Always mount tmpfs for dirs
https://android-review.googlesource.com/c/platform/system/core/+/928592
2023-02-25 18:19:46 -08:00
af01a36296 Refactor magic mount to support overlayfs
Previously, magic mount creates its own mirror devices and mount
mirror mount points. With these mirror mount points, magic mount
can get the original files and directory trees. However, some
devices use overlayfs to modify some mount points, and thus after
magic mount, the overlayed files are missing because the mirror
mount points do not contain the overlayed files. To address this
issue and make magic mount more compatible, this patch refactors
how magic mount works.

The new workflows are as follows:
1. make MAGISKTMP a private mount point so that we can create the
   private mount points there
2. for mirror mount points, we instead of creating our own mirror
   devices and mount the mirror mount points, we "copy" the
   original mount points by recursively mounting /
3. to prevent magic mount affecting the mirror mount points, we
   recursively set the mirror mount points private
4. to trace the mount points we created for reverting mounts, we
   again make the mirror mount points shared, and by this way we
   create a new peer group for each mirror mount points
5. as for tracing the newly created tmpfs mount point by magic
   mount, we create a dedicated tmpfs mount point for them, namely
   worker mount point, and obviously, it is shared as in a newly
   created peer group for tracing
6. when reverting mount points by magic mount, we can then trace
   the peer group id and unmount the mount points whose peer group
   ids are created by us

The advantages are as follows:
1. it is more compatible, (e.g., with overlayfs, fix #2359)
2. it can mount more partitions for which previous implementation
   cannot create mirror mount points (fix #3338)
2023-02-25 18:19:46 -08:00
97ed1b16d0 Fix gzip decompression 2023-02-20 18:26:04 -08:00
ae34659b26 No kernel repack if it isn't patched at all
It turns out that decompressing and recompressing the kernel is enough to break booting on many devices that use MT6763.
Fix #5124, fix #6204, fix #6566 

Co-authored-by: LoveSy <shana@zju.edu.cn>
Co-authored-by: 南宫雪珊 <vvb2060@gmail.com>
2023-02-17 15:00:14 -08:00
79a85f5937 Use mountinfo for revert unmount 2023-02-17 12:36:19 -08:00
b249832571 Use statfs to check rootfs
This helps support adb remount
2023-02-12 22:49:27 -08:00
577b5912af Fix SKIP_FD_SANITIZATION false positive
Fix #6523
2023-02-12 00:40:09 -08:00
9e8c68af12 Refactor sepolicy.rules resolve
We resolve available partitions for sepolicy.rules when patching
boot and bind mount the partition by magiskinit.

For older devices, the previous logic won't work because the part name
is never readable.

Co-authored-by: topjohnwu <topjohnwu@gmail.com>
2023-02-12 00:36:38 -08:00
03418ddcbf run module uninstall.sh on Magisk uninstallation 2023-02-09 20:36:58 -08:00
220a1c84ce Zygisk v4 module's plt commit should not use regex 2023-02-09 20:19:53 -08:00
7a9e6d2ad2 Remove unexpected /sbin/overlay.d 2023-02-09 20:08:59 -08:00
6ecc04a4df Fix auto install stub 2023-01-23 01:55:28 +08:00
0329f00129 Upgrade LSPlt
Fix #6533
2023-01-20 19:29:55 +08:00
cd8a2edefb Reduce unnecessary formatting 2023-01-20 14:41:34 +08:00
4318ab5cd2 Reuse tmpfs for magic mount
As we already have a tmpfs (magisktmp), we can reuse them for
magic mount
2023-01-20 03:49:40 +08:00
3517e6d752 Handle nullptr char* in Rust 2023-01-20 03:45:16 +08:00
67845f9c21 Clear sepolicy rules when disable/remove modules
Co-authored-by: topjohnwu <topjohnwu@gmail.com>
2023-01-19 04:25:44 +08:00
f562710438 Fix typos
Found via `codespell -S *.xml,*.kt,./native/src/external -L crate,bu`
2023-01-18 16:35:37 +08:00
e836909c50 umount old hijack binary 2023-01-18 13:06:17 +08:00
8f7d6dfb77 Cleanup unused functions 2023-01-12 23:17:41 +08:00
e73f87b758 Update LSPlt 2023-01-12 01:18:56 +08:00
636223b289 Cleanup APIs 2023-01-10 02:42:45 +08:00
aa0a2f77cf Add inode plt hook APIs 2023-01-10 02:42:45 +08:00
37b81ad1f6 Refine module preparation return value 2022-12-26 17:17:41 -08:00
57d83635c6 Check stub.xz existence 2022-12-26 16:07:04 -08:00
ad0e6511e1 Stop embedding stub.apk in magiskinit 2022-12-26 16:07:04 -08:00
5763a3d908 Support replacing existing .rc by overlay.d
Co-authored-by: topjohnwu <topjohnwu@gmail.com>
2022-12-26 03:28:10 -08:00
a848783b97 Guard boot stages more precisely
Close #6468, fix #6148
2022-12-26 00:04:58 -08:00
4d876f0145 Support detecting safemode by ro.sys.safemode 2022-12-24 15:16:53 -08:00
bdfedea4e0 Close missing fd
Fix #6463
2022-12-24 15:16:27 -08:00
dadae20960 Remove unused implementations 2022-12-23 17:20:39 -08:00
4ed34cd648 Eliminate unnecessarily copy on magiskinit
This patch reuses the abused /data tmpfs for magisktmp
2022-12-23 17:03:16 -08:00
33f5154269 Inject binaries into /system if sbin not accessible
Some Android 11+ devices have the /sbin partition but not accessible by the global shell (`PATH` doesn't contain `/sbin`). Not only custom ROMs but also some stock ROMs have the same behavior so I believe it is something we need to deal with.
Fix #6427, fix #4309, fix #5728, fix #3593
2022-12-13 13:54:55 -08:00
ed37ddd570 Stricter validation 2022-11-22 14:47:37 -08:00
cd5384f13e Fix crashes whenever a zygisk module has ver > 4 2022-11-22 14:47:37 -08:00
11b2ddbad8 Fix zygisk v4 ApiTable abi
Also refactor some code to let the compiler check the abi

Co-authored-by: topjohnwu <topjohnwu@gmail.com>
2022-11-22 11:49:31 -08:00
cf9957ce4d Properly detect SysUI appId
Fix #6322
2022-11-01 02:04:50 -07:00
44643ad7b3 Restrict pointer aliasing
Close #6354, close #6353
2022-10-31 16:35:33 -07:00
616adc22e1 Support Linux < 3.6 2022-10-31 16:00:42 -07:00
a468fd946d Fix #6314 2022-10-11 13:01:34 -07:00
c3b4678f6e Properly detect SysUI 2022-10-10 21:28:13 -07:00
44cfe94e4d Always cleanup init LD_PRELOAD hooks
Fix #6296
2022-10-03 08:26:33 -07:00
095d821240 Don't use xopen in readlink 2022-09-25 16:35:28 -07:00
48f829b76e Minor refactoring 2022-09-21 03:09:46 +02:00
af99c1b843 Don't crash when nullptr paired with len = 0 2022-09-15 16:56:22 -07:00