Commit Graph
393 Commits
Author SHA1 Message Date
topjohnwu f38e0c8bc6 su: Enable logging and notify by default
When a UID makes a root request for the first time, no row exists in
the policies table. Previously, RootSettings derived Default, which
initialized log and notify to false. As a result, connect_app() skipped
calling app_log() or app_notify() immediately after user approval on
the initial su request.

Explicitly implement Default for RootSettings with log and notify set
to true by default.

Assisted-by: Gemini 3.7 Flash
2026-08-30 00:03:52 +00:00
xAstroBoy 8903cf7f22 zygisk: make built-in Zygisk work on Meta Quest (lazy per-trust partition zygotes)
Meta Quest (Horizon OS) does not start the zygote the normal way: ro.zygote=
zygote64_stub32 launches /system/bin/stub_zygote, which forks a separate
app_process64 zygote PER security partition (system/trusted vs untrusted-app),
driven by hzos_security_zygote_partitioning_policy. The untrusted-app partition
zygote -- the one that forks 3rd-party apps and the Magisk manager -- is spawned
LAZILY, after boot-complete.

magiskd sets ro.dalvik.vm.native.bridge=libzygisk.so during boot but clears it
again at boot-complete (ZygiskState::reset). On a normal device every zygote has
already started by then, so clearing it is harmless. On Quest the untrusted-app
partition zygote reads the (now cleared) property when it finally execve's
app_process64, never loads libzygisk.so, so 3rd-party apps + the Magisk manager
are never injected -> "Zygisk: N/A".

Fix (daemon.rs): on the boot-complete reset(restore=true) path, reset the crash
counter but KEEP native.bridge set (set_prop) instead of clearing it
(restore_prop); only the >3-crash rollback path still clears. The lazily-spawned
partition zygotes then load the loader when they start.

Also (hook.cpp), robustness fixes the loader needs on this device:
 - Wrap hook_zygote_jni()'s JNI locals in PushLocalFrame(64)/PopLocalFrame so
   leaking locals can't trip ART's "non-empty local reference table" abort, and
   bail if GetEnv returns no env.
 - Make the strdup(ZygoteInit) trigger a substring match + add an idempotency
   guard so the zygote hooks install exactly once per process.

Verified on Quest 3 (Android 14): system_server + every app fork is intercepted
and LSPosed loads end-to-end.
2026-08-27 05:38:45 +00:00
topjohnwu 3bdffe695d Generate shorty in comments and reorder jni_hooks 2026-08-12 23:49:37 +00:00
Wang Han 65aa82516f Update jni hook signatures for A17 QPR2 2026-08-11 20:14:03 -07:00
Wang Han 2c98b6ccf2 Update resetprop to support --compact 2026-08-04 12:07:38 -07:00
topjohnwu bffc9108bc Address new clippy warnings 2026-07-31 22:57:41 -07:00
topjohnwu d04635478a Fix clippy warnings across native codebase
Address clippy warnings including collapsible match statements in
bootstages, daemon, su daemon, and db modules, as well as iterator
loops in files.rs.

