kernel: Fix execve filename access on ARM64

This commit is contained in:
weishu
2025-11-27 03:17:59 +00:00
committed by shirkneko
parent 3a97e6580f
commit 5e64eee624
6 changed files with 135 additions and 92 deletions

View File

@@ -18,6 +18,7 @@
#include "sucompat.h"
#include "setuid_hook.h"
#include "selinux/selinux.h"
#include "util.h"
// Tracepoint registration count management
// == 1: just us
@@ -246,12 +247,22 @@ static inline bool check_syscall_fastpath(int nr)
int ksu_handle_init_mark_tracker(const char __user **filename_user)
{
char path[64];
unsigned long addr;
const char __user *fn;
long ret;
if (unlikely(!filename_user))
return 0;
addr = untagged_addr((unsigned long)*filename_user);
fn = (const char __user *)addr;
memset(path, 0, sizeof(path));
strncpy_from_user_nofault(path, *filename_user, sizeof(path));
ret = strncpy_from_user_nofault(path, fn, sizeof(path));
if (ret < 0 && try_set_access_flag(addr)) {
ret = strncpy_from_user_nofault(path, fn, sizeof(path));
pr_info("ksu_handle_init_mark_tracker: %ld\n", ret);
}
if (likely(strstr(path, "/app_process") == NULL && strstr(path, "/adbd") == NULL && strstr(path, "/ksud") == NULL)) {
pr_info("hook_manager: unmark %d exec %s", current->pid, path);