Commit Graph

1489 Commits

Author SHA1 Message Date
b51feffe80 Limit process name match to cmdline only
We are only interested in Zygote forked processed
2019-03-01 18:13:41 -05:00
b1afd554fc Application Component Granularity MagiskHide
Before switching to the new MagiskHide implementation (APK inotify),
logcat parsing provides us lots of information to target a process.
We were targeting components so that apps with multi-processes
can still be hidden properly.

After switching to the new implementation, our granularity is limited
to the UID of the process. This is especially dangerous since Android
allow apps signed with the same signature to share UIDs, and many system
apps utilize this for elevated permissions for some services.

This commit introduces process name matching. We could not blanketly
target an UID, so the workaround is to verify its process name before
unmounting.

The tricky thing is that any app developer is allowed to name the
process of its component to whatever they want; there is no 'one
rule to catch them all' to target a specific package. As a result,
Magisk Manager is updated to scan through all components of all apps,
and show different processes of the same app, each as a separate
hide target in the list.

The hide target database also has to be updated accordingly.
Each hide target is now a <package name, process name> pair. The
magiskhide CLI and Magisk Manager is updated to support this new
target format.
2019-03-01 17:08:08 -05:00
e72c6685ed Support A only System-as-root Devices
Most Chinese devices (and supposedly Galaxy S10) running Android Pie
is using system-as-root without A/B partition.

https://source.android.com/devices/bootloader/system-as-root#about-system-as-root

According to the docs above, these devices will have a ramdisk block
with size 0 in their boot images. Since magiskinit can run independently
on system-as-root devices, we simply just create an empty ramdisk with
magiskinit added as init.

Huge thanks to @vvb2060 for the heads up and original PR.
Close #980, close #1102
2019-02-28 05:46:36 -05:00
54a8a05dae Small adjustments in connect.cpp 2019-02-27 16:44:27 -05:00
0eef4eacd6 Use REBOOT foreground broadcast 2019-02-27 16:44:27 -05:00
5764f0c839 Compiler flag enhancements
- Enable LTO
- Add -fomit-frame-pointer for even smaller binary size

This commit is inspired by #1075. Close #1075.
2019-02-26 03:42:44 -05:00
f152bea8d8 Trim dev name 2019-02-26 03:04:17 -05:00
8032bd0bac Introduce /data mirror
Since we switched to imageless Magisk, module files are directly
stored in /data. However, /data is mounted with nosuid, which also
prevents SELinux typetransition to work (auto transition from one
domain to another when executing files with specific context).
This could cause serious issues when we are replacing system critical
components (e.g. app_process for Xposed), because most of them
are daemons that run in special process domains.

This commit introduced /data mirror. Using similar mirroring technique
we used for system and vendor, we mount another mirror that mounts
/data without nosuid flag. All module files are then mounted from this
mirror mountpoint instead of directly from /data.

Close #1080
2019-02-25 06:13:42 -05:00
0c227f2917 Always clone attribute from existing files to module files
This makes sure no weird permission/SELinux issues shall happen
2019-02-25 05:17:08 -05:00
c9fa8118d1 Some code adjustments 2019-02-24 23:09:34 -05:00
63b18246d8 Add compressed ramdisk support 2019-02-24 20:39:01 -05:00
16ec37a226 Fix compression without outname 2019-02-24 17:45:08 -05:00
bd4e5bfc1a Some minor optmizations 2019-02-24 17:45:08 -05:00
621fd0ee29 Fix SEGV_ACCERR on some 64 bit devices 2019-02-24 08:20:05 -05:00
6ca8db2f0c Welcome to the 64 bit world!
Close #854
2019-02-24 08:13:27 -05:00
ea129fb206 Allow cpio mv to override existing entries 2019-02-24 05:11:36 -05:00
3356d7b6ff More friendly to obscure/outdated custom recoveries
Close #1049
2019-02-24 04:45:47 -05:00
c84023bdc2 Fix crashes when removing verity_key 2019-02-24 04:29:15 -05:00
86f778c0aa Group unsupported formats into the same code 2019-02-24 02:30:04 -05:00
0f46493477 Compile magiskboot as static 2019-02-23 17:01:44 -05:00
340bac7e42 Add decompression command 2019-02-23 16:53:51 -05:00
1d3ce9fef1 Support loading CPIO from a chunk of bytes 2019-02-23 16:16:35 -05:00
4a398642b8 Set mode in constructor 2019-02-23 15:22:11 -05:00
9c89e56c56 Add ramdisk compression option 2019-02-23 15:04:15 -05:00
267c59b1f1 Add truncate while open 2019-02-23 13:08:54 -05:00
2ab17204c6 Add stream output for CPIO 2019-02-23 05:06:07 -05:00
75939047d1 Fix bugs in compression 2019-02-23 04:51:13 -05:00
2d7f130d2c Introduce Java-like OutputStream 2019-02-23 04:51:13 -05:00
f7ae72a36c Move CPIO to libutils 2019-02-23 02:42:26 -05:00
391783e268 Introduce mmap based CPIO class 2019-02-23 02:23:24 -05:00
6f12c08204 Use ordered map to store CPIO entries 2019-02-22 22:53:20 -05:00
cb8fe70734 Modernize CPIO code 2019-02-22 02:56:18 -05:00
69d10b747a Directly use FDT headers for detection 2019-02-21 05:24:05 -05:00
da3394f34e Move image parsing out of header searching 2019-02-21 05:08:38 -05:00
b4c2a9f49f More macro magic 2019-02-21 04:14:52 -05:00
7cee77f57a Some C++ magic to make code cleaner 2019-02-21 02:54:37 -05:00
f28bd1972f Adjust LZ4F block size 2019-02-21 00:52:47 -05:00
0f92d1de1b Fix bzip2 decompression 2019-02-20 20:53:54 -05:00
e59c5c8780 Modernize compress and decompress 2019-02-20 20:49:26 -05:00
86d8026301 Update format.h
GZIP magic is \x1f\x8b\x08 not \x1f\x8b\x08\x00
2019-02-20 03:53:41 -05:00
d67b827338 Rewrite compression with OOP 2019-02-20 02:10:06 -05:00
660e0dc09a Fix MagiskHide unmount daemon
Close #1101
2019-02-19 01:50:41 -05:00
3ebc886f8a Make sure PPID exists 2019-02-18 03:45:01 -05:00
5b54ef840a Skip same mount namespace 2019-02-18 03:45:01 -05:00
0f61c627b1 Support deodexed ROM on Pie (Samsung)
- cc @abrahamgcc
2019-02-18 03:32:56 -05:00
17ab55115a Add newlines before rc scripts
Based on #1090, thanks to @shakalaca. Close #1090, close #1086
2019-02-18 03:30:30 -05:00
2708c74ebe Add O_CLOEXEC to opens 2019-02-18 03:25:21 -05:00
50ff11405f Swap out inotify fd before adding watch targets 2019-02-18 03:18:11 -05:00
31a27838f5 Fix help message for magisk 2019-02-18 03:09:01 -05:00
2f1b0fe57f Remove unused scripts 2019-02-18 03:08:40 -05:00