Add webview zygote as umount target

https://github.com/tiann/KernelSU/commit/4521784328352c54334beb29e05c74360b60d7cb
This commit is contained in:
Wang Han
2026-08-30 02:59:46 -07:00
committed by GitHub
parent faa5f85b15
commit b2d86c79c2
5 changed files with 85 additions and 12 deletions
+2
View File
@@ -3,6 +3,8 @@
#include <string_view>
#define ISOLATED_MAGIC "isolated"
#define WEBVIEW_ZYGOTE_MAGIC "webview_zygote"
#define WEBVIEW_ZYGOTE_UID 1053
namespace DenyRequest {
enum : int {
+27 -7
View File
@@ -132,6 +132,32 @@ static void process_main_buffer(struct log_msg *msg) {
if (android_log_processLogBuffer(&msg->entry, &entry) < 0) return;
entry.tagLen--;
auto tag = string_view(entry.tag, entry.tagLen);
auto revert = [](int pid, const char *name, int uid) {
kill(pid, SIGSTOP);
if (fork_dont_care() == 0) {
LOGI("logcat: revert [%s] PID=[%d] UID=[%d]\n", name, pid, uid);
revert_unmount(pid);
kill(pid, SIGCONT);
_exit(0);
}
};
// Unlike app zygote, webview zygote UID is fixed. This means we don't have to
// handle edge cases where apps print logs themselves and lead us into a honeycomb
if (tag == "WebViewZygoteInit") {
int pid = msg->entry.pid;
if (entry.uid != WEBVIEW_ZYGOTE_UID || entry.message[0] != 'S') {
return;
}
if (is_deny_target(WEBVIEW_ZYGOTE_UID, WEBVIEW_ZYGOTE_MAGIC)) {
revert(pid, WEBVIEW_ZYGOTE_MAGIC, WEBVIEW_ZYGOTE_UID);
} else {
LOGD("logcat: skip [%s] PID=[%d] UID=[%d]\n",
WEBVIEW_ZYGOTE_MAGIC, pid, WEBVIEW_ZYGOTE_UID);
}
return;
}
static bool ready = false;
if (tag == "AppZygote") {
@@ -158,13 +184,7 @@ static void process_main_buffer(struct log_msg *msg) {
if (is_deny_target(entry.uid, cmdline)) {
int pid = msg->entry.pid;
kill(pid, SIGSTOP);
if (fork_dont_care() == 0) {
LOGI("logcat: revert [%s] PID=[%d] UID=[%d]\n", cmdline, pid, entry.uid);
revert_unmount(pid);
kill(pid, SIGCONT);
_exit(0);
}
revert(pid, cmdline, entry.uid);
} else {
LOGD("logcat: skip [%s] PID=[%d] UID=[%d]\n", cmdline, msg->entry.pid, entry.uid);
}
+16
View File
@@ -17,6 +17,7 @@ using namespace std;
// For the following data structures:
// If package name == ISOLATED_MAGIC, or app ID == -1, it means isolated service
// If package name == WEBVIEW_ZYGOTE_MAGIC, or app ID == 1053, it means webview zygote
// Package name -> list of process names
static unique_ptr<map<string, set<string, StringCmp>, StringCmp>> pkg_to_procs_;
@@ -56,6 +57,8 @@ static void collect_users(vector<int> &users) {
static int get_app_id(const string &pkg) {
if (pkg == ISOLATED_MAGIC)
return -1;
if (pkg == WEBVIEW_ZYGOTE_MAGIC)
return WEBVIEW_ZYGOTE_UID;
vector<int> users;
collect_users(users);
return get_app_id(users, pkg);
@@ -144,6 +147,9 @@ static bool validate(const char *pkg, const char *proc) {
proc_valid = false;
break;
}
} else if (str_eql(pkg, WEBVIEW_ZYGOTE_MAGIC)) {
pkg_valid = true;
proc_valid = str_eql(proc, WEBVIEW_ZYGOTE_MAGIC);
} else {
for (char c; (c = *pkg); ++pkg) {
if (isalnum(c) || c == '_')
@@ -176,6 +182,8 @@ static bool add_hide_set(const char *pkg, const char *proc) {
if (str_eql(pkg, ISOLATED_MAGIC)) {
// Kill all matching isolated processes
kill_process<&proc_name_match<str_starts_with>>(proc, true);
} else if (str_eql(pkg, WEBVIEW_ZYGOTE_MAGIC)) {
kill_process<&proc_context_match>("u:r:webview_zygote:s0", true);
} else {
kill_process(proc);
}
@@ -196,6 +204,11 @@ void scan_deny_apps() {
it++;
continue;
}
if (it->first == WEBVIEW_ZYGOTE_MAGIC) {
update_app_id(WEBVIEW_ZYGOTE_UID, it->first, false);
it++;
continue;
}
int app_id = get_app_id(users, it->first);
if (app_id == 0) {
LOGI("denylist rm: [%s]\n", it->first.data());
@@ -383,6 +396,9 @@ int enable_deny() {
kill_process("usap64", true);
kill_process<&proc_context_match>("u:r:app_zygote:s0", true);
}
if (pkg_to_procs.find(WEBVIEW_ZYGOTE_MAGIC) != pkg_to_procs.end()) {
kill_process<&proc_context_match>("u:r:webview_zygote:s0", true);
}
}
MagiskD::Get().set_db_setting(DbEntryKey::DenylistConfig, true);