kernel: increase reliability, add ksu_access_ok to simplify

Co-authored-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
Signed-off-by: rsuntk <rsuntk@yukiprjkt.my.id>
This commit is contained in:
rsuntk
2025-07-22 22:31:58 +07:00
committed by ShirkNeko
parent 39811e311f
commit 0c87765958
4 changed files with 18 additions and 9 deletions

View File

@@ -577,6 +577,7 @@ static int ksu_execve_ksud_common(const char __user *filename_user,
{
struct filename filename_in, *filename_p;
char path[32];
long len;
// return early if disabled.
if (!ksu_execveat_hook) {
@@ -586,8 +587,11 @@ static int ksu_execve_ksud_common(const char __user *filename_user,
if (!filename_user)
return 0;
memset(path, 0, sizeof(path));
ksu_strncpy_from_user_nofault(path, filename_user, 32);
len = ksu_strncpy_from_user_nofault(path, filename_user, 32);
if (len <= 0)
return 0;
path[sizeof(path) - 1] = '\0';
// this is because ksu_handle_execveat_ksud calls it filename->name
filename_in.name = path;