Commit Graph

39 Commits

Author SHA1 Message Date
topjohnwu df4161ffcc Reboot to recovery when running as recovery 2019-03-30 06:49:29 -04:00
topjohnwu 8de03eef3f Allow modules to have custom uninstaller script 2019-03-23 03:50:55 -04:00
topjohnwu 081074ad9d Better zygote process detection 2019-03-08 23:53:53 -05:00
topjohnwu 82c864d57e Make zygote notifier more reliable 2019-03-06 18:22:04 -05:00
topjohnwu b278d07b05 Switch to Zygote ptrace-ing
No matter if we use the old, buggy, error prone am_proc_start monitoring,
or the new APK inotify method, both methods rely on MagiskHide 'reacting'
fast enough to hijack the process before any detection has been done.

However, this is not reliable and practical. There are apps that utilize
native libraries to start detects and register SIGCONT signal handlers
to mitigate all existing MagiskHide process monitoring mechanism. So
our only solution is to hijack an app BEFORE it is started.

All Android apps' process is forked from zygote, so it is easily the
target to be monitored. All forks will be notified, and subsequent
thread spawning (Android apps are heaviliy multithreaded) from children
are also closely monitored to find the earliest possible point to
identify what the process will eventually be (before am_proc_bound).

ptrace is extremely complicated and very difficult to get right. The
current code is heaviliy tested on a stock Android 9.0 Pixel system,
so in theory it should work fine on most devices, but more tests and
potentially fixes are expected to follow this commit.
2019-03-05 20:23:27 -05:00
topjohnwu 6c3896079d Add zygote server notifier 2019-03-05 20:23:27 -05:00
topjohnwu 2f1b0fe57f Remove unused scripts 2019-02-18 03:08:40 -05:00
topjohnwu f4f2274c60 Auto reinstall system apps on hide list
Since we are parsing through /data/app/ to find target APKs for
monitoring, system apps will not be covered in this case.
Automatically reinstall system apps as if they received an update
and refresh the monitor target after it's done.

As a bonus, use RAII idioms for locking pthread_mutex_t.
2019-02-16 02:24:35 -05:00
topjohnwu 19ee189468 Separate scripting code 2019-02-15 20:45:05 -05:00
topjohnwu 71ecbb3af3 Clean/refactor includes 2019-02-10 03:57:51 -05:00
topjohnwu 3a422c3f15 Remove magisklogd, use threads and BlockingQueue 2019-02-10 01:05:19 -05:00
topjohnwu b3242322fd Harden socket verification
- Do not allow connections to magiskd from binaries other than the one started the server
- Do not allow connections to magisklogd without root access
2019-02-09 15:02:46 -05:00
topjohnwu ab5fedda0b Prevent Magisk database race condition
The database should only be accessed by a single process, which is magiskd.
This means 'magisk --sqlite [SQL]' has to be updated to pass the SQL command to the daemon.
In addition, open the database connection with SQLITE_OPEN_FULLMUTEX to support multithread in magiskd.
2018-11-16 03:20:30 -05:00
topjohnwu 572e078d87 Fully deprecate <mount_point>/.core folder
Symlinks are preserved for backwards compatibility
2018-11-15 22:55:28 -05:00
topjohnwu 3a2a2a4ffa Micro optimizations 2018-11-13 02:07:02 -05:00
topjohnwu 5743c72cca Minor cleanup 2018-11-08 15:23:36 -05:00
topjohnwu 0742901cd2 Modernize database code 2018-11-04 18:24:08 -05:00
topjohnwu 5e4d2dedbe Minor log_daemon changes 2018-11-04 17:23:08 -05:00
topjohnwu b8a3cc8b60 Separate magiskhide logic from main daemon 2018-11-01 14:08:33 -04:00
topjohnwu 27c688252d Store hidelist in magisk database 2018-11-01 13:23:12 -04:00
topjohnwu a9121fa28f Reorganize libutils and cleanups 2018-10-12 21:46:09 -04:00
topjohnwu acf7c0c665 Minor reorganization of daemons 2018-10-12 00:50:47 -04:00
topjohnwu d119dd9a0c Rewrite su daemon and client 2018-10-04 04:59:51 -04:00
topjohnwu 906b4aad9e New method of communication
Introduce a new communication method between Magisk and Magisk Manager.

Magisk used to hardcode classnames and send broadcast/start activities to
specific components. This new method makes no assumption of any class names,
so Magisk Manager can easily be fully obfuscated.

In addition, the new method connects Magisk and Magisk Manager with random
abstract Linux sockets instead of socket files in filesystems, bypassing
file system complexities (selinux, permissions and such)
2018-09-16 04:16:18 -04:00
topjohnwu d3858b81e2 Add new boot service: boot-complete 2018-08-09 14:52:44 +08:00
topjohnwu ada0f93686 Apply all sepolicy patches pre-init
Boot services tend to fail in the middle when the kernel loads a sepolicy live.
It seems that moving full patch (allow magisk * * *) to late_start is still not enough to fix service startup failures.
So screw it, apply all patched in magiskinit, which makes sure that all rules are only loaded in a single step.
The only down side is that some OEM with a HUGE set of secontexts (e.g. Samsung) might suffer a slightly longer boot time, which IS the reason why the rules are split to 2 parts in the first place.
2018-08-09 03:20:28 +08:00
topjohnwu 5be035fd44 Try logging a little harder 2018-08-03 01:58:56 +08:00
topjohnwu 46ee2c3f4e Improve handshake between the 2 daemons 2018-07-06 07:51:17 +08:00
topjohnwu 6c4d81b1e9 Invincible mode implemented in magisklogd 2018-07-03 01:38:19 +08:00
topjohnwu a8030c39b1 Separate logging into its own daemon 2018-07-02 22:11:28 +08:00
topjohnwu d08fd0561a Remove invincible mode 2018-06-17 01:28:29 +08:00
topjohnwu 3f83919e09 Fix bootloops when flashing Magisk after data wipe on FBE devices 2018-06-11 02:26:18 +08:00
topjohnwu 34dcf49fbc Update restorecon implementation 2018-06-03 14:43:03 +08:00
topjohnwu 9484ec0c17 Massive refactoring
Remove post-fs mode
2018-04-22 02:16:56 +08:00
topjohnwu 87f6018468 Massive sepolicy refactor 2018-04-15 03:18:18 +08:00
topjohnwu 42284c5efb Test logcat instead of checking logd 2018-04-08 02:12:40 +08:00
topjohnwu 754fafcfe9 Check logd before logging 2018-02-12 02:48:15 +08:00
topjohnwu 40b6fe03c2 Tweak enum 2018-02-11 18:50:42 +08:00
topjohnwu 328fc44194 Rename module core to native 2018-01-27 09:11:28 +08:00