topjohnwu
1ec33863bc
Android 5.0 is actually supported
2021-08-11 17:14:22 -07:00
topjohnwu
a260e99090
Support code injection on Android 12
2021-08-11 00:00:21 -07:00
topjohnwu
25efdd3d6f
Use code generator for jni_hooks
2021-08-02 03:20:19 -07:00
topjohnwu
00a1e18959
Store all native JNI methods in data structures
2021-08-01 14:35:16 -07:00
topjohnwu
5e1fba3603
Build a single APK for all ABIs
2021-05-13 00:21:04 -07:00
vvb2060
66cc9bc545
Pure 64bit support
2021-05-12 16:38:34 -07:00
topjohnwu
5b37de8fe5
Build our own zlib
2021-05-10 18:46:03 -07:00
topjohnwu
7df23ceb74
Prevent undefined behavior in magiskboot
2021-05-10 18:38:30 -07:00
topjohnwu
6099f3b015
Always resolve to canonical path
2021-05-10 01:14:53 -07:00
topjohnwu
775d095b3c
Update busybox
...
Fix #4225
2021-05-08 16:45:31 -07:00
Wang Han
3798d50457
Kill processes with SIGKILL rather than SIGTERM
2021-05-04 22:14:46 -07:00
vvb2060
708fe514f8
Always use mirror path
2021-04-23 16:56:23 -07:00
vvb2060
f4ac7c8e7c
Ignore validating class name of isolated process name
...
Fix #4176
Co-authored-by: topjohnwu <topjohnwu@gmail.com>
2021-04-15 23:08:51 -07:00
Wang Han
44f005077d
Don't copy sepolicy.rule to /persist on boot
...
* This seems to be a logic that has been abandoned for a
long time. Now we automatically choose which partition
to store sepolicy.rule. Furthermore, touching /persist is
what we should avoid doing whenever possible.
2021-04-15 05:01:03 -07:00
LoveSy
013b6e68ec
Fix perfect forwarding
2021-04-15 04:58:30 -07:00
LoveSy
95c964673d
Initialized _root
properly
...
Fix #4204
`_root` is uninitialized for non-root nodes. And it will cause `module_node::mount` fail because it uses `root()`. Once the bug is triggered, signal 11 is received but Magisk catch all signals and therefore stuck forever.
2021-04-15 04:58:30 -07:00
Wang Han
e136fb3a4f
Remove outdated sepolicies
...
* Support deodexed ROM: This should not be done and dexpreopt is mandatory since P
Xposed: Xposed handles them just fine, at least in the latest version 89.3
suMiscL6: For whatever audio mods, a leftover of phh time
Liveboot and suBackL6: Was for CF.lumen and LiveBoot, not needed now
* Also cleanup binder sepolicies since we allow all binder transactions.
2021-04-09 21:34:51 -07:00
topjohnwu
01b985eded
Remove more pre SDK 21 stuffs
2021-04-09 21:29:42 -07:00
Shaka Huang
3da318b48e
Fix random return value of faccessat() in x86
...
faccessat() should return 0 when success, but it returns random number with errno == 0 in x86 platform.
It’s a side effect of commit bf80b08b5f
when magisk binaries ‘corretly’ linked with library of API16 .. lol
Co-authored-by: John Wu <topjohnwu@gmail.com>
2021-04-04 03:04:09 -07:00
Shaka Huang
dfe1f2c108
Call freecon() when fgetfilecon() succeeds
2021-04-04 01:58:59 -07:00
topjohnwu
7da36079c1
Always delete existing ro props at setprop
...
Close #4113
2021-03-29 04:16:18 -07:00
topjohnwu
2bef967af1
Make systemproperties more match AOSP
2021-03-29 03:46:07 -07:00
topjohnwu
7e4194418a
Update libcxx
2021-03-28 04:55:56 -07:00
topjohnwu
66e30a7723
Build libc++ ourselves
2021-03-25 01:00:10 -07:00
vvb2060
8ddab84745
Don't auto hide microG
...
close #3559
2021-03-24 04:43:45 -07:00
vvb2060
6865652125
Fix process name in MagiskHide
...
close #3997
2021-03-24 04:43:45 -07:00
Shaka Huang
e3801d6965
Fix overflow
...
`totalsize` might be a big (invalid) number so instead of checking the end address we check the size of the image.
Fix #4049
2021-03-24 03:02:46 -07:00
topjohnwu
336f1687c1
Be more careful with signals
...
Fix #4040
2021-03-18 03:28:02 -07:00
vvb2060
7a007b342a
Correct comment
...
For file-based encryption, /data/adb is always required to encrypt
https://android.googlesource.com/platform/system/extras/+/refs/tags/android-7.0.0_r36/ext4_utils/ext4_crypt_init_extensions.cpp
68258e8444
%5E%21/
2021-03-13 21:10:02 -08:00
vvb2060
0783f3d5b6
Fix mount rules dir
...
close #4006
2021-03-13 21:10:02 -08:00
topjohnwu
82f8948fd4
Separate setting log functions and starting log daemon
2021-03-13 17:50:48 -08:00
Shaka Huang
b9cdc755d1
Returned fds[0] in socketpair() might be STDOUT
...
* There will be garbage output when executing `su` (#4016 )
* Failed to check root status and showing N/A in status (#4005 )
Signed-off-by: Shaka Huang <shakalaca@gmail.com>
2021-03-13 17:50:48 -08:00
topjohnwu
a6f81c66e5
Bypass stdio
2021-03-13 16:17:28 -08:00
topjohnwu
1ff45ac5f5
Proper pattern matching
...
Fix #3998
2021-03-09 04:08:34 -08:00
topjohnwu
43c1105d62
Use dedicated thread for writing logfile
2021-03-09 02:40:12 -08:00
vvb2060
b693d13b93
Proper implementation of cgroup migration
...
https://www.kernel.org/doc/Documentation/admin-guide/cgroup-v1/cgroups.rst
https://www.kernel.org/doc/Documentation/admin-guide/cgroup-v2.rst
2021-03-07 01:55:19 -08:00
topjohnwu
39982d57ef
Fix logging implementation
...
- Block signals in logging routine (fix #3976 )
- Prevent possible deadlock after fork (stdio locks internally)
by creating a new FILE pointer per logging call (thread/stack local)
2021-03-06 13:55:30 -08:00
topjohnwu
851404205b
Update NDK to r21e
2021-03-02 23:18:44 -08:00
topjohnwu
117ae71025
Use custom class instead of std::map
2021-03-02 23:16:10 -08:00
topjohnwu
027ec70262
Patch AVB structures
...
Disable vbmeta verification in flags
2021-03-02 20:37:37 -08:00
topjohnwu
55fdee4d65
Use memmem for searching byte patterns
2021-02-28 14:37:12 -08:00
topjohnwu
0d42f937dd
Refactor magiskboot
2021-02-28 14:37:12 -08:00
vvb2060
ac8372dd26
Add cgroup2 path
...
https://android-review.googlesource.com/c/platform/system/core/+/1585101
2021-02-26 21:36:58 -08:00
Shaka Huang
ba1ce16b8b
Fix error in pure 64-bit environment
...
In Android S preview, there’s no 32-bit libraries in x86_64 system image for emulator.
Signed-off-by: Shaka Huang <shakalaca@gmail.com>
2021-02-22 03:28:54 -08:00
topjohnwu
ccb55205e6
Fix pre 21 support
2021-02-20 03:38:39 -08:00
vvb2060
b76c80e2ce
Fix apex path
2021-02-14 13:37:38 -08:00
topjohnwu
501bc9f438
Restore init from backup rather than symlink
...
Because of course Samsung don't follow AOSP norms.
I mean, why would they?
2021-02-13 16:43:06 -08:00
topjohnwu
2963747d14
Fix LZ4_LG format decompression
...
Fix #3802 , fix #3722 , fix #3770 , fix #3635 , fix #3787 , close #3812
2021-02-07 17:40:59 -08:00
topjohnwu
f1295cb7d6
Fix root on Android 7.0 and lower
2021-01-26 02:16:11 -08:00
topjohnwu
b1dbbdef12
Remove unneeded busybox redirection
2021-01-25 00:23:42 -08:00
topjohnwu
3e479726ec
Fix legacy rootfs devices
2021-01-25 00:19:10 -08:00
vvb2060
5113f6d375
Fix stop magiskhide
2021-01-23 18:13:15 -08:00
vvb2060
317336f771
Add isolated processes log
2021-01-23 17:31:11 -08:00
topjohnwu
61d52991f1
Update BusyBox
2021-01-21 00:35:22 -08:00
topjohnwu
d2bc2cfcf8
Install both 32 and 64 bit binaries
2021-01-18 12:37:08 -08:00
topjohnwu
5a71998b4e
Stop embedding magisk in magiskinit
2021-01-18 04:25:26 -08:00
topjohnwu
42278f12ff
Fix typo in init daemon
2021-01-18 04:13:54 -08:00
topjohnwu
79140c7636
Proper xxread and xwrite implementation
2021-01-17 01:42:45 -08:00
topjohnwu
1f4c595cd3
Revert to old su -c
behavior
2021-01-16 23:59:31 -08:00
topjohnwu
67e2a4720e
Fix xxread false negatives
...
Fix #3710
2021-01-16 21:43:53 -08:00
topjohnwu
f5c2d72429
Also log pid and tid
2021-01-16 16:10:47 -08:00
topjohnwu
13fbf397d1
Isolated processes might still be hide-able
2021-01-15 20:22:49 -08:00
topjohnwu
04c53c3578
Legacy SAR: use a simpler method to detect is_two_stage
2021-01-15 02:44:40 -08:00
topjohnwu
51bc27a869
Avoid F2FS like a plague
2021-01-15 02:24:11 -08:00
topjohnwu
71b083794c
Maintain global mount list
2021-01-14 21:14:54 -08:00
topjohnwu
b100d0c503
Revert DTB fstab changes
2021-01-14 19:48:00 -08:00
topjohnwu
76061296c9
Let MagiskBoot handle dtb fstab patching
2021-01-14 06:20:12 -08:00
topjohnwu
bb303d2da1
Remove old unused code
2021-01-14 05:59:53 -08:00
topjohnwu
c91c070343
Re-enable DTB table rebuilding
2021-01-14 05:45:05 -08:00
topjohnwu
aec06a6f61
Get proper total image size
2021-01-14 03:55:27 -08:00
topjohnwu
e8ba671fc2
Guard all injection features behind a global flag
2021-01-13 20:07:23 -08:00
topjohnwu
1860e5d133
Dynamically find libselinux.so path
2021-01-13 19:41:57 -08:00
topjohnwu
f2cb3c38fe
Update mmap implementation
...
Always map memory as writable, but private when read-only
2021-01-12 22:50:55 -08:00
topjohnwu
9a28dd4f6e
Implement MagiskHide through code injection
2021-01-12 03:28:00 -08:00
topjohnwu
d2acd59ea8
Minor code refactoring
2021-01-12 00:07:48 -08:00
topjohnwu
eb21c8b42e
Code cleanups
2021-01-11 02:19:10 -08:00
topjohnwu
70d67728fd
Add global toggle for ptrace monitor
2021-01-10 19:27:54 -08:00
topjohnwu
e546884b08
Remove isolated process handling in ptrace
...
Impossible to achieve only through ptrace
2021-01-10 17:18:42 -08:00
topjohnwu
b36e6d987d
Reorganize MagiskHide code
...
Prepare for zygote injection hiding
2021-01-10 17:11:00 -08:00
topjohnwu
53c3dd5e8b
Auto track JNI method hooks
2021-01-10 05:07:17 -08:00
topjohnwu
da723b207a
Allow 3rd party code to load pre-specializing
...
Magisk's policy is to never allow 3rd party code to be loaded in the
zygote daemon process so we have 100% control over injection and hiding.
However, this makes it impossible for 3rd party modules to run anything
before process specialization, which includes the ability to modify the
arguments being sent to these original nativeForkAndXXX methods.
The trick here is to fork before calling the original nativeForkAndXXX
methods, and hook `fork` in libandroid_runtime.so to skip the next
invocation; basically, we're moving the responsibility of process
forking to our own hands.
2021-01-10 01:25:30 -08:00
topjohnwu
e050f77198
Don't hook SystemProperties#set
...
Doesn't seem necessary
2021-01-09 20:39:59 -08:00
topjohnwu
540b4b7ea9
Update pre/post hooks implementation
2021-01-09 17:41:25 -08:00
topjohnwu
bbef22daf7
More macro magic to automate more code
2021-01-09 04:28:26 -08:00
topjohnwu
9ed110c91b
Add JNI hooks to critical methods
2021-01-08 05:25:44 -08:00
topjohnwu
a30d510eb1
Use xHook to hook functions in PLT
2021-01-08 00:53:24 -08:00
topjohnwu
ef98eaed8f
Proper injection entry and unloading
2021-01-06 23:59:05 -08:00
topjohnwu
2a257f327c
Sanitize /proc/PID/environ
2021-01-06 23:41:37 -08:00
topjohnwu
4060c2107c
Add preliminary zygote code injection support
...
Prototyping the injection setup and a clean "self unloading" mechanism.
2021-01-06 22:21:17 -08:00
topjohnwu
cd23d27048
Fix remote_write implementation
2021-01-06 21:56:29 -08:00
topjohnwu
18b86e4fd2
Update Android.mk for test binary
...
Make Android Studio happy
2021-01-05 00:01:02 -08:00
topjohnwu
5f2e22a259
Support remote function call with ptrace
...
End up not used for anything, but keep it for good
2021-01-02 21:29:45 -08:00
topjohnwu
4e97b18977
Move libsystemproperties to external
2020-12-31 15:06:19 -08:00
topjohnwu
f9bde347bc
Convert indentation to spaces
...
The tab war is lost
2020-12-30 22:11:24 -08:00
Billy Laws
947a7d6a2f
Support rootwait cmdline parameter on legacy SAR
...
On devices where the primary storage is slow to probe it makes sense to
wait forever for the system partition to mount, this emulates the
kernel's behaviour when waiting for rootfs on SAR if the rootwait
parameter is supplied.
This issue was encountered with some SD cards on the Nintendo Switch.
2020-12-30 16:43:28 -08:00
topjohnwu
79fa0d3a90
Hide selection improvements
2020-12-30 16:40:22 -08:00
topjohnwu
8e61080a4a
Preparation for hiding isolated processes
2020-12-30 15:55:53 -08:00
topjohnwu
db4f78d463
Unblock signals before executing commands
2020-12-27 15:05:39 -08:00
vvb2060
c5b452f369
Get boot config properly
...
https://android.googlesource.com/platform/system/core/+/refs/tags/android-11.0.0_r16/fs_mgr/fs_mgr_boot_config.cpp#93
2020-12-19 15:55:33 -08:00
topjohnwu
eee7f097e3
Make post-fs-data scripts block at most 35 secs
2020-12-17 16:54:53 -08:00
topjohnwu
086059ec30
Make sure boot stages are mutually exclusive
2020-12-15 03:40:37 -08:00
topjohnwu
7ff22c68c7
Only try to install APK when no manager is active
2020-12-09 02:15:16 -08:00
topjohnwu
0c28b23224
Fix install_module command
2020-12-09 00:37:15 -08:00
topjohnwu
c62dfc1bcc
Make logging less error prone
2020-12-06 23:09:24 -08:00
topjohnwu
aabe2696fe
Cleanup implementations
2020-12-06 03:07:47 -08:00
topjohnwu
ae0d605310
Make sure patch_rootdir does not cause crashes
2020-12-06 02:19:57 -08:00
topjohnwu
2a694596b5
Better error handling and logging
2020-12-05 10:23:49 -08:00
topjohnwu
ff0a76606e
Detect 2SI after system_root mount on legacy SAR
2020-12-04 03:06:21 -08:00
topjohnwu
dead74801d
Setup log file when manually starting daemon
2020-12-04 01:07:47 -08:00
topjohnwu
ab207a1bb3
va_list cannot be reused on x86
2020-12-03 20:53:19 -08:00
topjohnwu
f152e8c33d
Directly log to log file
2020-12-03 20:15:18 -08:00
topjohnwu
797ba4fbf4
Make sure all logging ends with newline
2020-12-02 00:55:22 -08:00
topjohnwu
552ec1eb35
Header v3 does not have name entry
2020-11-20 22:52:09 -08:00
topjohnwu
0064b01ae0
Trim out \r from string
...
Fix #3490
2020-11-15 06:30:29 -08:00
topjohnwu
e0afbb647b
Minor changes
2020-11-13 02:31:54 -08:00
topjohnwu
f9c7a4c933
Redirect /data/adb/magisk/busybox
...
Workaround some stupid Samsung kernel restrictions
2020-11-11 02:26:07 -08:00
topjohnwu
2b759b84b0
Properly reset string
2020-11-09 21:17:21 -08:00
topjohnwu
1e45c63ea5
Scan for zygote periodically
...
Fix #3417
2020-11-08 03:44:43 -08:00
topjohnwu
b14a260827
Offset pid_set by 1
...
PID starts at 1, not 0
2020-11-08 02:12:35 -08:00
topjohnwu
ade1597e03
Support hiding apps not installed in main user
...
Fix #2181 , close #1840
2020-11-08 01:53:18 -08:00
topjohnwu
afebe734b8
Fix several things regarding scripting
2020-11-07 14:36:13 -08:00
topjohnwu
e21a78164e
Properly handle factory resets
...
Close #3345
2020-11-04 04:50:04 -08:00
topjohnwu
1e0f96d0fd
Prefer platform implementation over internal
2020-11-04 04:42:02 -08:00
topjohnwu
bf650332d8
Update nanopb
2020-11-04 01:56:49 -08:00
topjohnwu
f32e0af830
Update resetprop help msg
2020-11-03 01:21:05 -08:00
topjohnwu
4c94f90e5d
Templatize function callbacks
2020-11-03 01:16:55 -08:00
topjohnwu
ffb4224640
Don't use reserved symbols
2020-11-03 01:12:33 -08:00
topjohnwu
89fff4830b
Mount proper system_root mirror in magiskd
2020-11-03 00:37:08 -08:00
topjohnwu
16e4c67992
Significantly broaden sepolicy.rule compatibility
...
Previously, Magisk uses persist or cache for storing modules' custom
sepolicy rules. In this commit, we significantly broaden its
compatibility and also prevent mounting errors.
The persist partition is non-standard and also critical for Snapdragon
devices, so we prefer not to use it by default.
We will go through the following logic to find the best suitable
non-volatile, writable location to store and load sepolicy.rule files:
Unencrypted data -> FBE data unencrypted dir -> cache -> metadata -> persist
This should cover almost all possible cases: very old devices have
cache partitions; newer devices will use FBE; latest devices will use
metadata FBE (which guarantees a metadata parition); and finally,
all Snapdragon devices have the persist partition (as a last resort).
Fix #3179
2020-11-02 23:20:38 -08:00
topjohnwu
0feab753fb
Fix coding errors and minor changes
2020-10-28 04:17:34 -07:00
Leorize
d0b6318b90
init/mount: support for dm-verity verified root
...
This commit adds support for kernel initialized dm-verity on legacy SAR
devices.
Tested on a Pixel 2 XL with a kernel patch to initialize mappings
specified via the `dm=` kernel parameter even when an initramfs is used.
2020-10-27 03:47:50 -07:00
topjohnwu
966e23b846
magiskinit code tidy-up
2020-10-26 20:46:15 -07:00
topjohnwu
5b8a1fc2a7
Minor renames
2020-10-25 21:41:14 -07:00
topjohnwu
02ea3ca525
Headers doesn't always occupy 1 page
2020-10-25 06:25:42 -07:00
topjohnwu
0632b146b8
Add vendor boot image support to magiskboot
2020-10-25 06:09:36 -07:00
topjohnwu
1b0b180761
Fix COMPRESSED macro
...
Fix #3383
2020-10-25 05:10:19 -07:00
topjohnwu
aaaaa3d044
Minor refactoring
2020-10-15 00:19:11 -07:00
topjohnwu
1edc4449d5
Update lz4 to v1.9.2
...
Close #3334
2020-10-15 00:04:48 -07:00
topjohnwu
f3cd4da026
Make lz4_lg an exception of lz4_legacy
2020-10-14 23:45:06 -07:00
vvb2060
872c55207c
Add com.android.i18n to apex path
2020-10-12 01:59:41 -07:00
topjohnwu
339ca6d666
Improve magiskboot info logging
2020-10-12 01:55:33 -07:00
topjohnwu
4aeac3b8f4
Support header_version 3
2020-10-12 01:06:42 -07:00
topjohnwu
d625beb7f3
Update --remove-modules
implementation
2020-10-11 18:30:03 -07:00
topjohnwu
0499588107
Support androidboot.fstab_suffix cmdline flag
...
Fix #3187
2020-10-08 03:04:12 -07:00
topjohnwu
8b5652ced5
Skip image padding on Pixel C
2020-09-29 02:49:10 -07:00
topjohnwu
6abd9aa8a4
Add new --install-module command
...
Close #2253
2020-09-26 16:50:41 -07:00
topjohnwu
c91ebfbcc1
Pad images to original sizes with zero
...
Close #2005
2020-09-26 14:36:57 -07:00
topjohnwu
4fd04e62af
Remove compressed ramdisk support
...
It is causing more issues than it addresses
2020-09-24 02:49:09 -07:00
topjohnwu
17b5291bbb
Fix Android 8.0 selinux rules
2020-09-20 14:39:11 -07:00
topjohnwu
30e45f863d
Remove unnecessary workaround
2020-09-10 01:01:51 -07:00