fix: ReZygiskd Magisk DenyList not checking against process

This commit improves the precision of ReZygiskd check for Magisk if a process is in DenyList/SuList, as previously it used "package_name" instead of the correct "process" field.
This commit is contained in:
ThePedroo
2025-04-27 19:50:59 -03:00
parent 0c0f65998d
commit 0930c8cca4
11 changed files with 47 additions and 34 deletions

View File

@@ -64,7 +64,7 @@ bool rezygiskd_ping() {
return true;
}
uint32_t rezygiskd_get_process_flags(uid_t uid) {
uint32_t rezygiskd_get_process_flags(uid_t uid, const char *const process) {
int fd = rezygiskd_connect(1);
if (fd == -1) {
PLOGE("connection to ReZygiskd");
@@ -74,6 +74,7 @@ uint32_t rezygiskd_get_process_flags(uid_t uid) {
write_uint8_t(fd, (uint8_t)GetProcessFlags);
write_uint32_t(fd, (uint32_t)uid);
write_string(fd, process);
uint32_t res = 0;
read_uint32_t(fd, &res);

View File

@@ -45,6 +45,25 @@ int read_fd(int fd) {
return sendfd;
}
ssize_t write_string(int fd, const char *str) {
size_t str_len = strlen(str);
ssize_t write_bytes = write(fd, &str_len, sizeof(size_t));
if (write_bytes != (ssize_t)sizeof(size_t)) {
LOGE("Failed to write string length: Not all bytes were written (%zd != %zu).\n", write_bytes, sizeof(size_t));
return -1;
}
write_bytes = write(fd, str, str_len);
if (write_bytes != (ssize_t)str_len) {
LOGE("Failed to write string: Promised bytes doesn't exist (%zd != %zu).\n", write_bytes, str_len);
return -1;
}
return write_bytes;
}
char *read_string(int fd) {
size_t str_len = 0;
ssize_t read_bytes = read(fd, &str_len, sizeof(size_t));

View File

@@ -63,7 +63,7 @@ int rezygiskd_connect(uint8_t retry);
bool rezygiskd_ping();
uint32_t rezygiskd_get_process_flags(uid_t uid);
uint32_t rezygiskd_get_process_flags(uid_t uid, const char *const process);
void rezygiskd_get_info(struct rezygisk_info *info);

View File

@@ -4,6 +4,8 @@
#include <stdint.h>
int read_fd(int fd);
ssize_t write_string(int fd, const char *str);
char *read_string(int fd);

View File

@@ -677,7 +677,7 @@ void ZygiskContext::run_modules_post() {
void ZygiskContext::app_specialize_pre() {
flags[APP_SPECIALIZE] = true;
info_flags = rezygiskd_get_process_flags(g_ctx->args.app->uid);
info_flags = rezygiskd_get_process_flags(g_ctx->args.app->uid, (const char *const)process);
if (info_flags & PROCESS_IS_FIRST_STARTED) {
/* INFO: To ensure we are really using a clean mount namespace, we use
the first process it as reference for clean mount namespace,