From db99caf25805b89688ac0e0b19e5d468f282bbcd Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 24 Feb 2024 01:47:11 -0800 Subject: [PATCH] Use execve directly --- native/src/crt0/syscall.c | 1 + native/src/init/mount.cpp | 2 +- native/src/init/rootdir.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/native/src/crt0/syscall.c b/native/src/crt0/syscall.c index 2b8bafd84..3cc9b7076 100644 --- a/native/src/crt0/syscall.c +++ b/native/src/crt0/syscall.c @@ -65,6 +65,7 @@ EXPORT_SYMBOL(fchmodat); EXPORT_SYMBOL(fchownat); EXPORT_SYMBOL(readv); EXPORT_SYMBOL(lseek); +EXPORT_SYMBOL(execve); SYMBOL_ALIAS(exit, _exit); diff --git a/native/src/init/mount.cpp b/native/src/init/mount.cpp index 476257870..15538cd26 100644 --- a/native/src/init/mount.cpp +++ b/native/src/init/mount.cpp @@ -243,7 +243,7 @@ void BaseInit::exec_init() { if (xumount2(p.data(), MNT_DETACH) == 0) LOGD("Unmount [%s]\n", p.data()); } - execv("/init", argv); + execve("/init", argv, environ); exit(1); } diff --git a/native/src/init/rootdir.cpp b/native/src/init/rootdir.cpp index c9b54749a..c9667c287 100644 --- a/native/src/init/rootdir.cpp +++ b/native/src/init/rootdir.cpp @@ -403,6 +403,6 @@ int magisk_proxy_main(int argc, char *argv[]) { // Tell magiskd to remount rootfs setenv("REMOUNT_ROOT", "1", 1); - execv("/sbin/magisk", argv); + execve("/sbin/magisk", argv, environ); return 1; }