Commit Graph
1937 Commits
Author SHA1 Message Date
Wang HanandGitHub 52ef1d1cb2 Simplify matching selinux context of child zygote (#8845) 2025-03-11 01:27:15 -07:00
John WuandGitHub f14e3a89cc Enable optimize_for_size for Rust std (#8844) 2025-03-10 15:50:43 -07:00
topjohnwu 95d3eac2e0 Cleanup xwrap functions 2025-03-09 01:10:41 -08:00
LoveSyandJohn Wu 12a0870bc9 Replace bzip2 with bz2-rs 2025-03-08 14:37:17 -08:00
topjohnwu 6ff82c4e86 Introduce FsPathFollow
Make sure all operations of FsPath do not follow symlinks, and provide
a way to explicitly switch over to a set of operations that DO follow
symlinks by FsPath::follow_link.
2025-03-07 15:51:51 -08:00
LoveSyandtopjohnwu c64de35375 Move magiskpolicy cli to argh 2025-03-07 14:29:30 -08:00
LoveSyandJohn Wu bd0e954fea Replace zlib with zlib-rs 2025-03-07 11:40:02 -08:00
topjohnwu 675471a49e Upgrade argh to stable release 2025-03-07 02:38:36 -08:00
topjohnwu c90e73ccec Migration to Edition 2024 2025-03-07 02:35:25 -08:00
topjohnwu a43c1267d8 Update Cargo.toml 2025-03-07 02:35:25 -08:00
vvb2060andJohn Wu e8958c6b5c get_secontext: ignore ENODATA 2025-03-06 20:03:36 -08:00
LoveSyandJohn Wu e8a3bf82c6 set exit code of log ExitOnError to -1 2025-03-06 20:03:15 -08:00
topjohnwu c6c1a17ae6 Address several clippy warnings 2025-03-03 02:15:14 -08:00
David K.andJohn Wu 0e82df9e10 Support zImage compression types other than gzip.
Instead of just searching for the gzip magic, it now incrementally searches the kernel for the first thing that `check_fmt_lg` doesn't report as `UNKNOWN`.
2025-03-02 13:35:13 -08:00
topjohnwu c9eac0c438 Introduce new sepolicy strategy for legacy devices
The existing sepolicy patching strategy looks like this:

1. 2SI: use LD_PRELOAD to hijack `security_load_policy`
2. Split policy: devices using split policy implies it also needs to
   do early mount, which means fstab is stored in device tree.
   So we do the following:
   - Hijack the fstab node in the device tree in sysfs
   - Wait for init to mount selinuxfs for us
   - Hijack selinuxfs to intercept sepolicy loading
3. Monolithic policy: directly patch `/sepolicy`

Method #1 and #2 both has the magiskinit pre-init daemon handling
the sepolicy patching and loading process, while method #3 gives us
zero control over sepolicy loading process. Downsides:

a. Pre-init daemon bypasses the need to guess which sepolicy init
   will load, because the original init will literally send the stock
   sepolicy file directly to us with this approach.
b. If we want to add more features/functionalities during the sepolicy
   patching process, we will leave out devices using method #3

In order to solve these issues, we completely redesign the sepolicy
patching strategy for non-2SI devices. Instead of limiting usage of
pre-init daemon to early mount devices, we always intercept the
sepolicy loading process regardless of the Android version and device
setup. This will give us a unified implementation for sepolicy patching,
and will make it easier to develop further new features down the line.
2025-02-28 09:39:10 -08:00
topjohnwu b6b34f7612 Fix overlay.d context preservation 2025-02-27 01:57:25 -08:00
LoveSyandJohn Wu e55c413261 Correctly handle truncated dtb 2025-02-23 20:31:55 -08:00
topjohnwu 019eb03823 Hide or remove mut constructors for Utf8CStr 2025-02-17 11:38:11 -08:00
topjohnwu 363410e1c0 Introduce cstr_buf helper functions 2025-02-17 11:32:21 -08:00
topjohnwu fc2ef21660 Introduce path! macro for FsPath 2025-02-17 01:46:19 -08:00
topjohnwu 63231d97ce Properly handle db downgrades 2025-02-16 17:01:36 -08:00
topjohnwu b73d4a7022 Fix log_ok() 2025-02-16 12:01:25 -08:00
topjohnwu bf591fca12 Fix Utf8CString constructor and add more comments 2025-02-16 01:17:48 -08:00
topjohnwu dcf027884d Update FsPathBuf 2025-02-15 18:27:45 -08:00
topjohnwu 584f3820fe Make all Utf8CStrWrite Utf8CStrBuf 2025-02-15 18:27:45 -08:00
topjohnwu 3c7c46307a Partially cleanup MagiskInit code 2025-02-15 18:27:45 -08:00
vvb2060andJohn Wu 4d80361805 core: search for first available dir in PATH 2025-02-15 15:08:26 -08:00
LoveSyandJohn Wu 9a74e19117 Add log_ok() for log().ok() 2025-02-14 14:24:13 -08:00
LoveSyandJohn Wu b1e17706a4 Format code 2025-02-14 14:24:13 -08:00
LoveSyandJohn Wu caad129d69 Move MagiskInit::patch_sepolicy to rust 2025-02-14 14:24:13 -08:00
LoveSyandJohn Wu da58571ce5 Remove redundant rust export 2025-02-14 14:24:13 -08:00
LoveSyandJohn Wu 2aa7f1c094 Move MagiskInit::check_two_stage to rust 2025-02-14 14:24:13 -08:00
LoveSyandJohn Wu 823e31a91b Use linker to link vfprintf as tiny_vfprintf 2025-02-14 14:24:13 -08:00
LoveSyandJohn Wu fb926ae302 Move MagiskInit::redirect_second_stage to rust 2025-02-14 14:24:13 -08:00
LoveSyandJohn Wu e0489eeffd Move MagiskInit::first_stage to rust 2025-02-14 14:24:13 -08:00
LoveSyandJohn Wu dc9d5a4cac Move MagiskInit::second_stage to rust 2025-02-14 14:24:13 -08:00
LoveSyandJohn Wu 143743d0b0 Refactor init.cpp to init.rs 2025-02-14 14:24:13 -08:00
LoveSyandJohn Wu 563f0d5ad5 Move BootConfig::print to rust 2025-02-14 14:24:13 -08:00
LoveSyandJohn Wu c99f4a591b Move MagiskInit::exec_init to rust 2025-02-14 14:24:13 -08:00
LoveSyandJohn Wu 449204e380 Move MagiskInit::prepare_data to rust 2025-02-14 14:24:13 -08:00
LoveSyandJohn Wu a85c4c6528 Move MagiskInit::MagiskInit to rust 2025-02-14 14:24:13 -08:00
LoveSyandJohn Wu d203a6fff6 Move MagiskInit to rust 2025-02-14 14:24:13 -08:00
LoveSyandJohn Wu 6c612d66d7 Move BootConfig to rust 2025-02-14 14:24:13 -08:00
topjohnwu 540253a55b Remove unnecessary FFI 2025-02-14 11:24:46 -08:00
topjohnwu 442d5335ea Consolidate get_module_fds implementation
Close #8767
2025-02-12 02:55:27 +08:00
topjohnwu 8a80eea597 Directly deal with Rust &str in sepolicy.cpp 2025-02-12 01:26:06 +08:00
topjohnwu b7ca73f431 Remove an additional unique_ptr indirection 2025-02-05 14:18:16 +08:00
a14fc90f07 Fix fetching notification settings from db (#8761)
Co-authored-by: LoveSy <shana@zju.edu.cn>
2025-02-04 17:42:21 +08:00
LoveSyandJohn Wu c913f7ec74 Make sepolicy a shared type between rust and cxx 2025-02-04 00:36:11 +08:00
topjohnwu 7f6c9e8411 Fix zygisk module load 2025-02-03 23:21:51 +08:00