Assisted-by: Gemini 3.6 Flash
2026-07-31 22:57:41 -07:00
Wang Han ee25db0627 Add jni hooks signature for nubia 2026-02-22 13:20:08 -08:00
topjohnwu 9ee6a6b3d7 Update to ONDK r29.5 2026-02-06 16:32:25 -08:00
Wang Han e872fafd8b Update getModuleDir() API doc 2026-02-05 13:12:34 -08:00
Ephemera42 0d39b10889 Optimize preinit finding and add klogdump partition
* Use major number check to filter out device-mapper devices while preserving virtio-blk compatibility.
* Introduce `klogdump` partition support for Smartisan devices as a valid preinit target.
2026-02-04 21:10:25 -08:00
vvb2060 628b4d4715 Allow reacquiring capabilities if not explicitly cleared
- Old behavior: Switching to a non-zero UID was implicitly interpreted as a request to drop capabilities, thereby preventing subsequent reacquisition  via `su`.
- New behavior: Switching to a non-zero UID now requires the `--drop-cap` argument to explicitly prevent the reacquisition of capabilities.
2026-02-04 11:35:24 -08:00
canyie ac8d4200e1 Add nativeSpecializeAppProcess signature for XR devices running 14
Build fingerprint: google/gms_sdk_xr64_x86_64/emulator64_x86_64:14/UP1A.231005.007.A1/13953962:userdebug/test-keys
2026-01-31 13:51:41 -08:00
topjohnwu 01cb75eaef Code cleanup 2025-12-13 22:12:30 -08:00
topjohnwu ff4ca74cfe Ban all unwrap usage in codebase 2025-12-08 23:31:04 -08:00
topjohnwu 200665c48a Make jni_hooks.hpp a normal C++ header
[skip ci]
2025-12-07 02:44:19 -08:00
topjohnwu dd42aa99ea Refactor gen_jni_hooks.py
[skip ci]
2025-12-07 02:25:50 -08:00
Wang Han 0936cdb192 Update nativeForkAndSpecialize signature for A16 QPR2
https://android.googlesource.com/platform/frameworks/base.git/+/67a4b1b2fee385f798d75ad02d016b80fc79f075
2025-12-07 00:18:50 -08:00
topjohnwu a510554b21 Disable Zygisk upon incomplete JNI hook
Do not enable Zygisk unless ALL replacements are hooked properly.
This allow Zygisk tests to fail when new signature is introduced.
2025-12-07 00:18:50 -08:00
南宫雪珊 9a776c22d9 Revert "Use rootfs for magisktmp if possible" 2025-12-01 11:45:34 -08:00
topjohnwu f7ce9c38e1 Run through clippy and rustfmt 2025-11-29 00:13:41 -08:00
LoveSy bdbfb40383 Use rootfs for magisktmp if possible 2025-11-29 00:13:41 -08:00
topjohnwu 3a60ef2039 Update to ONDK r29.3 2025-11-21 13:28:46 -08:00
Wang Han 52d7eff03f Fix splice direction for ptmx out stream 2025-11-19 15:14:59 -08:00
Wang Han f741a4aeb8 Free regex resources in plt_hook_commit
Free regex resources for registered and ignored hooks before clearing the lists.
2025-11-02 01:59:03 -08:00
topjohnwu 57d9fc6099 Support short only options and switches 2025-10-19 17:15:30 -07:00
topjohnwu b72ba6759e Vendor argh sources
Further customization will come in future commits
2025-10-19 17:15:30 -07:00
topjohnwu 5bcb55b7fc Format Rust imports with rustfmt 2025-10-19 17:15:30 -07:00
topjohnwu 0dc8231585 Make all dependencies workspace = true 2025-10-19 17:15:30 -07:00
topjohnwu d37da5ca66 Cleanup code 2025-10-02 04:18:20 -07:00
topjohnwu 78e2fc37e5 Add easy knobs to disable security checks 2025-10-02 04:09:46 -07:00
LoveSy c07fdc87e3 Handle second splice() failure gracefully 2025-10-02 04:03:27 -07:00
topjohnwu 7270f5e413 Several minor fixes/improvements 2025-10-02 04:03:08 -07:00
Wang Han d60806f429 Only reset NB prop when zygisk is enabled 2025-10-02 03:19:32 -07:00
topjohnwu 3cda9beb93 Cleanup unused bindings 2025-09-24 02:38:18 -07:00
topjohnwu 8b7d1ffcdd Migrate magisk_main to Rust 2025-09-18 03:22:44 -07:00
topjohnwu 8d02d0632e Fix comments 2025-09-18 03:22:44 -07:00
topjohnwu dd743f6f7e Improve Encodable/Decodable impls 2025-09-18 01:17:28 -07:00
topjohnwu cf483ad4d2 Migrate connect_daemon to Rust 2025-09-15 14:25:18 -07:00
topjohnwu 4aed644e08 Directly accept RequestCode for connect_daemon 2025-09-15 14:25:18 -07:00
topjohnwu 0acc39cec0 Use bitflags to implement BootState 2025-09-15 14:25:18 -07:00
topjohnwu 8b3a44344f Move bootstages into its own module 2025-09-15 14:25:18 -07:00
topjohnwu 8b49eda85a Migrate daemon_entry to Rust 2025-09-15 14:25:18 -07:00
topjohnwu 7057d4c7f1 Migrate setup_magisk_env to Rust 2025-09-15 14:25:18 -07:00
topjohnwu 7cccf83b37 Remove unused poll_ctrl implementation 2025-09-14 01:59:04 -07:00
topjohnwu f10ad93c4e Move more code of daemon_entry into Rust 2025-09-13 01:21:33 -07:00
topjohnwu f143b5df15 Do not mount directories as mirror
Mounting real directories into worker will cause init to start tracking
the mount point through dev.mnt. This causes issues, so we are forced
to recursively reconstruct the mirror directory structure from scratch.

Fix #9316
2025-09-12 22:01:08 -07:00
topjohnwu 71213cc6f4 Fix path tracking in module.rs 2025-09-12 22:01:08 -07:00
topjohnwu e2a1774e5b Make logging.rs use nix 2025-09-11 01:17:34 -07:00
topjohnwu 0222527a1e Use bitflags macro 2025-09-11 01:17:34 -07:00