From 89c9b1b8b85ed1df358575241e6b787cd1bd1ff6 Mon Sep 17 00:00:00 2001 From: Rifat Azad Date: Wed, 16 Jul 2025 21:06:59 +0600 Subject: [PATCH] kernel: use ksu_strncpy_from_user_retry when kprobes hook sucompat pagefaults --- kernel/sucompat.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/kernel/sucompat.c b/kernel/sucompat.c index 35847bed..3140f00f 100644 --- a/kernel/sucompat.c +++ b/kernel/sucompat.c @@ -211,23 +211,8 @@ int ksu_handle_execve_sucompat(int *fd, const char __user **filename_user, if (unlikely(!filename_user)) return 0; - // nofault variant fails probably due to pagefault_disable - // some cpus dont really have that good speculative execution - // substitute set_fs, check if pointer is valid -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,0,0) - if (!access_ok(VERIFY_READ, *filename_user, sizeof(path))) - return 0; -#else - if (!access_ok(*filename_user, sizeof(path))) - return 0; -#endif - // success = returns number of bytes and should be less than path - long len = strncpy_from_user(path, *filename_user, sizeof(path)); - if (len <= 0 || len > sizeof(path)) - return 0; - - // strncpy_from_user_nofault does this too - path[sizeof(path) - 1] = '\0'; + memset(path, 0, sizeof(path)); + ksu_strncpy_from_user_retry(path, *filename_user, sizeof(path)); if (likely(memcmp(path, su, sizeof(su)))) return 0;