Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3e8cb47

Browse files
author
ng
committed
Fix mounts cleanup in sar/2si
1 parent a6eb06d commit 3e8cb47

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

‎native/jni/payload/executor.cpp‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,13 @@
4646
#define DEBUG_EXECUTOR "/debug_ramdisk/executor"
4747
#define NEW_MAGISK_PATH "/debug_ramdisk/magisk"
4848

49+
#define INITRC "/init.rc"
4950
#define INITRC_SYSTEM "/system/etc/init/hw/init.rc"
5051
#define INIT_BIN_SYSTEM "/system/bin/init"
5152

53+
#define LIBSELINUX "/system/lib/libselinux.so"
54+
#define LIBSELINUX64 "/system/lib64/libselinux.so"
55+
5256

5357
bool check_fs_decrypted() {
5458
struct dirent *entry;
@@ -79,7 +83,7 @@ int unhide_process(pid_t pid) {
7983

8084
char buf[32];
8185
snprintf(buf, 31, "/proc/%d", pid);
82-
return umount(buf);
86+
return umount2(buf, MNT_DETACH);
8387
}
8488

8589
void block_signals() {
@@ -249,11 +253,21 @@ int main(int argc, char** argv, char** envp) {
249253
delprop(svc_name.c_str());
250254
}
251255

252-
// Unmount init.rc on android 11+ (if no magisk, i.e. revshell is not at debug_ramdisk)
253-
if (access(INITRC_SYSTEM, F_OK) == 0 && access(DEBUG_REVSHELL, F_OK) != 0) {
254-
ALOGD("Unmounting new init.rc");
255-
umount2(INITRC_SYSTEM, MNT_DETACH);
256+
// Unmount init.rc in ramdisk
257+
umount2(INITRC, MNT_DETACH);
258+
259+
// Unmount SAR stuff in /system (if no magisk in debug_ramdisk)
260+
if (access(INIT_BIN_SYSTEM, F_OK) == 0 && access(NEW_MAGISK_PATH, F_OK) != 0) {
261+
ALOGD("Unmounting SAR stuff");
256262
umount2(INIT_BIN_SYSTEM, MNT_DETACH);
263+
// Unmount init.rc on android 11+
264+
if (access(INITRC_SYSTEM, F_OK) == 0)
265+
umount2(INITRC_SYSTEM, MNT_DETACH);
266+
// Unmount libselinux
267+
if (access(LIBSELINUX64, F_OK) == 0)
268+
umount2(LIBSELINUX64, MNT_DETACH);
269+
else if (access(LIBSELINUX, F_OK) == 0)
270+
umount2(LIBSELINUX, MNT_DETACH);
257271
}
258272

259273
// Cleanup /sbin on rootfs

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /