Remove isolated process handling in ptrace

Impossible to achieve only through ptrace
This commit is contained in:
topjohnwu 2021-01-10 17:18:42 -08:00
parent b36e6d987d
commit e546884b08

View File

@ -207,16 +207,8 @@ static bool check_pid(int pid) {
auto it = uid_proc_map.end(); auto it = uid_proc_map.end();
if (uid % 100000 > 90000) { if (uid % 100000 > 90000) {
// Isolated process // No way to handle isolated process
it = uid_proc_map.find(-1);
if (it == uid_proc_map.end())
goto not_target; goto not_target;
for (auto &s : it->second) {
if (str_starts(cmdline, s)) {
LOGI("proc_monitor: (isolated) [%s] PID=[%d] UID=[%d]\n", cmdline, pid, uid);
goto inject_and_hide;
}
}
} }
it = uid_proc_map.find(uid); it = uid_proc_map.find(uid);
@ -226,17 +218,12 @@ static bool check_pid(int pid) {
if (s != cmdline) if (s != cmdline)
continue; continue;
if (str_ends(s, "_zygote")) { // Check if ns is separated (could be app zygote)
LOGI("proc_monitor: (app zygote) [%s] PID=[%d] UID=[%d]\n", cmdline, pid, uid);
goto inject_and_hide;
}
// Double check whether ns is separated
read_ns(pid, &st); read_ns(pid, &st);
for (auto &zit : zygote_map) { for (auto &zit : zygote_map) {
if (zit.second.st_ino == st.st_ino && if (zit.second.st_ino == st.st_ino &&
zit.second.st_dev == st.st_dev) { zit.second.st_dev == st.st_dev) {
// For some reason ns is not separated, abort // ns not separated, abort
goto not_target; goto not_target;
} }
} }
@ -254,11 +241,6 @@ not_target:
PTRACE_LOG("[%s] is not our target\n", cmdline); PTRACE_LOG("[%s] is not our target\n", cmdline);
detach_pid(pid); detach_pid(pid);
return true; return true;
inject_and_hide:
// TODO: handle isolated processes and app zygotes
detach_pid(pid);
return true;
} }
static bool is_process(int pid) { static bool is_process(int pid) {